mirror of
https://github.com/alexbers/mtprotoproxy.git
synced 2026-03-14 07:13:09 +00:00
Prefix for Prometheus metrics (#151)
Added default prefix for Prometheus metrics.
This commit is contained in:
committed by
Alexander Bersenev
parent
0a41479054
commit
c010543889
@@ -236,6 +236,9 @@ def init_config():
|
|||||||
# export proxy link to prometheus
|
# export proxy link to prometheus
|
||||||
conf_dict.setdefault("METRICS_EXPORT_LINKS", False)
|
conf_dict.setdefault("METRICS_EXPORT_LINKS", False)
|
||||||
|
|
||||||
|
# default prefix for metrics
|
||||||
|
conf_dict.setdefault("METRICS_PREFIX", "mtprotoproxy_")
|
||||||
|
|
||||||
# allow access to config by attributes
|
# allow access to config by attributes
|
||||||
config = type("config", (dict,), conf_dict)(conf_dict)
|
config = type("config", (dict,), conf_dict)(conf_dict)
|
||||||
|
|
||||||
@@ -1586,6 +1589,7 @@ def make_metrics_pkt(metrics):
|
|||||||
used_names = set()
|
used_names = set()
|
||||||
|
|
||||||
for name, m_type, desc, val in metrics:
|
for name, m_type, desc, val in metrics:
|
||||||
|
name = config.METRICS_PREFIX + name
|
||||||
if name not in used_names:
|
if name not in used_names:
|
||||||
pkt_body_list.append("# HELP %s %s" % (name, desc))
|
pkt_body_list.append("# HELP %s %s" % (name, desc))
|
||||||
pkt_body_list.append("# TYPE %s %s" % (name, m_type))
|
pkt_body_list.append("# TYPE %s %s" % (name, m_type))
|
||||||
|
|||||||
Reference in New Issue
Block a user