Monitoring Quay with Prometheus and Grafana
Environment
- Red Hat Quay
- Prometheus
- Grafana v5.4.1
- Red Hat Enterprise Linux 7.x
Issue
- Configure Prometheus and Grafana for extracting repository count over a duration
Resolution
Following steps outline process of configuring Prometheus and Grafana to monitor repository count
Step 1 :
Publish port 9092(note: for 3.3.0 and newer, publish port 9091) on Quay by running following docker command
docker run --restart=always -p 443:443 -p 80:80 -p 9092:9092 --privileged=true -v /var/run/quay/config:/conf/stack -v /var/run/quay/storage:/datastorage -d quay.io/coreos/quay:v2.9.2
Once quay has started successfully execute curl http://{QuayHostname}:9092/metrics to validate if you are able to see metrics in raw format
Step 2:
On the host where Prometheus will be configured create prometheus.yml file with following contents
global:
scrape_interval: 15s # By default, scrape targets every 15 seconds.
evaluation_interval: 15s # By default, scrape targets every 15 seconds.
scrape_configs:
- job_name: 'quay'
static_configs:
- targets: ['QuayFQDN:9092']
Provide Fully Qualified Domain Name for targets and appropriate job_name in above config file.
Note: The job_name will be used for configuring queries on Grafana
Step 3:
Install Prometheus by mounting the config file and publish default port 9090 by running following docker command
docker run --name prometheus-quay -d -p 9090:9090 -v /path to/prometheus.yml/:/etc/prometheus/prometheus.yml -d quay.io/prometheus/prometheus:latest
Note: Update the path for prometheus.yml in the above command accordingly . Once Prometheus container is up, access http://{example.prometheus.redhat.com}:9090
Step 4:
Install Grafana using following docker command
docker run -d --name=grafana -p 3000:3000 grafana/grafana
Step 5:
Once Grafana container is up, access http://{example.grafana.redhat.com}:3000.
Click Data source on Grafana and choose Prometheus from the list , provide details of Prometheus endpoint http://{example.prometheus.redhat.com}:9090.
Step 6:
Create a new panel and click on tab Metrics , update the following query for deriving the repository count with suitable duration
rate(quay_repository_count{job="job_name"}[duration])
Note: The job_name should match the one provided in prometheus.yml . The duration can be in seconds, minutes or hours, for example 10h
Step 7:
Use the Query Inspector to validate the query.
You can add multiple panels measuring various parameters associated with Quay.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.