From 1bee784f0df6a9d364e94e3f655860044beb06ba Mon Sep 17 00:00:00 2001 From: Danny__Wei Date: Thu, 14 Nov 2024 16:22:12 +0800 Subject: [PATCH] Add varmor prefix for all metrics --- grafana/panel.json | 34 +++++++++++++++---------------- internal/status/api/v1/manager.go | 8 ++++---- internal/status/api/v1/status.go | 2 +- internal/webhooks/server.go | 8 ++++---- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/grafana/panel.json b/grafana/panel.json index 3cb4db2..ad36741 100644 --- a/grafana/panel.json +++ b/grafana/panel.json @@ -117,7 +117,7 @@ "targets": [ { "editorMode": "code", - "expr": "sum(profile_processing_failure_total)", + "expr": "sum(varmor_profile_processing_failure_total)", "format": "time_series", "legendFormat": "Failure Total", "range": true, @@ -129,7 +129,7 @@ "uid": "prometheus" }, "editorMode": "code", - "expr": "sum(profile_processing_failure_total)", + "expr": "sum(varmor_profile_processing_failure_total)", "hide": false, "instant": false, "legendFormat": "Success Total", @@ -223,7 +223,7 @@ "targets": [ { "editorMode": "code", - "expr": "sum(profile_change_count_total) by (node_name)", + "expr": "sum(varmor_profile_change_count_total) by (node_name)", "legendFormat": "{{node_name}} Total Changes", "range": true, "refId": "A" @@ -287,7 +287,7 @@ "targets": [ { "editorMode": "code", - "expr": "sum(profile_processing_failure_total) by (node_name)", + "expr": "sum(varmor_profile_processing_failure_total) by (node_name)", "format": "time_series", "legendFormat": "{{node_name}} Failure Total", "range": true, @@ -352,7 +352,7 @@ "targets": [ { "editorMode": "code", - "expr": "sum(profile_processing_success_total) by (node_name)", + "expr": "sum(varmor_profile_processing_success_total) by (node_name)", "format": "time_series", "legendFormat": "{{node_name}} Success Total", "range": true, @@ -448,7 +448,7 @@ "pluginVersion": "11.3.0", "targets": [ { - "expr": "rate(profile_change_count_total[5m])", + "expr": "rate(varmor_profile_change_count_total[5m])", "legendFormat": "Change Rate", "refId": "A" } @@ -542,12 +542,12 @@ "pluginVersion": "11.3.0", "targets": [ { - "expr": "rate(profile_processing_success_total[5m])", + "expr": "rate(varmor_profile_processing_success_total[5m])", "legendFormat": "Success Rate", "refId": "A" }, { - "expr": "rate(profile_processing_failure_total[5m])", + "expr": "rate(varmor_profile_processing_failure_total[5m])", "legendFormat": "Failure Rate", "refId": "B" } @@ -623,7 +623,7 @@ "targets": [ { "editorMode": "code", - "expr": "profile_status_per_node", + "expr": "varmor_profile_status_per_node", "format": "table", "instant": true, "refId": "A" @@ -757,17 +757,17 @@ "pluginVersion": "11.3.0", "targets": [ { - "expr": "admission_requests_total", + "expr": "varmor_admission_requests_total", "legendFormat": "Total Requests", "refId": "A" }, { - "expr": "mutated_requests_total", + "expr": "varmor_mutated_requests_total", "legendFormat": "Mutated", "refId": "B" }, { - "expr": "non_mutated_requests_total", + "expr": "varmor_non_mutated_requests_total", "legendFormat": "Non-mutated", "refId": "C" } @@ -857,12 +857,12 @@ "pluginVersion": "11.3.0", "targets": [ { - "expr": "rate(admission_requests_total[5m])", + "expr": "rate(varmor_admission_requests_total[5m])", "legendFormat": "Request Rate", "refId": "A" }, { - "expr": "rate(mutated_requests_total[5m])", + "expr": "rate(varmor_mutated_requests_total[5m])", "legendFormat": "Mutation Rate", "refId": "B" } @@ -975,7 +975,7 @@ }, "editorMode": "code", "exemplar": false, - "expr": "sum(webhook_latency_sum) by (operation) / sum(webhook_latency_count) by (operation)\n", + "expr": "sum(varmor_webhook_latency_sum) by (request_operation) / sum(varmor_webhook_latency_count) by (request_operation)\n", "format": "time_series", "hide": false, "instant": false, @@ -1003,11 +1003,11 @@ "type": "prometheus", "uid": "prometheus" }, - "definition": "label_values(profile_status_per_node, namespace)", + "definition": "label_values(varmor_profile_status_per_node, namespace)", "name": "namespace", "options": [], "query": { - "query": "label_values(profile_status_per_node, namespace)", + "query": "label_values(varmor_profile_status_per_node, namespace)", "refId": "StandardVariableQuery" }, "refresh": 2, diff --git a/internal/status/api/v1/manager.go b/internal/status/api/v1/manager.go index c99e867..0cae5a5 100644 --- a/internal/status/api/v1/manager.go +++ b/internal/status/api/v1/manager.go @@ -96,10 +96,10 @@ func NewStatusManager(coreInterface corev1.CoreV1Interface, } if metricsModule.Enabled { - m.profileSuccess = metricsModule.RegisterFloat64Counter("profile_processing_success", "Number of successful profile processing") - m.profileFailure = metricsModule.RegisterFloat64Counter("profile_processing_failure", "Number of failed profile processing") - m.profileChangeCount = metricsModule.RegisterFloat64Counter("profile_change_count", "Number of profile change") - //m.profileStatusPerNode = metricsModule.RegisterFloat64Gauge("profile_status_per_node", "Profile status per node (1=success, 0=failure)") + m.profileSuccess = metricsModule.RegisterFloat64Counter("varmor_profile_processing_success", "Number of successful profile processing") + m.profileFailure = metricsModule.RegisterFloat64Counter("varmor_profile_processing_failure", "Number of failed profile processing") + m.profileChangeCount = metricsModule.RegisterFloat64Counter("varmor_profile_change_count", "Number of profile change") + //m.profileStatusPerNode = metricsModule.RegisterFloat64Gauge("varmor_profile_status_per_node", "Profile status per node (1=success, 0=failure)") } return &m diff --git a/internal/status/api/v1/status.go b/internal/status/api/v1/status.go index 0c873e6..3540be8 100644 --- a/internal/status/api/v1/status.go +++ b/internal/status/api/v1/status.go @@ -95,7 +95,7 @@ func (m *StatusManager) HandleProfileStatusUpdate(status varmortypes.ProfileStat // time.Sleep(time.Duration(m.metricsModule.Refresh) * time.Second) // logger := m.log.WithName("syncStatusMetricsLoop()") // logger.Info("start syncing status metrics") -// m.profileStatusPerNode = m.metricsModule.RegisterFloat64Gauge("profile_status_per_node", "Profile status per node (1=success, 0=failure)") +// m.profileStatusPerNode = m.metricsModule.RegisterFloat64Gauge("varmor_profile_status_per_node", "Profile status per node (1=success, 0=failure)") // for key, status := range m.PolicyStatuses { // namespace, name, err := PolicyStatusKeyGetInfo(key) // if err != nil { diff --git a/internal/webhooks/server.go b/internal/webhooks/server.go index 99d9ecd..77cf907 100644 --- a/internal/webhooks/server.go +++ b/internal/webhooks/server.go @@ -79,10 +79,10 @@ func NewWebhookServer( } if metricsModule.Enabled { - ws.admissionRequests = metricsModule.RegisterFloat64Counter("admission_requests_total", "Total number of admission requests") - ws.mutatedRequests = metricsModule.RegisterFloat64Counter("mutated_requests", "Number of requests that were mutated") - ws.nonMutatedRequests = metricsModule.RegisterFloat64Counter("non_mutated_requests", "Number of requests that were not mutated") - ws.webhookLatency = metricsModule.RegisterHistogram("webhook_latency", "Latency of webhook processing", 0.1, 0.5, 1, 2, 5) + ws.admissionRequests = metricsModule.RegisterFloat64Counter("varmor_admission_requests_total", "Total number of admission requests") + ws.mutatedRequests = metricsModule.RegisterFloat64Counter("varmor_mutated_requests", "Number of requests that were mutated") + ws.nonMutatedRequests = metricsModule.RegisterFloat64Counter("varmor_non_mutated_requests", "Number of requests that were not mutated") + ws.webhookLatency = metricsModule.RegisterHistogram("varmor_webhook_latency", "Latency of webhook processing", 0.1, 0.5, 1, 2, 5) } scheme := runtime.NewScheme()