Skip to content

Commit

Permalink
Add OVS table name as label for ovs_flow_count Prometheus metrics (#4893
Browse files Browse the repository at this point in the history
)

Signed-off-by: Cheng, Seven <seven.cheng@sap.com>
Co-authored-by: Cheng, Seven <seven.cheng@sap.com>
  • Loading branch information
cr7258 and Cheng, Seven authored Apr 25, 2023
1 parent 7acbb39 commit eb7b3f0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/prometheus-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ managed by the Antrea Agent.
- **antrea_agent_networkpolicy_count:** Number of NetworkPolicies on local
Node which are managed by the Antrea Agent.
- **antrea_agent_ovs_flow_count:** Flow count for each OVS flow table. The
TableID is used as a label.
TableID and TableName are used as labels.
- **antrea_agent_ovs_flow_ops_count:** Number of OVS flow operations,
partitioned by operation type (add, modify and delete).
- **antrea_agent_ovs_flow_ops_error_count:** Number of OVS flow operation
Expand Down
4 changes: 2 additions & 2 deletions pkg/agent/metrics/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ var (
Namespace: metricNamespaceAntrea,
Subsystem: metricSubsystemAgent,
Name: "ovs_flow_count",
Help: "Flow count for each OVS flow table. The TableID is used as a label.",
Help: "Flow count for each OVS flow table. The TableID and TableName are used as labels.",
StabilityLevel: metrics.STABLE,
}, []string{"table_id"})
}, []string{"table_id", "table_name"})

OVSFlowOpsCount = metrics.NewCounterVec(
&metrics.CounterOpts{
Expand Down
4 changes: 2 additions & 2 deletions pkg/ovs/openflow/ofctrl_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (t *ofTable) UpdateStatus(flowCountDelta int) {
}

metrics.OVSTotalFlowCount.Add(float64(flowCountDelta))
metrics.OVSFlowCount.WithLabelValues(strconv.Itoa(int(t.id))).Add(float64(flowCountDelta))
metrics.OVSFlowCount.WithLabelValues(strconv.Itoa(int(t.id)), t.name).Add(float64(flowCountDelta))

t.updateTime = time.Now()
}
Expand All @@ -115,7 +115,7 @@ func (t *ofTable) ResetStatus() {

t.flowCount = 0

metrics.OVSFlowCount.WithLabelValues(strconv.Itoa(int(t.id))).Set(0)
metrics.OVSFlowCount.WithLabelValues(strconv.Itoa(int(t.id)), t.name).Set(0)

t.updateTime = time.Now()
}
Expand Down
4 changes: 2 additions & 2 deletions test/integration/agent/openflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1019,13 +1019,13 @@ func getIPProtoStr(addr types.Address) (bool, string) {

func checkOVSFlowMetrics(t *testing.T, client ofClient.Client) {
expectedFlowCount := `
# HELP antrea_agent_ovs_flow_count [STABLE] Flow count for each OVS flow table. The TableID is used as a label.
# HELP antrea_agent_ovs_flow_count [STABLE] Flow count for each OVS flow table. The TableID and TableName are used as labels.
# TYPE antrea_agent_ovs_flow_count gauge
`
tableStatus := client.GetFlowTableStatus()
totalFlowCount := 0
for _, table := range tableStatus {
expectedFlowCount = expectedFlowCount + fmt.Sprintf("antrea_agent_ovs_flow_count{table_id=\"%d\"} %d\n", table.ID, table.FlowCount)
expectedFlowCount = expectedFlowCount + fmt.Sprintf("antrea_agent_ovs_flow_count{table_id=\"%d\", table_name=\"%s\"} %d\n", table.ID, table.Name, table.FlowCount)
totalFlowCount = totalFlowCount + int(table.FlowCount)
}
expectedTotalFlowCount := `
Expand Down

0 comments on commit eb7b3f0

Please sign in to comment.