Home

Awesome

Prometheus AWS ElastiCache Service Discovery

release build go report

ElastiCache SD allows retrieving scrape targets from AWS ElastiCache cache nodes for Prometheus. No address is defined by default, it must be configured with relabeling and requires a third-party exporter supporting the multi-target pattern.

Configuration

Help on flags:

./prometheus-elasticache-sd --help

The following meta labels are available on targets during relabeling:

The following AWS IAM permissions are required:

Usage

Docker

To run the ElastiCache SD as a Docker container, run:

docker run ghcr.io/maxbrunet/prometheus-elasticache-sd:latest --help

oliver006/redis_exporter

This service discovery can be used with oliver006/redis_exporter, here is a sample Prometheus configuration:

scrape_configs:
  - job_name: "redis_exporter_targets"
    file_sd_configs:
    - files:
        - /path/to/elasticache.json  # Set file path with --output.file flag
    metrics_path: /scrape
    relabel_configs:
      # Filter for Redis cache nodes
      - source_labels: [__meta_elasticache_engine]
        regex: redis
        action: keep
      # Build Redis URL to use as target parameter for the exporter
      - source_labels:
          - __meta_elasticache_endpoint_address
          - __meta_elasticache_endpoint_port
        replacement: redis://$1
        separator: ':'
        target_label: __param_target
      # Use Redis URL as instance label
      - source_labels: [__param_target]
        target_label: instance
      # Set exporter address
      - target_label: __address__
        replacement: <<REDIS-EXPORTER-HOSTNAME>>:9121

prometheus/memcached_exporter

This service discovery can be used with the official memcached_exporter, see its README for details.

Development

Build

Binary:

go build .

Container image with ko:

ko build --base-import-paths --local .

Test

go test -v ./...

License

Apache License 2.0, see LICENSE.