From 4f769f0ced20fa2ed287f05115c1949bdef82ace Mon Sep 17 00:00:00 2001 From: Tal Date: Tue, 24 Dec 2024 11:29:52 +0100 Subject: [PATCH] chore: prefix metrics (#2889) --- keep/api/core/metrics.py | 21 +++++++++++++++------ pyproject.toml | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/keep/api/core/metrics.py b/keep/api/core/metrics.py index 6147c5f88..39c5d6177 100644 --- a/keep/api/core/metrics.py +++ b/keep/api/core/metrics.py @@ -5,6 +5,7 @@ PROMETHEUS_MULTIPROC_DIR = os.environ.get("PROMETHEUS_MULTIPROC_DIR", "/tmp/prometheus") os.makedirs(PROMETHEUS_MULTIPROC_DIR, exist_ok=True) +METRIC_PREFIX = "keep_" # Create a single registry for all metrics registry = CollectorRegistry() @@ -12,21 +13,29 @@ # Process event metrics events_in_counter = Counter( - "events_in_total", "Total number of events received", registry=registry + f"{METRIC_PREFIX}events_in_total", + "Total number of events received", + registry=registry, ) events_out_counter = Counter( - "events_out_total", "Total number of events processed", registry=registry + f"{METRIC_PREFIX}events_processed_total", + "Total number of events processed", + registry=registry, ) events_error_counter = Counter( - "events_error_total", "Total number of events with error", registry=registry + f"{METRIC_PREFIX}events_error_total", + "Total number of events with error", + registry=registry, ) processing_time_summary = Summary( - "processing_time_seconds", "Average time spent processing events", registry=registry + f"{METRIC_PREFIX}processing_time_seconds", + "Average time spent processing events", + registry=registry, ) # Running tasks metrics running_tasks_gauge = Gauge( - "running_tasks_current", + f"{METRIC_PREFIX}running_tasks_current", "Current number of running tasks", registry=registry, multiprocess_mode="livesum", @@ -34,7 +43,7 @@ # Per-process running tasks metrics running_tasks_by_process_gauge = Gauge( - "running_tasks_by_process", + f"{METRIC_PREFIX}running_tasks_by_process", "Current number of running tasks per process", labelnames=["pid"], registry=registry, diff --git a/pyproject.toml b/pyproject.toml index 2dc0ef9d3..3ce53a09f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "keep" -version = "0.32.6" +version = "0.32.7" description = "Alerting. for developers, by developers." authors = ["Keep Alerting LTD"] packages = [{include = "keep"}]