将自定义属性添加到 Prometheus 指标中,例如地理位置

Adding Custom Attribute into Prometheus Metric such as Geolocation

我有很多实例位于两个不同的城市(伊斯坦布尔和安卡拉) 我想将城市位置属性自动添加到来自这些实例的所有指标中 通过在普罗米修斯配置中指示主机。我已经发布了一个普罗米修斯配置示例。 有没有办法添加这样的自定义属性?

--实际--

- job_name: 'my-app'
    scrape_interval: 60s
    metrics_path: /actuator/prometheus
    static_configs:
      - targets:
                 - 172.18.11.33:8081
                 - 172.18.11.34:8080

--我的期望添加了地理定位指示器--

job_name: 'my-app'
scrape_interval: 60s
metrics_path: /actuator/prometheus
static_configs:
- targets:
- 172.18.11.33:8081;geo='istanbul’
- 172.18.11.34:8080;"geo='ankara'

类似于Prometheus - add target specific label in static_configs

您可以定义多个目标:

static_configs:
  - targets: ['172.18.11.33:8081']
    labels:  {geo: 'istanbul'}
  - targets: ['172.18.11.34:8080']
    labels:  {geo: 'ankara'}