From 73c0e8e6494121374556bd4e90b45a95aeb10290 Mon Sep 17 00:00:00 2001 From: Paul Meyer <49727155+katexochen@users.noreply.github.com> Date: Fri, 12 Jul 2024 13:29:24 +0200 Subject: [PATCH] meshapi: follow best practice for metric names Counters should have a _total suffix. Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com> --- coordinator/meshapi.go | 2 +- docs/docs/architecture/observability.md | 2 +- e2e/policy/policy_test.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/coordinator/meshapi.go b/coordinator/meshapi.go index 7e1eed8f07..05fa80be8a 100644 --- a/coordinator/meshapi.go +++ b/coordinator/meshapi.go @@ -49,7 +49,7 @@ func newMeshAPIServer(meshAuth *authority.Authority, bundleGetter certBundleGett attestationFailuresCounter := promauto.With(reg).NewCounter(prometheus.CounterOpts{ Subsystem: "contrast_meshapi", - Name: "attestation_failures", + Name: "attestation_failures_total", Help: "Number of attestation failures from workloads to the Coordinator.", }) diff --git a/docs/docs/architecture/observability.md b/docs/docs/architecture/observability.md index 4b792265e1..048eb5284c 100644 --- a/docs/docs/architecture/observability.md +++ b/docs/docs/architecture/observability.md @@ -28,7 +28,7 @@ Coordinator](../deployment#verify-the-coordinator) respectively. The `meshapi.MeshAPI` service records metrics for the method `NewMeshCert`, which gets called by the [Initializer](../components#the-initializer) when starting a new workload. Attestation failures from workloads to the Coordinator can be -tracked with the counter `contrast_meshapi_attestation_failures`. +tracked with the counter `contrast_meshapi_attestation_failures_total`. The current manifest generation is exposed as a [gauge](https://prometheus.io/docs/concepts/metric_types/#gauge) with the metric diff --git a/e2e/policy/policy_test.go b/e2e/policy/policy_test.go index bec6f87d66..0fd02696ad 100644 --- a/e2e/policy/policy_test.go +++ b/e2e/policy/policy_test.go @@ -165,13 +165,13 @@ func getFailures(ctx context.Context, t *testing.T, ct *contrasttest.ContrastTes require.NoError(err) failures := -1 for k, v := range metrics { - if k == "contrast_meshapi_attestation_failures" { + if k == "contrast_meshapi_attestation_failures_total" { failures = int(v.GetMetric()[0].GetCounter().GetValue()) } } if failures == -1 { // metric not found - t.Error("metric \"contrast_meshapi_attestation_failures\" not found") + t.Error("metric \"contrast_meshapi_attestation_failures_total\" not found") } return failures }