Skip to content

Instantly share code, notes, and snippets.

@carlosjgp
Created November 22, 2022 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlosjgp/85d9a71fe2b979ae9978994a8ba57bb9 to your computer and use it in GitHub Desktop.
Save carlosjgp/85d9a71fe2b979ae9978994a8ba57bb9 to your computer and use it in GitHub Desktop.
Prometheus Cloudwatch exporter configuration generation
# 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