ServiceMonitor可以给度量添加标签吗?



我需要给metric添加一些标签,这样grafana就可以根据它的值进行过滤。我想知道是否有一种方法可以在ServiceMonitor中做到这一点,这样我就不需要改变我的springboot项目中的代码。

我的最终解决方案是在ServiceMonitor的端点下添加一个metricRelabelings。

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
...
spec:
...
endpoints:
- ...
metricRelabelings:
- separator: ;
regex: (.*)
targetLabel: LABLE_NAME
replacement: VALUE
action: replace

最新更新