百度推广必须做手机网站吗,ae模板免费下载网站有哪些,上海高端室内设计,洛阳设计网站公司一 问题现象
一个job有多个实例推送指标#xff0c;但是从pushgateway上看这个job的instance字段#xff0c;只显示一个实例的ip#xff0c;而不是多个实例。导致在grafana上无法正常根据ip查看监控。 应用的prometheus的配置
management:metrics:tags:application: ${spr…一 问题现象
一个job有多个实例推送指标但是从pushgateway上看这个job的instance字段只显示一个实例的ip而不是多个实例。导致在grafana上无法正常根据ip查看监控。 应用的prometheus的配置
management:metrics:tags:application: ${spring.application.name}export:prometheus:pushgateway:#pushgateway地址baseUrl: ***:9091#推送周期pushRate: 15s#job定义名job: ${spring.application.name}#启用推送enabled: true## actuator暴露出prometheusendpoints:web:exposure:include: prometheusendpoint:health:show-details: always二 解决办法
增加grouping-key避免多个不同的实例的指标被聚合。HOSTNAME这个环境变量是k8s自带的并且每个实例都不一样。当时想找一个能标识pod ip的环境变量用env命令搜了一下并没有。
management:metrics:tags:application: ${spring.application.name}export:prometheus:pushgateway:#pushgateway地址baseUrl: ***:9091#推送周期pushRate: 15s#job定义名job: ${spring.application.name}#启用推送enabled: truegrouping-key:hostname: ${HOSTNAME}## actuator暴露出prometheusendpoints:web:exposure:include: prometheus,healthendpoint:health:show-details: always三 groupingkey作用分析
pushgateway指标上报的源码路径io.prometheus.client.exporter.PushGateway#doRequest
没配置groupingkey 配置了groupingkey 由于是本机debugHostName这个环境变量取不到k8s上正常取值。
grouping-key 官方解释 https://github.com/prometheus/pushgateway The default port the Pushgateway is listening to is 9091. The path looks like /metrics/job/JOB_NAME{/LABEL_NAME/LABEL_VALUE} JOB_NAME is used as the value of the job label, followed by any number of other label pairs (which might or might not include an instance label). The label set defined by the URL path is used as a grouping key. Any of those labels already set in the body of the request (as regular labels, e.g. name{job“foo”} 42) will be overwritten to match the labels defined by the URL path! pushgateway是用请求pushgateway的url的path作为grouping-key的。如果不配置任何grouping-keypushgateway会把所有job字段一样的指标聚合到一起。