-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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] add a field to represent the amount of MetricStat in CloudWatch GetMetricData API #18448
Comments
Pinging @elastic/integrations-platforms (Team:Platforms) |
beats/x-pack/metricbeat/module/aws/cloudwatch/cloudwatch.go Lines 443 to 461 in 1dde9f4
I want to create a panel of Metric visualization in kibana to show how many cloudwatch metrics are queried and estimated cost. |
I run a demo test. Except of the amount of MetricDataQueries, we should also pay attention to the amoun of emtpy values in MetricDataResults. This would be helpful to observe the cost of metricbeat.
index 5674a45ec..d4d55335a 100644
--- a/x-pack/metricbeat/module/aws/cloudwatch/cloudwatch.go
+++ b/x-pack/metricbeat/module/aws/cloudwatch/cloudwatch.go
@@ -458,6 +461,17 @@ func (m *MetricSet) createEvents(svcCloudwatch cloudwatchiface.ClientAPI, svcRes
if err != nil {
return events, errors.Wrap(err, "GetMetricDataResults failed")
}
+ emptyValueMetricCount := 0
+ for _, item := range metricDataResults {
+ if item.Values == nil {
+ emptyValueMetricCount += 1
+ }
+ }
+ e := aws.InitEvent(regionName, m.AccountName, m.AccountID)
+ e.RootFields.Put("aws.cloudwatch.getmetricdata.query.amount", len(metricDataQueries))
+ e.RootFields.Put("aws.cloudwatch.getmetricdata.result.amount", len(metricDataResults))
+ e.RootFields.Put("aws.cloudwatch.getmetricdata.result.emptyvalues", emptyValueMetricCount)
+ events["some_random_strings"] = e
this indicates that 48.4% of the MetricDataQueries got emtpy result, we should optimize metricbeat config to reduce the wast of cost. refer:
|
@kwinstonix Thanks for all the effort! Good point it would be nice to show users the query number to help understanding the API cost. What do you think about adding these information in debug logs for example instead of in each event? |
When you mention |
Yes, debug log is also helpful . When I run metricbeat deployment in production env, I should report the estimated AWS API cost, so I think it is better to have a visualization panel in Kibana. Besides, metricbeat uses AWS API that is not free, These metrics in the example are not included in each event. Each Above all is just the situation I'm facing, and I hope metricbeat could export some metrics of AWS API call cost. Maybe others people have the same situation ? Thanks for your reply |
Region or dimensions filters are helpful, and I reported another issue #18050 😁 When I run tests, there's a odd metric There is another situaction that |
Describe the enhancement:
add a field
metricstatscount
to represent the amount of MetricStat in CloudWatch GetMetricData api request . Then we can figure out how many metrics were retrieved from AWS and the monthly bill amount.with the example, there are six MetricNames of CloudWatch and each MetricName has only one statistic. so the total amount of MetricStat is6 * 1 = 6
this only shows the MetricDataResults with valid datapoint, please refer below comment
The text was updated successfully, but these errors were encountered: