我在prometheus有个反指标。我想动态地向它添加标签,例如,如果我的请求是http://abc123.com/{p1},我想要custom_metric_name能够存储:{statuscode=200, p1=p1Value , host="abc123"};如果请求是http://def123.com/{p2},则想要custom_metric_name 能够存储{statuscode=200, p2=p2Value , host="def123"},且custom_metric_name能够由双方共享度量。我还在努力找答案。
You can use relabel_config or metric_relabel_config in your Prometheus config.
It would look like the following:
- source_labels: [request_origin]
regex: 'http://(\w+)/.*'
replacement: '${1}'
target_label: host
See also this article showing usage of relabelling.