Fedora offers optional server metrics using Prometheus.
To enable metrics collection, the fcrepo.metrics.enable
property must be set to true
. For example, you could start Fedora with the argument -Dfcrepo.metrics.enable=true
. With this option on, Fedora now exposes an endpoint that can be used by Prometheus to collect metrics. The endpoint is at http://[FCREPO-HOST]/prometheus
.
Example Metrics Collection Setup
The following is an example of how you could setup Prometheus and Grafana using Docker to collect and monitor Fedora metrics. It is a quick and easy setup, and not intended to demonstrate a production ready install. This setup assumes that you already have Docker and Docker Compose installed on your system.
8080
on the same machine that you intend to run Prometheus and Grafana on. If this is not the case, you will need to adjust some of the following configuration accordingly. For example, if you're running Fedora using Tomcat you may need to add a context to the the metrics_path
so that it's something like /fcrepo/prometheus
instead of /prometheus
.Linux Setup
Create a Prometheus config file, named prometheus.yml
, that looks similar to the following:
scrape_configs: - job_name: 'fcrepo' scrape_interval: 30s metrics_path: '/prometheus' static_configs: - targets: ['localhost:8080'] basic_auth: username: fedoraAdmin password: fedoraAdmin
Next, create a Docker compose file in the same directory, named docker-compose.yml
,that looks like the following:
version: '3.8' services: prometheus: image: prom/prometheus ports: - "9090:9090" volumes: - ./prometheus.yml:/etc/prometheus/prometheus.yml network_mode: "host" grafana: image: grafana/grafana ports: - "3000:3000" network_mode: "host"
Mac (Windows?) Setup
Create a Prometheus config file, named prometheus.yml
, that looks similar to the following:
scrape_configs: - job_name: 'fcrepo' scrape_interval: 30s metrics_path: '/prometheus' static_configs: - targets: ['host.docker.internal:8080'] basic_auth: username: fedoraAdmin password: fedoraAdmin
Next, create a Docker compose file in the same directory, named docker-compose.yml
,that looks like the following:
version: '3.8' services: prometheus: image: prom/prometheus ports: - "9090:9090" volumes: - ./prometheus.yml:/etc/prometheus/prometheus.yml grafana: image: grafana/grafana ports: - "3000:3000"
Collecting Metrics
From within this directory, execute docker-compose up
to startup the services. You can confirm the services started by browsing to http://localhost:9090, the Prometheus endpoint, and http://localhost:3000, the Grafana endpoint.
Note, this will run the process in the foreground. If you prefer to run it in the background, use the -d
flag.
The final bit of setup is to connect Grafana to Prometheus as follows:
- Log into Grafana with the default credentials:
admin
/admin
- Navigate to Configuration -> Datasources
- Add a Prometheus datasource
- For the Prometheus URL, if you're on linux specify http://localhost:9090, and if you're on Mac use http://host.docker.internal:9090. For amazon linux 2 use http://prometheus:9090
- Save the configuration
Now that you have the datasource added, you can create a dashboard to display metrics from Fedora. Here is an example dashboard that you can import with some pre-configured graphs. You will need to actively use Fedora before any graphs will appear.