Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MetricBeat] [AWS] events can't set TargetGroup tags #20326

Closed
kwinstonix opened this issue Jul 29, 2020 · 4 comments · Fixed by #20385
Closed

[MetricBeat] [AWS] events can't set TargetGroup tags #20326

kwinstonix opened this issue Jul 29, 2020 · 4 comments · Fixed by #20385
Assignees
Labels
enhancement Team:Platforms Label for the Integrations - Platforms team

Comments

@kwinstonix
Copy link
Contributor

For confirmed bugs, please report:

  • Version: 7.8.1

  • Steps to Reproduce:

    • set aws ALB/NLB targetgroup tags
    • run metricbeat with this example config
metricbeat.modules:
  - module: aws
    aws_partition: aws
    period: 300s
    access_key_id:  'your aws key'
    secret_access_key: 'your aws key'
    metricsets:
      - cloudwatch
    metrics:
      - namespace: AWS/ApplicationELB
        statistic: ['Minimum']
        name: ['HealthyHostCount']
        tags.resource_type_filter: elasticloadbalancing
  • current result:

events only contain Loadbalancer tags

  • expected result:

events contain both LoadBalancer and TargetGroup tags


aws alb and nlb metrics structure

// CLI output : aws resourcegroupstaggingapi get-resources --resource-type-filters elasticloadbalancing
        {
            "Namespace": "AWS/ApplicationELB",
            "MetricName": "UnHealthyHostCount",
            "Dimensions": [
                {
                    "Name": "TargetGroup",
                    "Value": "targetgroup/tg-name/12345678abc"
                },
                {
                    "Name": "LoadBalancer",
                    "Value": "app/lb-name/12345678abc"
                }
            ]
        },

        {
            "Namespace": "AWS/NetworkELB",
            "MetricName": "HealthyHostCount",
            "Dimensions": [
                {
                    "Name": "TargetGroup",
                    "Value": "targetgroup/tg-name/012345678abcdef"
                },
                {
                    "Name": "LoadBalancer",
                    "Value": "net/lb-name/012345678abcdef"
                }
            ]
        },
  • aws resourcetagginggroup result examle


{
    "ResourceARN": "arn:aws:elasticloadbalancing:ap-northeast-2:123456789012:loadbalancer/app/alb-name/12345678abc",
        "Tags": [
        {
            "Key": "K1",
            "Value": "V1"
        },
}
{
    "ResourceARN": "arn:aws:elasticloadbalancing:ap-northeast-2:123456789012:loadbalancer/net/nlb-name/2233445566",
        "Tags": [
        {
            "Key": "K2",
            "Value": "V2"
        },
}

{
    "ResourceARN": "arn:aws:elasticloadbalancing:ap-northeast-2:123456789012:targetgroup/tg-name/012345678abcdef"
        "Tags": [
        {
            "Key": "K3",
            "Value": "V3"
        },
}

comparing above two example results, we can figure out that ALB and NLB LoadBalancer dimension value is not same with resource id field of ARN, and TargetGroup dimension value is same with resource id field of ARN.

  • the reason

GetResourcesTags func has proccessed the resourcegroupstaggingapi result, the resourceTagMap is like this, so we can not get TargetGroup tags in insertTags function .

{
   "tg-name/012345678abcdef":   {
            "Key": "K3",
            "Value": "V3"
        },
  "net/nlb-name/2233445566" :  {
            "Key": "K2",
            "Value": "V2"
   }
}

for _, resourceTag := range output.ResourceTagMappingList {
identifier, err := FindIdentifierFromARN(*resourceTag.ResourceARN)
if err != nil {
err = errors.Wrap(err, "error FindIdentifierFromARN")
return nil, err
}
resourceTagMap[identifier] = resourceTag.Tags
}

  • suggestion

I think we should use both short resource identifier and whole resource identifier of ARN, just like this

{
   "tg-name/012345678abcdef":   {
            "Key": "K3",
            "Value": "V3"
        },
  "net/nlb-name/2233445566" :  {
            "Key": "K2",
            "Value": "V2"
   },

   "targetgroup/tg-name/012345678abcdef":   {
            "Key": "K3",
            "Value": "V3"
        },
  "loadbalancer/net/nlb-name/2233445566" :  {
            "Key": "K2",
            "Value": "V2"
   }
}
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jul 29, 2020
@kaiyan-sheng kaiyan-sheng self-assigned this Jul 29, 2020
@kaiyan-sheng kaiyan-sheng added [zube]: Investigate Team:Platforms Label for the Integrations - Platforms team labels Jul 29, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations-platforms (Team:Platforms)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jul 29, 2020
@kaiyan-sheng
Copy link
Contributor

@kwinstonix Thanks for creating this issue. Good point, it would be good to add collection for TargetGroup tags. I won't be able to start working on this for a while because of other priorities on my list 😬 Please feel free to take over!

@kwinstonix
Copy link
Contributor Author

OK, I will open a PR

@kaiyan-sheng
Copy link
Contributor

@kwinstonix Awesome!! Thank you!! Just ping me for the PR and I will test it 😄

kwinstonix added a commit to kwinstonix/beats that referenced this issue Aug 18, 2020
kaiyan-sheng pushed a commit that referenced this issue Aug 18, 2020
…le resource id (#20385)

* resource tags map should be compatible with short or whole resource identifier (#20326)
kaiyan-sheng added a commit that referenced this issue Aug 19, 2020
…le resource id (#20385) (#20668)

* resource tags map should be compatible with short or whole resource identifier (#20326)

(cherry picked from commit 3ef1811)

Co-authored-by: martin <kwinstonix@users.noreply.github.com>
kaiyan-sheng added a commit that referenced this issue Aug 19, 2020
…le resource id (#20385) (#20670)

* resource tags map should be compatible with short or whole resource identifier (#20326)

(cherry picked from commit 3ef1811)

Co-authored-by: martin <kwinstonix@users.noreply.github.com>
melchiormoulin pushed a commit to melchiormoulin/beats that referenced this issue Oct 14, 2020
…le resource id (elastic#20385)

* resource tags map should be compatible with short or whole resource identifier (elastic#20326)
leweafan pushed a commit to leweafan/beats that referenced this issue Apr 28, 2023
…le resource id (elastic#20385) (elastic#20670)

* resource tags map should be compatible with short or whole resource identifier (elastic#20326)

(cherry picked from commit 4e8f09d)

Co-authored-by: martin <kwinstonix@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Team:Platforms Label for the Integrations - Platforms team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants