chen-gliu / nacos-consul-adapter

This project contains a Spring Boot Starter that registers HTTP endpoints on a Spring Cloud Nacos server to support Prometheus's service discovery mechanism for Consul (<consul_sd_config>)
MIT License
87 stars 36 forks source link

不支持Prometheus自定义打标签 #13

Closed BBdong closed 1 year ago

BBdong commented 1 year ago

拉取微服务的lebles下的instance标签默认是内网ip+端口(见图),后续alertmanager 告警通知只能获取当前服务的instance标签和job标签,获取不到当前告警服务的名称 image

chen-gliu commented 1 year ago

内网的ip是因为你使用nacos注册是内网ip,这个可以设置

chen-gliu commented 1 year ago

第二个告警不是服务的名称,这个应该和你的配置有关系

BBdong commented 1 year ago

其实就是想要这个效果(见图) , 目前这个项目拉取的服务注册到Prometheus默认labels下只有job和instance(默认是ip+端口)
如果是给注册的微服务动态打自定义标签目前还不支持 如图中的registerProjectName标签。 后续在告警时 可以使用诸如registerProjectName自定义标签去做一些事情 image

BBdong commented 1 year ago

我的做法是在Service类增加 Map<String, String> meta , 然后把自定义标签放到meta 中 , 然后再prometheus.yml中增加配置 relabel_configs

BBdong commented 1 year ago

如果可以我提交pull request, 加一些代码然后在READ.ME增加配置说明

chen-gliu commented 1 year ago

可以,欢迎

chen-gliu commented 1 year ago

我合并了,等有时间我更新一下版本

xiohuchi commented 11 months ago

这个不错