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

fix: Fix parsing for dimension names from CloudWatch tag identifier values #33040

Closed
wants to merge 3 commits into from

Conversation

cjr125
Copy link
Contributor

@cjr125 cjr125 commented Sep 9, 2022

  • Bug fix

What does this PR do?

Fix parsing for dimension names from CloudWatch tag identifier values

Why is it important?

This change is necessary for filtering CloudWatch metric tags with dimensions attached to identifier values

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Author's Checklist

  • Approach to remove dimension names from identifier values is correct

@cjr125 cjr125 requested a review from a team as a code owner September 9, 2022 16:01
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Sep 9, 2022
@mergify mergify bot assigned cjr125 Sep 9, 2022
@mergify
Copy link
Contributor

mergify bot commented Sep 9, 2022

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @cjr125? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v8./d.0 is the label to automatically backport to the 8./d branch. /d is the digit

@cjr125 cjr125 force-pushed the review/addCloudFront branch 2 times, most recently from f6bca84 to dbb8ce4 Compare September 9, 2022 16:07
@elasticmachine
Copy link
Collaborator

elasticmachine commented Sep 9, 2022

❕ Build Aborted

The PR is not allowed to run in the CI yet

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Start Time: 2022-10-11T22:16:46.801+0000

  • Duration: 5 min 36 sec

Steps errors 2

Expand to view the steps failures

Load a resource file from a library
  • Took 0 min 0 sec . View more details here
  • Description: approval-list/elastic/beats.yml
Error signal
  • Took 0 min 0 sec . View more details here
  • Description: githubApiCall: The REST API call https://api.github.com/orgs/elastic/members/cjr125 return the message : java.lang.Exception: httpRequest: Failure connecting to the service https://api.github.com/orgs/elastic/members/cjr125 : httpRequest: Failure connecting to the service https://api.github.com/orgs/elastic/members/cjr125 : Code: 404Error: {"message":"User does not exist or is not a member of the organization","documentation_url":"https://docs.github.com/rest/reference/orgs#check-organization-membership-for-a-user"}

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@cjr125 cjr125 force-pushed the review/addCloudFront branch 5 times, most recently from 8960f81 to 2c546ef Compare September 13, 2022 11:56
@endorama endorama added the Team:Cloud-Monitoring Label for the Cloud Monitoring team label Sep 19, 2022
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Sep 19, 2022
@mergify
Copy link
Contributor

mergify bot commented Sep 20, 2022

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b review/addCloudFront upstream/review/addCloudFront
git merge upstream/main
git push upstream review/addCloudFront

@aspacca
Copy link

aspacca commented Sep 21, 2022

@cjr125 there's no need to add a new metricset to metrcibeat

you can collect the metrics you need just adding the following to your modules.d/aws.yml:

- module: aws
  period: 5m
  metricsets:
    - cloudwatch
  metrics:
      - namespace: AWS/CloudFront
        resource_type: cloudfront
        statistic: ["Average"]
        name:
          - 4xxErrorRate
          - 401ErrorRate
          - 403ErrorRate
          - 404ErrorRate
          - 5xxErrorRate
          - 502ErrorRate
          - 503ErrorRate
          - 504ErrorRate
          - CacheHitRate
          - TotalErrorRate
          - ExecutionTime
      - namespace: AWS/CloudFront
        resource_type: cloudfront
        statistic: ["Sum"]
        name:
          - BytesDownloaded
          - BytesUploaded
          - Requests
          - Invocations
          - ValidationErrors
          - ExecutionErrors
          - FunctionThrottles
      - namespace: AWS/CloudFront
        resource_type: cloudfront
        statistic: ["p95"] # or others relevant pNN
        name:
          - OriginLatency

@cla-checker-service
Copy link

cla-checker-service bot commented Oct 6, 2022

💚 CLA has been signed

@cjr125 cjr125 changed the title feat: Add AWS CloudFront Module to Metricbeat fix: Fix parsing for dimension names from CloudWatch tag identifier values Oct 6, 2022
@cjr125
Copy link
Contributor Author

cjr125 commented Oct 6, 2022

@cjr125 there's no need to add a new metricset to metrcibeat

you can collect the metrics you need just adding the following to your modules.d/aws.yml:

- module: aws
  period: 5m
  metricsets:
    - cloudwatch
  metrics:
      - namespace: AWS/CloudFront
        resource_type: cloudfront
        statistic: ["Average"]
        name:
          - 4xxErrorRate
          - 401ErrorRate
          - 403ErrorRate
          - 404ErrorRate
          - 5xxErrorRate
          - 502ErrorRate
          - 503ErrorRate
          - 504ErrorRate
          - CacheHitRate
          - TotalErrorRate
          - ExecutionTime
      - namespace: AWS/CloudFront
        resource_type: cloudfront
        statistic: ["Sum"]
        name:
          - BytesDownloaded
          - BytesUploaded
          - Requests
          - Invocations
          - ValidationErrors
          - ExecutionErrors
          - FunctionThrottles
      - namespace: AWS/CloudFront
        resource_type: cloudfront
        statistic: ["p95"] # or others relevant pNN
        name:
          - OriginLatency

@aspacca I do actually need part of this code to fix a problem with using tags_filter on CloudFront metrics in CloudWatch. The identifier values include dimension names which break the standard tag filtering logic. please see the updates (I left the commit history)

@aspacca
Copy link

aspacca commented Oct 11, 2022

The identifier values include dimension names which break the standard tag filtering logic. please see the updates (I left the commit history)

can you explain your use case with an example?
From what I see it looks like a breaking change, and if so we cannot merge without proper protocol

@mergify
Copy link
Contributor

mergify bot commented Oct 11, 2022

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b review/addCloudFront upstream/review/addCloudFront
git merge upstream/main
git push upstream review/addCloudFront

@cjr125
Copy link
Contributor Author

cjr125 commented Oct 11, 2022

The identifier values include dimension names which break the standard tag filtering logic. please see the updates (I left the commit history)

can you explain your use case with an example? From what I see it looks like a breaking change, and if so we cannot merge without proper protocol

When loading metrics using the following config, I am able to print the following:

  aws.yml: |-
    - module: aws
      period: 1m
      metricsets:
        - cloudwatch
      metrics:
        - namespace: AWS/CloudFront
          resource_type: cloudfront
          statistic: ["Average"]
          name:
            - 4xxErrorRate
            - 401ErrorRate
            - 403ErrorRate
            - 404ErrorRate
            - 5xxErrorRate
            - 502ErrorRate
            - 503ErrorRate
            - 504ErrorRate
            - CacheHitRate
            - TotalErrorRate
            - ExecutionTime
        - namespace: AWS/CloudFront
          resource_type: cloudfront
          statistic: ["Sum"]
          name:
            - BytesDownloaded
            - BytesUploaded
            - Requests
            - Invocations
            - ValidationErrors
            - ExecutionErrors
            - FunctionThrottles
        - namespace: AWS/CloudFront
          resource_type: cloudfront
          statistic: ["p95"] # or others relevant pNN
          name:
            - OriginLatency
      tags_filter:
        - key: "amwell:environment-name"
          value: "dev-next"
// remove dimension names from identifier value if applicable
if strings.Contains(identifierValue, dimensionSeparator) {
	fmt.Println("identifierValue:", identifierValue)
	identifierSeparators := strings.Split(identifierValue, dimensionSeparator)
	identifierValue = identifierSeparators[len(identifierSeparators)-1]
}

identifierValue: Global,E5TGO8HHLKEA8

@aspacca
Copy link

aspacca commented Oct 12, 2022

identifierValue: Global,E5TGO8HHLKEA8

you should use this full value in the tags_filter

with the other PR you've created you can add multiple values for the same tag filter

@cjr125
Copy link
Contributor Author

cjr125 commented Oct 12, 2022

identifierValue: Global,E5TGO8HHLKEA8

you should use this full value in the tags_filter

with the other PR you've created you can add multiple values for the same tag filter

I'm not sure I follow what you are suggesting. These identifier values are what come back when I try to apply the filter for a specific application environment which we need to monitor. I need the filter to select all CloudFront distributions tagged with this environment name. For other namespaces, the identifier values do not contain dimension names (Global in this case) and the filtering works properly. In the case of the CloudFront namespace, however, the dimension name must be trimmed off in order to capture the desired identifier value. Is there some other way this problem can be approached?

@mergify
Copy link
Contributor

mergify bot commented Oct 25, 2022

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b review/addCloudFront upstream/review/addCloudFront
git merge upstream/main
git push upstream review/addCloudFront

@kaiyan-sheng
Copy link
Contributor

@cjr125 Im trying to fix this issue in #33472, please feel free to test/review it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Cloud-Monitoring Label for the Cloud Monitoring team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants