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]Combine metrics with no dimension into one event #17345

Merged
merged 4 commits into from
Apr 1, 2020
Merged

[Metricbeat]Combine metrics with no dimension into one event #17345

merged 4 commits into from
Apr 1, 2020

Conversation

kaiyan-sheng
Copy link
Contributor

@kaiyan-sheng kaiyan-sheng commented Mar 30, 2020

What does this PR do?

When collecting CloudWatch metrics with no dimension, they should be reported in the same metric/event instead of separate metrics/events. For example, lambda namespace reports metrics across all functions: ConcurrentExecutions, Duration, Errors, Invocations, Throttles. For metrics across all functions, they represent aggregate metrics for all functions in the current AWS Region. Instead of separating these metrics into individual events, cloudwatch metricset should report them as one metric.

Why is it important?

Combining metrics with no dimension into one event will easily show users all the aggregated metrics from CloudWatch in one event.

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.

How to test this PR locally

  1. make sure there is at least one lambda function and also check cloudwatch to see if there are metrics for that lambda function.
  2. enable aws module by ./metricbeat modules enable aws
  3. change aws.yml under modules.d to:
- module: aws
  period: 30s
  credential_profile_name: elastic-beats
  metricsets:
    - lambda
  1. You should see events in Kibana with/without dimensions. There should be only one event without dimension which includes all CloudWatch aggregated metrics. For example:
{
  "_index": "metricbeat-8.0.0-2020.03.09-000001",
  "_type": "_doc",
  "_id": "YMxZLXEBCsIwLMtCN8hn",
  "_version": 1,
  "_score": null,
  "_source": {
    "@timestamp": "2020-03-30T21:29:02.851Z",
    "ecs": {
      "version": "1.5.0"
    },
    "host": {
      "os": {
        "family": "darwin",
        "name": "Mac OS X",
        "kernel": "17.7.0",
        "build": "17G10021",
        "platform": "darwin",
        "version": "10.13.6"
      },
    "cloud": {
      "provider": "aws",
      "region": "us-west-1",
      "account": {
        "name": "elastic-beats",
        "id": "428152502467"
      }
    },
    "aws": {
      "lambda": {
        "metrics": {
          "Throttles": {
            "avg": 0
          },
          "Duration": {
            "avg": 3003.1659999999997
          },
          "Errors": {
            "avg": 1
          },
          "ConcurrentExecutions": {
            "avg": 1
          },
          "Invocations": {
            "avg": 1
          }
        }
      },
      "cloudwatch": {
        "namespace": "AWS/Lambda"
      }
    },
    "event": {
      "duration": 9918983165,
      "dataset": "aws.lambda",
      "module": "aws"
    },
    "metricset": {
      "name": "lambda",
      "period": 300000
    },
    "service": {
      "type": "aws"
    }
  },
  "fields": {
    "@timestamp": [
      "2020-03-30T21:29:02.851Z"
    ]
  },
  "sort": [
    1585603742851
  ]
}

@kaiyan-sheng kaiyan-sheng self-assigned this Mar 30, 2020
@kaiyan-sheng kaiyan-sheng added bug needs_backport PR is waiting to be backported to other branches. Team:Platforms Label for the Integrations - Platforms team labels Mar 30, 2020
@elasticmachine
Copy link
Collaborator

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

Copy link
Member

@ChrsMark ChrsMark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! Wondering if we could have a unit test to ensure this functionality.

@kaiyan-sheng
Copy link
Contributor Author

@ChrsMark Totally agree on adding more unit test. I just added two tests for CreateEvents function. Thank you!

@kaiyan-sheng kaiyan-sheng merged commit d853f27 into elastic:master Apr 1, 2020
@kaiyan-sheng kaiyan-sheng deleted the lambda_bug branch April 1, 2020 13:12
@kaiyan-sheng kaiyan-sheng added v7.8.0 and removed needs_backport PR is waiting to be backported to other branches. labels Apr 1, 2020
kaiyan-sheng added a commit that referenced this pull request Apr 2, 2020
…#17403)

* Combine metrics with no dimension
* Add unit tests for CreateEvents function w/o dimensions

(cherry picked from commit d853f27)
kaiyan-sheng added a commit that referenced this pull request Apr 2, 2020
…#17398)

* Combine metrics with no dimension
* Add unit tests for CreateEvents function w/o dimensions

(cherry picked from commit d853f27)
leweafan pushed a commit to leweafan/beats that referenced this pull request Apr 28, 2023
…#17345) (elastic#17403)

* Combine metrics with no dimension
* Add unit tests for CreateEvents function w/o dimensions

(cherry picked from commit 1866bfc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Team:Platforms Label for the Integrations - Platforms team v7.7.0 v7.8.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants