From 67be2b5e9971ea3e4afef1525e00cedb55e4fbc5 Mon Sep 17 00:00:00 2001 From: Gabriel Dos Santos <91925154+gabedos@users.noreply.github.com> Date: Fri, 18 Oct 2024 13:18:55 -0400 Subject: [PATCH] [CONTP-382] Add Validation Webhook telemetry metrics (#18867) * Add Validation Webhook telemetry * Updating webhooks_receieved description --- datadog_cluster_agent/changelog.d/18867.added | 1 + .../datadog_checks/datadog_cluster_agent/check.py | 1 + datadog_cluster_agent/metadata.csv | 3 ++- datadog_cluster_agent/tests/fixtures/metrics.txt | 5 ++++- datadog_cluster_agent/tests/test_datadog_cluster_agent.py | 1 + 5 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 datadog_cluster_agent/changelog.d/18867.added diff --git a/datadog_cluster_agent/changelog.d/18867.added b/datadog_cluster_agent/changelog.d/18867.added new file mode 100644 index 0000000000000..8374264cecc15 --- /dev/null +++ b/datadog_cluster_agent/changelog.d/18867.added @@ -0,0 +1 @@ +Add telemetry scraping for Validation AdmissionController diff --git a/datadog_cluster_agent/datadog_checks/datadog_cluster_agent/check.py b/datadog_cluster_agent/datadog_checks/datadog_cluster_agent/check.py index 1a1ece2ed9d95..e88ac2f4acdf6 100644 --- a/datadog_cluster_agent/datadog_checks/datadog_cluster_agent/check.py +++ b/datadog_cluster_agent/datadog_checks/datadog_cluster_agent/check.py @@ -11,6 +11,7 @@ 'admission_webhooks_library_injection_attempts': 'admission_webhooks.library_injection_attempts', 'admission_webhooks_library_injection_errors': 'admission_webhooks.library_injection_errors', 'admission_webhooks_mutation_attempts': 'admission_webhooks.mutation_attempts', + 'admission_webhooks_validation_attempts': 'admission_webhooks.validation_attempts', 'admission_webhooks_patcher_attempts': 'admission_webhooks.patcher.attempts', 'admission_webhooks_patcher_completed': 'admission_webhooks.patcher.completed', 'admission_webhooks_patcher_errors': 'admission_webhooks.patcher.errors', diff --git a/datadog_cluster_agent/metadata.csv b/datadog_cluster_agent/metadata.csv index 979d12072772d..00b14ceb90bf7 100644 --- a/datadog_cluster_agent/metadata.csv +++ b/datadog_cluster_agent/metadata.csv @@ -17,7 +17,8 @@ datadog.cluster_agent.admission_webhooks.reconcile_errors,gauge,,,,Number of rec datadog.cluster_agent.admission_webhooks.reconcile_success,gauge,,success,,Number of reconcile successes per controller,0,datadog_cluster_agent,admission webhooks reconcile success, datadog.cluster_agent.admission_webhooks.response_duration.count,count,,,,Webhook response duration count,0,datadog_cluster_agent,webhook response duration count, datadog.cluster_agent.admission_webhooks.response_duration.sum,count,,second,,Webhook response duration sum,0,datadog_cluster_agent,webhook response duration sum, -datadog.cluster_agent.admission_webhooks.webhooks_received,gauge,,,,Number of mutation webhook requests received,0,datadog_cluster_agent,admission webhooks received, +datadog.cluster_agent.admission_webhooks.validation_attempts,gauge,,,,Number of pod validation attempts by validation type,0,datadog_cluster_agent,admission webhooks validation attempts, +datadog.cluster_agent.admission_webhooks.webhooks_received,gauge,,,,Number of webhook requests received,0,datadog_cluster_agent,admission webhooks received, datadog.cluster_agent.aggregator.flush,count,,,,"Number of metrics/service checks/events flushed by (data_type, state)",0,datadog_cluster_agent,aggregator flush, datadog.cluster_agent.aggregator.processed,count,,,,Amount of metrics/services_checks/events processed by the aggregator by data_type,0,datadog_cluster_agent,aggregator processed, datadog.cluster_agent.api_requests,count,,request,,"Requests made to the cluster agent API by (handler, status)",0,datadog_cluster_agent,api requests, diff --git a/datadog_cluster_agent/tests/fixtures/metrics.txt b/datadog_cluster_agent/tests/fixtures/metrics.txt index dc1ee15bee468..018ba1b59fbf8 100644 --- a/datadog_cluster_agent/tests/fixtures/metrics.txt +++ b/datadog_cluster_agent/tests/fixtures/metrics.txt @@ -11,6 +11,9 @@ admission_webhooks_mutation_attempts{error="",injected="true",mutation_type="age admission_webhooks_mutation_attempts{error="",injected="true",mutation_type="agent_sidecar",status="success"} 1 admission_webhooks_mutation_attempts{error="",injected="true",mutation_type="cws_pod_instrumentation",status="success"} 2 admission_webhooks_mutation_attempts{error="",injected="true",mutation_type="lib_injection",status="success"} 1 +# HELP admission_webhooks_validation_attempts Number of pod validation attempts by validation type +# TYPE admission_webhooks_validation_attempts gauge +admission_webhooks_validation_attempts{error="",validated="true",webhook_name="kubernetes_audit",status="success"} 1 # HELP admission_webhooks_reconcile_errors Number of reconcile errors per controller. # TYPE admission_webhooks_reconcile_errors gauge admission_webhooks_reconcile_errors{controller="secrets"} 5 @@ -34,7 +37,7 @@ admission_webhooks_response_duration_bucket{le="10"} 108 admission_webhooks_response_duration_bucket{le="+Inf"} 108 admission_webhooks_response_duration_sum 0.4897835529999999 admission_webhooks_response_duration_count 108 -# HELP admission_webhooks_webhooks_received Number of mutation webhook requests received. +# HELP admission_webhooks_webhooks_received Number of webhook requests received. # TYPE admission_webhooks_webhooks_received gauge admission_webhooks_webhooks_received 300 # HELP aggregator__dogstatsd_contexts Count the number of dogstatsd contexts in the aggregator diff --git a/datadog_cluster_agent/tests/test_datadog_cluster_agent.py b/datadog_cluster_agent/tests/test_datadog_cluster_agent.py index 0bae2b520a5f9..d8c915e4ab465 100644 --- a/datadog_cluster_agent/tests/test_datadog_cluster_agent.py +++ b/datadog_cluster_agent/tests/test_datadog_cluster_agent.py @@ -21,6 +21,7 @@ 'admission_webhooks.library_injection_attempts', 'admission_webhooks.library_injection_errors', 'admission_webhooks.mutation_attempts', + 'admission_webhooks.validation_attempts', 'admission_webhooks.patcher.attempts', 'admission_webhooks.patcher.completed', 'admission_webhooks.patcher.errors',