Skip to content

labmonkeys-space/drl-exporter

 
 

Repository files navigation


Dockerhub rate limit prometheus metrics exporter

Docker Image Size (latest by date) Docker Image Version (latest by date) License GitHub issues

AboutUsageImage ConfigurationLocal DemoTODOIssuesCredits


About

This exporter allows to retrieve the DockerHub rate limit counts as scrape target for Prometheus. The exporter obtains an auth token and then queries the Docker Hub registry with a HEAD request to parse RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset into a Gauge metric. You can use your Docker Hub credentials to authenticate, otherwise an anonymous token is used.

Screenshot

Usage

Multi Arch docker images are available (arm/arm64/amd64) you can pull it from dockerhub and run in your environment.

docker pull khaliq/drl-exporter:latest

docker run -d -p 2121:2121  khaliq/drl-exporter:latest

curl localhost:2121/metrics

Output

# HELP dockerhub_limit_max_requests_time Dockerhub rate limit maximum requests total time seconds
# TYPE dockerhub_limit_max_requests_time gauge
dockerhub_limit_max_requests_time 21600
# HELP dockerhub_limit_max_requests_total Dockerhub rate limit maximum requests in given time
# TYPE dockerhub_limit_max_requests_total gauge
dockerhub_limit_max_requests_total 100
# HELP dockerhub_limit_remaining_requests_time Dockerhub rate limit remaining requests time seconds
# TYPE dockerhub_limit_remaining_requests_time gauge
dockerhub_limit_remaining_requests_time 21600
# HELP dockerhub_limit_remaining_requests_total Dockerhub rate limit remaining requests in given time
# TYPE dockerhub_limit_remaining_requests_total gauge
dockerhub_limit_remaining_requests_total 99

To build the image in your local envorinment
git clone https://github.com/m47ik/drl-exporter.git
cd drl-exporter
make docker

Configuration Variables

Variables Default Value Discription
EXPORTER_PORT 2121 Server listening port
ENABLE_USER_AUTH false️ Must be set to true if providing username
DOCKERHUB_USER "" Dockerhub account
DOCKERHUB_PASSWORD "" Account password
DOCKERHUB_REPO_IMAGE ratelimitpreview/test custom repository/image

Local Demo

You can find the complete docker-compose file along with a dashboard under deploy folder to test it out.

cd deploy/docker-compose
docker-compose up -d
version: "3.7"
services:

  docker-hub-limit-exporter:
    image: khaliq/drl-exporter:latest
    environment:
      - EXPORTER_PORT=8881
      - DOCKERHUB_USER=user
      - DOCKERHUB_PASSWORD=password
      - ENABLE_USER_AUTH=true
    ports:
      - "8881"

  prometheus:
    image: prom/prometheus:latest
    volumes:
      - type: bind
        source: ./etc/prometheus.yaml
        target: /etc/prometheus.yaml
    entrypoint:
      - /bin/prometheus
      - --config.file=/etc/prometheus.yaml
    ports:
      - "9090:9090"

  grafana:
    image: grafana/grafana:latest
    volumes:
      - ./deploy-data/datasources:/etc/grafana/provisioning/datasources
      - ./deploy-data/dashboards-provisioning:/etc/grafana/provisioning/dashboards
      - ./deploy-data/dashboards:/var/lib/grafana/dashboards
    environment:
      - GF_AUTH_ANONYMOUS_ENABLED=true
      - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
      - GF_AUTH_DISABLE_LOGIN_FORM=true
    ports:
      - "3000:3000"

Web UI

Web URL
Grafana http://localhost:3000
Prometheus http://localhost:9090
Exporter http://localhost:8881

TODO

  • Tests
  • Helm Chart

Issues

Please open an issue if you are facing any problems.

Credits

This project is inspired by Michael Friedrich's amazing work.

About

Prometheus exporter for dockerhub rate limits

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Go 89.2%
  • Dockerfile 5.7%
  • Makefile 5.1%