Created
October 28, 2015 21:26
-
-
Save gdhaworth/b71cda594f7a10f2e3c1 to your computer and use it in GitHub Desktop.
Grabs all of the CloudWatch metric names and dimensions and prints them in Splunk's inputs.conf format for easy use with the Splunk AWS add-on. Requires awscli and jq.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -ex | |
exec aws cloudwatch list-metrics \ | |
| jq -r ' | |
.Metrics | |
| reduce .[] as $item ({}; .[$item.Namespace] |= { | |
names: (.names + [$item.MetricName] | unique), | |
dimensions: (.dimensions + [$item.Dimensions[].Name?] | unique) | |
}) | |
| to_entries | |
| .[] | |
| .value.dimensions |= map({ | |
(.): [".*"] | |
}) | |
| "[aws_cloudwatch://\(.key | gsub("/"; ".") | ascii_downcase)]\n" | |
+ "metric_namespace = \(.key)\n" | |
+ "metric_names = \(.value.names | tojson)\n" | |
+ "metric_dimensions = \(.value.dimensions | tojson)\n"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment