nerdswords / yet-another-cloudwatch-exporter

Prometheus exporter for AWS CloudWatch - Discovers services through AWS tags, gets CloudWatch metrics data and provides them as Prometheus metrics with AWS tags as labels
Apache License 2.0
981 stars 334 forks source link

[BUG] SearchTags filter takes empty tag values even though it does not match #793

Open harshajith opened 1 year ago

harshajith commented 1 year ago

Is there an existing issue for this?

Current Behavior

This is my search tag filter

    apiVersion: v1alpha1
    sts-region: ap-southeast-2
    discovery:
      exportedTagsOnMetrics:
        ec2:
          - Environment
      jobs:
      - type: ec2
        delay: 120
        searchTags:
          - key: Environment
            value: tbv
        regions:
          - ap-southeast-2
        metrics:
          - name: CPUUtilization
            statistics:
            - Average
            period: 60
            length: 300
            nilToZero: true

Below is some sample results I got as metrics

aws_ec2_cpuutilization_average{account_id="xxxxxx",dimension_AutoScalingGroupName="",dimension_ImageId="",dimension_InstanceId="",dimension_InstanceType="t3.2xlarge",name="global",region="ap-southeast-2",tag_Environment=""} 0.9044415834955238

aws_ec2_cpuutilization_average{account_id="xxxxxx",dimension_AutoScalingGroupName="",dimension_ImageId="",dimension_InstanceId="xxxx",dimension_InstanceType="",name="arn:aws:ec2:ap-southeast-2:xxxxx:instance/xxxxxx",region="ap-southeast-2",tag_Environment="tbv"} 0.9616666666666668

It included tag_Environment="" as well as tag_Environment="tbv" metrics.

Expected Behavior

I am expecting searchTags to filter the exact key/value pairs leaving unmatched empty values.

Steps To Reproduce

Version I am using is "v0.45.0-alpha"

Anything else?

No

Jks08 commented 1 year ago

Hi @harshajith, were you able to figure this out. I am also facing the same issue and I am not able to understand the cause for getting the name="global" metrics in my output. Any help is appreciated.

Amoolaa commented 8 months ago

+1, I'm also having the same issue

Amoolaa commented 8 months ago

Quick fix is to use the dimensionNameRequirements field to filter between the ASG and EC2 metrics,

      dimensionNameRequirements:
        - InstanceId # Prevents returning autoscaling group names