首页 > 解决方案 > 在 Prometheus 监控中,我正在尝试使用 AWS 标签过滤 extraScrapeConfigs

问题描述

在我的普罗米修斯服务器中,我只想从我的 EC2 实例中获取数据,这些实例的标签名为“应用程序”,值为“gitlab-runner-servers”。

以下是我尝试过的方法,但它不起作用 - Prometheus 显示了 us-west-2 区域中的每个 ec2 实例。

extraScrapeConfigs: |
  - job_name: ‘gitlab-ec2-runners’
    ec2_sd_configs:
    - region: us-west-2
      port: 9252
      filters:
        - name: 'tag:application'
          values: 'gitlab-runner-servers'

我遵循以下参考 - https://prometheus.io/docs/prometheus/latest/configuration/configuration/#ec2_sd_config

来自 - https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html

tag:<key>
 - The key/value combination of a tag assigned to the resource. Use the tag key in the filter name and the tag value as the filter value. For example, to find all resources that have a tag with the key Owner
 and the value TeamA
, specify tag:Owner
 for the filter name and TeamA
 for the filter value.

关于我需要使用什么来正确过滤的任何建议?

标签: amazon-web-servicesprometheusgrafana

解决方案


推荐阅读