Skip to content

Commit 4ce3c75

Browse files
committed
expose FlowMetric help and autogenerate defaults
1 parent 5c0c0c7 commit 4ce3c75

File tree

9 files changed

+33
-1
lines changed

9 files changed

+33
-1
lines changed

api/flowmetrics/v1alpha1/flowmetric_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ type FlowMetricSpec struct {
7676
// +required
7777
Type MetricType `json:"type"`
7878

79+
// Help text of the metric, as it appears in Prometheus.
80+
// +optional
81+
Help string `json:"help,omitempty"`
82+
7983
// `valueField` is the flow field that must be used as a value for this metric (for example: `Bytes`). This field must hold numeric values.
8084
// Leave empty to count flows rather than a specific value per flow.
8185
// Refer to the documentation for the list of available fields: https://docs.redhat.com/en/documentation/openshift_container_platform/latest/html/network_observability/json-flows-format-reference.

bundle/manifests/flows.netobserv.io_flowmetrics.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ spec:
192192
items:
193193
type: string
194194
type: array
195+
help:
196+
description: Help text of the metric, as it appears in Prometheus.
197+
type: string
195198
labels:
196199
description: |-
197200
`labels` is a list of fields that should be used as Prometheus labels, also known as dimensions (for example: `SrcK8S_Namespace`).

bundle/manifests/netobserv-operator.clusterserviceversion.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ metadata:
253253
categories: Monitoring, Networking, Observability
254254
console.openshift.io/plugins: '["netobserv-plugin"]'
255255
containerImage: quay.io/netobserv/network-observability-operator:1.9.2-community
256-
createdAt: "2025-09-30T17:05:14Z"
256+
createdAt: "2025-10-01T10:32:51Z"
257257
description: Network flows collector and monitoring solution
258258
operatorframework.io/initialization-resource: '{"apiVersion":"flows.netobserv.io/v1beta2",
259259
"kind":"FlowCollector","metadata":{"name":"cluster"},"spec": {}}'

config/crd/bases/flows.netobserv.io_flowmetrics.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ spec:
192192
items:
193193
type: string
194194
type: array
195+
help:
196+
description: Help text of the metric, as it appears in Prometheus.
197+
type: string
195198
labels:
196199
description: |-
197200
`labels` is a list of fields that should be used as Prometheus labels, also known as dimensions (for example: `SrcK8S_Namespace`).

docs/FlowMetric.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ Refer to the documentation for the list of available fields: https://docs.redhat
152152
For instance, when flattening `Interfaces` on a bytes counter, a flow having Interfaces [br-ex, ens5] increases one counter for `br-ex` and another for `ens5`.<br/>
153153
</td>
154154
<td>false</td>
155+
</tr><tr>
156+
<td><b>help</b></td>
157+
<td>string</td>
158+
<td>
159+
Help text of the metric, as it appears in Prometheus.<br/>
160+
</td>
161+
<td>false</td>
155162
</tr><tr>
156163
<td><b>labels</b></td>
157164
<td>[]string</td>

helm/crds/flows.netobserv.io_flowmetrics.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ spec:
180180
items:
181181
type: string
182182
type: array
183+
help:
184+
description: Help text of the metric, as it appears in Prometheus.
185+
type: string
183186
labels:
184187
description: |-
185188
`labels` is a list of fields that should be used as Prometheus labels, also known as dimensions (for example: `SrcK8S_Namespace`).

internal/controller/flp/flp_pipeline_builder.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ func flowMetricToFLP(fm *metricslatest.FlowMetric) (*api.MetricsItem, error) {
409409
m := &api.MetricsItem{
410410
Name: metricName,
411411
Type: api.MetricEncodeOperationEnum(strings.ToLower(string(fm.Spec.Type))),
412+
Help: fm.Spec.Help,
412413
Filters: []api.MetricsFilter{},
413414
Labels: fm.Spec.Labels,
414415
Remap: remap,

internal/pkg/helper/otel/otel_config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ func GetOtelMetrics(flpMetrics []api.MetricsItem) ([]api.MetricsItem, error) {
8989
otelMetrics = append(otelMetrics, api.MetricsItem{
9090
Name: convertToOtelLabel(otelRules, m.Name),
9191
Type: m.Type,
92+
Help: m.Help,
9293
Filters: convertToOtelFilters(otelRules, m.Filters),
9394
ValueKey: convertToOtelLabel(otelRules, m.ValueKey),
9495
Labels: convertToOtelLabels(otelRules, m.Labels),

internal/pkg/metrics/predefined_metrics.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func init() {
5656
FlowMetricSpec: metricslatest.FlowMetricSpec{
5757
MetricName: fmt.Sprintf("%s_%s_%s_total", groupTrimmed, lowDir, vt),
5858
Type: metricslatest.CounterMetric,
59+
Help: fmt.Sprintf("Total %s per %s in %s direction", vt, groupTrimmed, lowDir),
5960
ValueField: valueField,
6061
Direction: dir,
6162
Labels: labels,
@@ -70,6 +71,7 @@ func init() {
7071
FlowMetricSpec: metricslatest.FlowMetricSpec{
7172
MetricName: fmt.Sprintf("%s_sampling", groupTrimmed),
7273
Type: metricslatest.GaugeMetric,
74+
Help: fmt.Sprintf("Sampling per %s", groupTrimmed),
7375
ValueField: "Sampling",
7476
Labels: labels,
7577
},
@@ -80,6 +82,7 @@ func init() {
8082
FlowMetricSpec: metricslatest.FlowMetricSpec{
8183
MetricName: fmt.Sprintf("%s_flows_total", groupTrimmed),
8284
Type: "counter",
85+
Help: fmt.Sprintf("Total flows per %s", groupTrimmed),
8386
Labels: labels,
8487
},
8588
tags: []string{group, group + "-flows", "flows"},
@@ -93,6 +96,7 @@ func init() {
9396
FlowMetricSpec: metricslatest.FlowMetricSpec{
9497
MetricName: fmt.Sprintf("%s_rtt_seconds", groupTrimmed),
9598
Type: metricslatest.HistogramMetric,
99+
Help: fmt.Sprintf("Round-trip time latency in seconds per %s", groupTrimmed),
96100
ValueField: "TimeFlowRttNs",
97101
Filters: []metricslatest.MetricFilter{
98102
{Field: "TimeFlowRttNs", MatchType: metricslatest.MatchPresence},
@@ -115,6 +119,7 @@ func init() {
115119
FlowMetricSpec: metricslatest.FlowMetricSpec{
116120
MetricName: fmt.Sprintf("%s_drop_packets_total", groupTrimmed),
117121
Type: metricslatest.CounterMetric,
122+
Help: fmt.Sprintf("Total dropped packets per %s", groupTrimmed),
118123
ValueField: "PktDropPackets",
119124
Filters: []metricslatest.MetricFilter{
120125
{Field: "PktDropPackets", MatchType: metricslatest.MatchPresence},
@@ -128,6 +133,7 @@ func init() {
128133
FlowMetricSpec: metricslatest.FlowMetricSpec{
129134
MetricName: fmt.Sprintf("%s_drop_bytes_total", groupTrimmed),
130135
Type: metricslatest.CounterMetric,
136+
Help: fmt.Sprintf("Total dropped bytes per %s", groupTrimmed),
131137
ValueField: "PktDropBytes",
132138
Filters: []metricslatest.MetricFilter{
133139
{Field: "PktDropBytes", MatchType: metricslatest.MatchPresence},
@@ -148,6 +154,7 @@ func init() {
148154
FlowMetricSpec: metricslatest.FlowMetricSpec{
149155
MetricName: fmt.Sprintf("%s_dns_latency_seconds", groupTrimmed),
150156
Type: metricslatest.HistogramMetric,
157+
Help: fmt.Sprintf("DNS latency in seconds per %s", groupTrimmed),
151158
ValueField: "DnsLatencyMs",
152159
Filters: []metricslatest.MetricFilter{
153160
{Field: "DnsId", MatchType: metricslatest.MatchPresence},
@@ -171,6 +178,7 @@ func init() {
171178
FlowMetricSpec: metricslatest.FlowMetricSpec{
172179
MetricName: fmt.Sprintf("%s_network_policy_events_total", groupTrimmed),
173180
Type: "counter",
181+
Help: fmt.Sprintf("Total network policy events per %s", groupTrimmed),
174182
Labels: netpolLabels,
175183
Filters: []metricslatest.MetricFilter{{Field: "NetworkEvents>Feature", Value: "acl"}},
176184
Flatten: []string{"NetworkEvents"},
@@ -197,6 +205,7 @@ func init() {
197205
FlowMetricSpec: metricslatest.FlowMetricSpec{
198206
MetricName: fmt.Sprintf("%s_ipsec_flows_total", groupTrimmed),
199207
Type: metricslatest.CounterMetric,
208+
Help: fmt.Sprintf("Total IPsec encrypted flows per %s", groupTrimmed),
200209
Filters: []metricslatest.MetricFilter{{Field: "IPSecStatus", MatchType: metricslatest.MatchPresence}},
201210
Labels: ipsecLabels,
202211
Charts: ipsecStatusChart(group),
@@ -209,6 +218,7 @@ func init() {
209218
FlowMetricSpec: metricslatest.FlowMetricSpec{
210219
MetricName: "node_to_node_ingress_flows_total",
211220
Type: metricslatest.CounterMetric,
221+
Help: "Total ingress flows between nodes",
212222
Labels: mapLabels[tagNodes],
213223
Filters: []metricslatest.MetricFilter{
214224
{Field: "FlowDirection", Value: "2", MatchType: metricslatest.MatchNotEqual},

0 commit comments

Comments
 (0)