A simple, lightweight Prometheus metrics exporter for AWS' Simple Queue Service, written in Go. Potential use cases are monitoring SQS queues or scaling off SQS queues (e.g. with a Kubernetes HPA).
The SQS Prometheus Exporter can be run using the Docker image with either the docker-compose file or the Helm chart. To use the Helm chart, execute helm install sqs-prometheus-exporter oci://ghcr.io/jmriebold/charts/sqs-prometheus-exporter
.
In order to authenticate with AWS, the SQS Prometheus Exporter will need AWS credentials either in environment variables (i.e. AWS_ACCESS_KEY_ID
, AWS_SECRET_ACCESS_KEY
), a creds file mounted into the container, or a role to assume via IRSA or kiam/kube2iam. For more information on authenticating with AWS, see the official documentation.
The user or role that the service will be using to monitor the SQS queues will need the permissions contained in AWS' AmazonSQSReadOnlyAccess
policy.
To set the queues scraped by the Exporter, set the SQS_QUEUE_URLS
environment variable to a comma-separated list of the SQS queue URLs. For example: SQS_QUEUE_URLS=https://sqs.[region].amazonaws.com/[account-id]/[queue-name-1],https://sqs.[region].amazonaws.com/[account-id]/[queue-name-2]
By default the application will scrape queue metrics every 30 seconds. To change this interval, set the SQS_MONITOR_INTERVAL_SECONDS
environment variable.
Examples of how to run SQS Prometheus Exporter locally (such as via systemd) can be found under the examples directory. See the chart README for Helm-specific examples.
The SQS Prometheus Exporter serves the following metrics:
sqs_approximatenumberofmessages
sqs_approximatenumberofmessagesdelayed
sqs_approximatenumberofmessagesnotvisible
Each has a queue
label, which will be populated with the queue name and metric value.
SQS Prometheus Exporter uses the following Go packages:
- aws-sdk-go for monitoring the queues themselves
- prometheus/client_golang for metrics
- zerolog for logging
- Kubernetes cluster (ideally Minikube, however managed or other types of clusters work as well)
- kubectl
- helm
- skaffold
- Install local dev tools
- Create a Kubernetes cluster with your tool of choice and set kubectl context accordingly
- Execute
skaffold dev
SQS Prometheus Exporter should now be running alongside LocalStack and the Kube-Prometheus-Stack, where you can test your changes.