Skip to content

Commit

Permalink
Add varmor prefix for all metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Danny-Wei committed Nov 14, 2024
1 parent e32474e commit 1bee784
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
34 changes: 17 additions & 17 deletions grafana/panel.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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",
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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"
}
Expand Down Expand Up @@ -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"
}
Expand Down Expand Up @@ -623,7 +623,7 @@
"targets": [
{
"editorMode": "code",
"expr": "profile_status_per_node",
"expr": "varmor_profile_status_per_node",
"format": "table",
"instant": true,
"refId": "A"
Expand Down Expand Up @@ -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"
}
Expand Down Expand Up @@ -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"
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions internal/status/api/v1/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/status/api/v1/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions internal/webhooks/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 1bee784

Please sign in to comment.