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

Add SQS metricset into AWS metricbeat module #10684

Merged
merged 10 commits into from
Feb 25, 2019
Merged

Add SQS metricset into AWS metricbeat module #10684

merged 10 commits into from
Feb 25, 2019

Conversation

kaiyan-sheng
Copy link
Contributor

@kaiyan-sheng kaiyan-sheng commented Feb 11, 2019

This PR is to add SQS metricset into AWS metricbeat module. CloudWatch metrics for Amazon SQS queues are automatically collected and pushed to CloudWatch every five minutes. So sqs metricset can share the same config as ec2.

@kaiyan-sheng kaiyan-sheng requested a review from a team as a code owner February 11, 2019 21:16
@kaiyan-sheng kaiyan-sheng changed the title Initial PR for adding SQS metricset Add SQS metricset into AWS metricbeat module Feb 11, 2019
@kaiyan-sheng kaiyan-sheng self-assigned this Feb 11, 2019
@kaiyan-sheng kaiyan-sheng added Metricbeat Metricbeat Team:Integrations Label for the Integrations team in progress Pull request is currently in progress. labels Feb 11, 2019
Copy link
Member

@ruflin ruflin left a comment

Choose a reason for hiding this comment

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

Left some early comments. Hope it's ok as it's still in progress.

x-pack/metricbeat/module/aws/sqs/_meta/data.json Outdated Show resolved Hide resolved
x-pack/metricbeat/module/aws/sqs/sqs.go Outdated Show resolved Hide resolved
x-pack/metricbeat/module/aws/sqs/sqs.go Outdated Show resolved Hide resolved
x-pack/metricbeat/module/aws/sqs/sqs.go Outdated Show resolved Hide resolved
init = false
output, err := aws.GetMetricDataPerRegion(metricDataQueries, getMetricDataOutput.NextToken, svcCloudwatch, startTime, endTime)
if err != nil {
err = errors.Wrap(err, "getMetricDataPerRegion failed, skipping region "+regionName)
Copy link
Member

Choose a reason for hiding this comment

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

I see this pattern across all our metricsets, we should come up wit a 1 liner to do this. @jsoriano FYI

I think @ycombinator already did something about this in the ES module.

if err != nil {
m.logger.Error(err.Error())
event.Error = err
report.Event(event)
Copy link
Member

Choose a reason for hiding this comment

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

Why not use report.Error(...) here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure... report.Error is what I want here... Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

I think it is correct as is if you want to report an event with whatever data it has AND an error.
In this case it seems that this would be an error with some metadata (service.name, cloud.region) and without any metrics, I think this could be acceptable.
If this is the case and this is the only thing blocking this PR I think this would be ready to go.

x-pack/metricbeat/module/aws/sqs/sqs_integration_test.go Outdated Show resolved Hide resolved
"count": c.Int("ApproximateNumberOfMessagesNotVisible"),
},
"visible": s.Object{
"count": c.Int("ApproximateNumberOfMessagesVisible"),
Copy link
Contributor

Choose a reason for hiding this comment

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

It's such a mess to have approximated values. I'm worried that users might rely on them as source of truth later and will open issues wondering why their maths doesn't match what they are expecting (from the field names)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These approximate metrics are directly from cloudwatch so if the users check in cloudwatch, the data should match what we have here.


metricSet, err := aws.NewMetricSet(base)
if err != nil {
return nil, errors.Wrap(err, "error creating aws metricset")
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️ to add error to context before returning.

Copy link
Contributor

@sayden sayden left a comment

Choose a reason for hiding this comment

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

Overall looks good apart from the comments that @ruflin already left.

@kaiyan-sheng kaiyan-sheng requested a review from a team as a code owner February 13, 2019 15:33
@@ -2,7 +2,7 @@ This module periodically fetches monitoring metrics from AWS Cloudwatch using
https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricData.html[GetMetricData API] for running
EC2 instances. Note: extra AWS charges on GetMetricData API requests will be generated by this module.

The default metricset is `ec2`.
The default metricset is `ec2` and `sqs`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The default metricset is `ec2` and `sqs`.
The default metricsets are `ec2` and `sqs`.

if err != nil {
m.logger.Error(err.Error())
event.Error = err
report.Event(event)
Copy link
Member

Choose a reason for hiding this comment

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

I think it is correct as is if you want to report an event with whatever data it has AND an error.
In this case it seems that this would be an error with some metadata (service.name, cloud.region) and without any metrics, I think this could be acceptable.
If this is the case and this is the only thing blocking this PR I think this would be ready to go.

@kaiyan-sheng kaiyan-sheng merged commit 5d4dc24 into elastic:master Feb 25, 2019
@kaiyan-sheng kaiyan-sheng deleted the aws_sqs branch February 25, 2019 19:02
@kaiyan-sheng kaiyan-sheng removed the in progress Pull request is currently in progress. label Feb 25, 2019
"oldest_message_age": {
"sec": 86404
},
"sent_message_size": {}
Copy link
Member

Choose a reason for hiding this comment

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

If we don't have bytes inside, this should not be here I assume?

},
"empty_receives": c.Float("NumberOfEmptyReceives"),
"sent_message_size": s.Object{
"bytes": c.Float("SentMessageSize"),
Copy link
Member

Choose a reason for hiding this comment

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

I'm still struggling with having bytes as a float. I understand it's because we get the average but should we just round it up or down?

The main issue I see is that we use scaled_floats which can become inaccurate for large numbers if I remember correctly. So using long would scale better.

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

Successfully merging this pull request may close these issues.

5 participants