ZBLOG

在原有 Prometheus 的配置文件中,修改 scrape_configs 部分中的 targets 参数为 prom-aggregation-gateway 的地址。请根据上面的例子给出配置demo

假设 prom-aggregation-gateway 的地址为 192.168.1.100:8080,那么在 Prometheus 的配置文件中,需要将原有的 scrape_configs 部分中的 targets 参数修改为该地址。示例配置如下:

  1. global:
  2. scrape_interval: 15s
  3. evaluation_interval: 15s
  4. scrape_configs:
  5. - job_name: 'node'
  6. static_configs:
  7. - targets: ['localhost:9100']
  8. - job_name: 'prometheus'
  9. static_configs:
  10. - targets: ['localhost:9090']
  11. - job_name: 'aggregated-metrics'
  12. metrics_path: '/metrics/aggregated'
  13. scrape_interval: 30s
  14. scrape_timeout: 10s
  15. scheme: http
  16. honor_labels: true
  17. params:
  18. match[]:
  19. - '{job=~".+"}'
  20. - '{__name__=~"job:.+"}'
  21. aggregate[]:
  22. - 'job'
  23. - '__name__'
  24. - 'instance'
  25. - 'environment'
  26. - 'region'
  27. - 'zone'
  28. # 修改 targets 参数为 prom-aggregation-gateway 的地址
  29. # 注意:此处需要使用 prom-aggregation-gateway 中定义的 target labels,比如这里是使用了 environment=prod 这个 label。
  30. relabel_configs:
  31. - source_labels : [__meta_consul_service_port]
  32. regex : ".*"
  33. action : replace
  34. target_label : __address__
  35. - source_labels : [__meta_consul_service_address, __meta_consul_service_tags]
  36. regex : "(.*);environment=prod(,.*)?"
  37. replacement : "${1}"
  38. action : replace
  39. target_label : instance

在上面的配置中,我们将 scrape_configs 部分新增了一个名为 aggregated-metrics 的 job,它会通过 HTTP 协议从 prom-aggregation-gateway 上获取聚合后的指标数据,并且使用 relabel_configs 来对获取的 target 进行处理以满足需要。

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:https://golang.0voice.com/?id=5927

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?