Skip to content

Commit

Permalink
Update CRD doc and tests with added metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
jotak committed Nov 8, 2023
1 parent c63c8aa commit 7286588
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 28 deletions.
4 changes: 2 additions & 2 deletions api/v1beta1/flowcollector_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ func TestBeta1ConversionRoundtrip_Metrics(t *testing.T) {

assert.Equal([]v1beta2.FLPAlert{v1beta2.AlertLokiError}, converted.Spec.Processor.Metrics.DisableAlerts)
assert.NotNil(converted.Spec.Processor.Metrics.IncludeList)
assert.Equal([]string{"namespace_egress_packets_total", "namespace_flows_total"}, *converted.Spec.Processor.Metrics.IncludeList)
assert.Equal([]string{"namespace_egress_packets_total", "namespace_flows_total", "namespace_rtt_seconds", "namespace_drop_packets_total"}, *converted.Spec.Processor.Metrics.IncludeList)

// Other way
var back FlowCollector
err = back.ConvertFrom(&converted)
assert.NoError(err)
// Here, includeList is preserved; it takes precedence over ignoreTags
assert.Equal([]string{"namespace_egress_packets_total", "namespace_flows_total"}, *back.Spec.Processor.Metrics.IncludeList)
assert.Equal([]string{"namespace_egress_packets_total", "namespace_flows_total", "namespace_rtt_seconds", "namespace_drop_packets_total"}, *back.Spec.Processor.Metrics.IncludeList)
assert.Equal(initial.Spec.Processor.Metrics.DisableAlerts, back.Spec.Processor.Metrics.DisableAlerts)
assert.Equal(initial.Spec.Processor.Metrics.Server, back.Spec.Processor.Metrics.Server)
}
Expand Down
5 changes: 5 additions & 0 deletions api/v1beta2/flowcollector_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,11 @@ type FLPMetrics struct {
// `namespace_ingress_packets_total`, `namespace_flows_total`, `node_egress_bytes_total`, `node_egress_packets_total`,
// `node_ingress_bytes_total`, `node_ingress_packets_total`, `node_flows_total`, `workload_egress_bytes_total`,
// `workload_egress_packets_total`, `workload_ingress_bytes_total`, `workload_ingress_packets_total`, `workload_flows_total`.
// When the `PacketDrop` feature is enabled in `spec.agent.ebpf.features`, these additional metrics are available:
// `namespace_drop_bytes_total`, `namespace_drop_packets_total`, `node_drop_bytes_total`, `node_drop_packets_total`,
// `workload_drop_bytes_total`, `workload_drop_packets_total`.
// When the `FlowRTT` feature is enabled in `spec.agent.ebpf.features`, these additional metrics are available:
// `namespace_rtt_seconds`, `node_rtt_seconds`, `workload_rtt_seconds`.
// +optional
IncludeList *[]string `json:"includeList,omitempty"`

Expand Down
9 changes: 8 additions & 1 deletion bundle/manifests/flows.netobserv.io_flowcollectors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7714,7 +7714,14 @@ spec:
`node_ingress_bytes_total`, `node_ingress_packets_total`,
`node_flows_total`, `workload_egress_bytes_total`, `workload_egress_packets_total`,
`workload_ingress_bytes_total`, `workload_ingress_packets_total`,
`workload_flows_total`.'
`workload_flows_total`. When the `PacketDrop` feature is
enabled in `spec.agent.ebpf.features`, these additional
metrics are available: `namespace_drop_bytes_total`, `namespace_drop_packets_total`,
`node_drop_bytes_total`, `node_drop_packets_total`, `workload_drop_bytes_total`,
`workload_drop_packets_total`. When the `FlowRTT` feature
is enabled in `spec.agent.ebpf.features`, these additional
metrics are available: `namespace_rtt_seconds`, `node_rtt_seconds`,
`workload_rtt_seconds`.'
items:
type: string
type: array
Expand Down
9 changes: 8 additions & 1 deletion config/crd/bases/flows.netobserv.io_flowcollectors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7700,7 +7700,14 @@ spec:
`node_ingress_bytes_total`, `node_ingress_packets_total`,
`node_flows_total`, `workload_egress_bytes_total`, `workload_egress_packets_total`,
`workload_ingress_bytes_total`, `workload_ingress_packets_total`,
`workload_flows_total`.'
`workload_flows_total`. When the `PacketDrop` feature is
enabled in `spec.agent.ebpf.features`, these additional
metrics are available: `namespace_drop_bytes_total`, `namespace_drop_packets_total`,
`node_drop_bytes_total`, `node_drop_packets_total`, `workload_drop_bytes_total`,
`workload_drop_packets_total`. When the `FlowRTT` feature
is enabled in `spec.agent.ebpf.features`, these additional
metrics are available: `namespace_rtt_seconds`, `node_rtt_seconds`,
`workload_rtt_seconds`.'
items:
type: string
type: array
Expand Down
2 changes: 1 addition & 1 deletion docs/FlowCollector.md
Original file line number Diff line number Diff line change
Expand Up @@ -13717,7 +13717,7 @@ target specifies the target value for the given metric
<td><b>includeList</b></td>
<td>[]string</td>
<td>
`includeList` is a list of metric names to specify which metrics to generate. The names correspond to the name in Prometheus, without the prefix. For example, `namespace_egress_packets_total` will show up as `netobserv_namespace_egress_packets_total` in Prometheus. Available names are: `namespace_egress_bytes_total`, `namespace_egress_packets_total`, `namespace_ingress_bytes_total`, `namespace_ingress_packets_total`, `namespace_flows_total`, `node_egress_bytes_total`, `node_egress_packets_total`, `node_ingress_bytes_total`, `node_ingress_packets_total`, `node_flows_total`, `workload_egress_bytes_total`, `workload_egress_packets_total`, `workload_ingress_bytes_total`, `workload_ingress_packets_total`, `workload_flows_total`.<br/>
`includeList` is a list of metric names to specify which metrics to generate. The names correspond to the name in Prometheus, without the prefix. For example, `namespace_egress_packets_total` will show up as `netobserv_namespace_egress_packets_total` in Prometheus. Available names are: `namespace_egress_bytes_total`, `namespace_egress_packets_total`, `namespace_ingress_bytes_total`, `namespace_ingress_packets_total`, `namespace_flows_total`, `node_egress_bytes_total`, `node_egress_packets_total`, `node_ingress_bytes_total`, `node_ingress_packets_total`, `node_flows_total`, `workload_egress_bytes_total`, `workload_egress_packets_total`, `workload_ingress_bytes_total`, `workload_ingress_packets_total`, `workload_flows_total`. When the `PacketDrop` feature is enabled in `spec.agent.ebpf.features`, these additional metrics are available: `namespace_drop_bytes_total`, `namespace_drop_packets_total`, `node_drop_bytes_total`, `node_drop_packets_total`, `workload_drop_bytes_total`, `workload_drop_packets_total`. When the `FlowRTT` feature is enabled in `spec.agent.ebpf.features`, these additional metrics are available: `namespace_rtt_seconds`, `node_rtt_seconds`, `workload_rtt_seconds`.<br/>
</td>
<td>false</td>
</tr><tr>
Expand Down
2 changes: 1 addition & 1 deletion hack/cloned.flows.netobserv.io_flowcollectors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5320,7 +5320,7 @@ spec:
type: string
type: array
includeList:
description: '`includeList` is a list of metric names to specify which metrics to generate. The names correspond to the name in Prometheus, without the prefix. For example, `namespace_egress_packets_total` will show up as `netobserv_namespace_egress_packets_total` in Prometheus. Available names are: `namespace_egress_bytes_total`, `namespace_egress_packets_total`, `namespace_ingress_bytes_total`, `namespace_ingress_packets_total`, `namespace_flows_total`, `node_egress_bytes_total`, `node_egress_packets_total`, `node_ingress_bytes_total`, `node_ingress_packets_total`, `node_flows_total`, `workload_egress_bytes_total`, `workload_egress_packets_total`, `workload_ingress_bytes_total`, `workload_ingress_packets_total`, `workload_flows_total`.'
description: '`includeList` is a list of metric names to specify which metrics to generate. The names correspond to the name in Prometheus, without the prefix. For example, `namespace_egress_packets_total` will show up as `netobserv_namespace_egress_packets_total` in Prometheus. Available names are: `namespace_egress_bytes_total`, `namespace_egress_packets_total`, `namespace_ingress_bytes_total`, `namespace_ingress_packets_total`, `namespace_flows_total`, `node_egress_bytes_total`, `node_egress_packets_total`, `node_ingress_bytes_total`, `node_ingress_packets_total`, `node_flows_total`, `workload_egress_bytes_total`, `workload_egress_packets_total`, `workload_ingress_bytes_total`, `workload_ingress_packets_total`, `workload_flows_total`. When the `PacketDrop` feature is enabled in `spec.agent.ebpf.features`, these additional metrics are available: `namespace_drop_bytes_total`, `namespace_drop_packets_total`, `node_drop_bytes_total`, `node_drop_packets_total`, `workload_drop_bytes_total`, `workload_drop_packets_total`. When the `FlowRTT` feature is enabled in `spec.agent.ebpf.features`, these additional metrics are available: `namespace_rtt_seconds`, `node_rtt_seconds`, `workload_rtt_seconds`.'
items:
type: string
type: array
Expand Down
10 changes: 5 additions & 5 deletions pkg/dashboards/dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestCreateFlowMetricsDashboard_All(t *testing.T) {
assert.NoError(err)

assert.Equal("NetObserv", d.Title)
assert.Len(d.Rows, 12)
assert.Len(d.Rows, 18)

// First row
row := 0
Expand All @@ -28,8 +28,8 @@ func TestCreateFlowMetricsDashboard_All(t *testing.T) {
assert.Len(d.Rows[row].Panels[0].Targets, 1)
assert.Contains(d.Rows[row].Panels[0].Targets[0].Expr, "label_replace(label_replace(topk(10,sum(rate(netobserv_node_egress_bytes_total[1m])) by (SrcK8S_HostName, DstK8S_HostName))")

// 6th row
row = 5
// 8th row
row = 7
assert.Equal("Top byte rates received per source and destination namespaces", d.Rows[row].Title)
assert.Len(d.Rows[row].Panels, 2)
assert.Equal("Applications", d.Rows[row].Panels[0].Title)
Expand All @@ -42,8 +42,8 @@ func TestCreateFlowMetricsDashboard_All(t *testing.T) {
`label_replace(label_replace(topk(10,sum(rate(netobserv_namespace_ingress_bytes_total{SrcK8S_Namespace=~"netobserv|openshift.*"}[1m]) or rate(netobserv_namespace_ingress_bytes_total{SrcK8S_Namespace!~"netobserv|openshift.*",DstK8S_Namespace=~"netobserv|openshift.*"}[1m])) by (SrcK8S_Namespace, DstK8S_Namespace))`,
)

// 12th row
row = 11
// 16th row
row = 15
assert.Equal("Top packet rates received per source and destination workloads", d.Rows[row].Title)
assert.Len(d.Rows[row].Panels, 2)
assert.Equal("Applications", d.Rows[row].Panels[0].Title)
Expand Down
20 changes: 9 additions & 11 deletions pkg/metrics/predefined_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func init() {
ValueKey: valueField,
Filters: []flpapi.PromMetricsFilter{
{Key: "Duplicate", Value: "false"},
{Key: "FlowDirection", Value: mapDirection[dir], Type: "regex"},
{Key: "FlowDirection", Value: mapDirection[dir], Type: flpapi.PromFilterRegex},
},
Labels: labels,
},
Expand All @@ -81,16 +81,14 @@ func init() {
// RTT metrics
predefinedMetrics = append(predefinedMetrics, taggedMetricDefinition{
PromMetricsItem: flpapi.PromMetricsItem{
Name: fmt.Sprintf("%s_rtt", groupTrimmed),
Name: fmt.Sprintf("%s_rtt_seconds", groupTrimmed),
Type: "histogram",
ValueKey: "TimeFlowRttNs",
Filters: []flpapi.PromMetricsFilter{
{Key: "TimeFlowRttNs", Value: "!nil"},
{Key: "TimeFlowRttNs", Type: flpapi.PromFilterPresence},
},
Labels: labels,
// TODO: Add Scaling to prom API to avoid having these poor buckets
// (convert ns => s)
Buckets: []float64{10, 1000, 100000, 10_000_000, 1_000_000_000},
Labels: labels,
ValueScale: 1_000_000_000, // ns => s
},
tags: []string{group, "rtt"},
})
Expand All @@ -102,11 +100,11 @@ func init() {
ValueKey: "PktDropPackets",
Filters: []flpapi.PromMetricsFilter{
{Key: "Duplicate", Value: "false"},
{Key: "PktDropPackets", Value: "!nil"},
{Key: "PktDropPackets", Type: flpapi.PromFilterPresence},
},
Labels: labels,
},
tags: []string{group, "drop-packets"},
tags: []string{group, tagPackets, "drops"},
})
predefinedMetrics = append(predefinedMetrics, taggedMetricDefinition{
PromMetricsItem: flpapi.PromMetricsItem{
Expand All @@ -115,11 +113,11 @@ func init() {
ValueKey: "PktDropBytes",
Filters: []flpapi.PromMetricsFilter{
{Key: "Duplicate", Value: "false"},
{Key: "PktDropBytes", Value: "!nil"},
{Key: "PktDropBytes", Type: flpapi.PromFilterPresence},
},
Labels: labels,
},
tags: []string{group, "drop-packets"},
tags: []string{group, tagBytes, "drop"},
})
}
}
Expand Down
9 changes: 3 additions & 6 deletions pkg/metrics/predefined_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@ func TestIncludeExclude(t *testing.T) {
res := GetEnabledNames([]string{"egress", "packets", "flows"}, nil)
assert.Equal([]string{
"node_ingress_bytes_total",
"node_rtt",
"node_drop_packets_total",
"node_rtt_seconds",
"node_drop_bytes_total",
"namespace_ingress_bytes_total",
"namespace_rtt",
"namespace_drop_packets_total",
"namespace_rtt_seconds",
"namespace_drop_bytes_total",
"workload_ingress_bytes_total",
"workload_rtt",
"workload_drop_packets_total",
"workload_rtt_seconds",
"workload_drop_bytes_total",
}, res)

Expand Down

0 comments on commit 7286588

Please sign in to comment.