- Prometheus metrics go via pushgateway, as different worker processes might have different registries that are not picked up by Prometheus
This commit is contained in:
11
common/utils/prometheus_utils.py
Normal file
11
common/utils/prometheus_utils.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from flask import current_app
|
||||
from prometheus_client import push_to_gateway
|
||||
|
||||
|
||||
def sanitize_label(value):
|
||||
"""Convert value to valid Prometheus label by removing/replacing invalid chars"""
|
||||
if value is None:
|
||||
return ""
|
||||
# Replace spaces and special chars with underscores
|
||||
import re
|
||||
return re.sub(r'[^a-zA-Z0-9_]', '_', str(value))
|
||||
Reference in New Issue
Block a user