0

I have a requirement, where I have enabled NGINX metrics and I am trying to plot metrics with Prometheus. I am trying to plot metrics for NGINX EC2 server which has a tag named test=nginx or by running on specific port 9113. I am trying to use the below config, but after adding this config I am unable to see the targets in Prometheus

- job_name: "prometheus_nginx"
  ec2_sd_configs:
    - region: us-east-1
      access_key: XXXXXXXXXX
      secret_key: XXXXXXXXXX/
      port: 9113
  relabel_configs:
    - source_labels: [__meta_ec2_tag_test]
      regex: nginx
      action: keep
    - source_labels: []
      regex: .*
      action: drop

So can someone please help in what modifications are needed. NGINX is running on EC2 and Prometheus is running as a pod. Already enabled the traffic between NGINX and Prometheus pod and I am able to plot metrics.

But I am looking at more feasible option which should automatically get the dynamic targets based on the tag of the EC2 server

1 Answer 1

1

I have figured out the way and using the below code snippet, we should be able to filter the ec2 instances based on the tags

    additionalScrapeConfigs: |
  - job_name: "prometheus_nginx"
    ec2_sd_configs:
      - region: us-east-1
        access_key: XXXXXX
        secret_key: XXXXXX
        port: 9113
        filters:
          - name: tag:test
            values:
              - nginx

Thanks to chatgpt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.