Created
November 22, 2022 14:41
-
-
Save carlosjgp/85d9a71fe2b979ae9978994a8ba57bb9 to your computer and use it in GitHub Desktop.
Prometheus Cloudwatch exporter configuration generation
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
# This command shows all the metrics from all the services in use on the account and region used | |
# Different services and configurations might have more or less metrics than others. eg. When using T instance types you would get CPU credits related metrics otherwise you won't | |
# | |
# AWS Cloudwatch metrics namespaces https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/aws-services-cloudwatch-metrics.html | |
aws cloudwatch list-metrics --namespace AWS/ES > metrics.json | |
# Add 'select(.MetricName | contains("FreeStorageSpace")) |' to JQ pipe to filter by name | |
# | |
# this snippet will not add the instances identifiers and remove duplicated entries (one per instace) | |
cat metrics.json | jq -r '.Metrics | |
| map({ | |
(.MetricName): | |
{ | |
aws_namespace: (.Namespace), | |
aws_metric_name: (.MetricName), | |
aws_dimensions: (.Dimensions | map(.Name)), | |
aws_statistics: ["Average"] | |
} | |
}) | |
| add | |
| to_entries | |
| map(.value)' | yq -P | xclip -sel clip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment