← Home

◢◢ Grafana-Prometheus

Setting up metrics

Create an API token in Strapi

  1. Create a new API token from the admin panel
  2. Call the token Prometheus, duration Unlimited, token type Read-only
  3. Save the generated token somewhere

Setup Prometheus

  1. Create a new Web Service in Render
  2. Deploy from an existing image, use prom/prometheus
  3. Create a persistent disk, 1GB mount path /var/data
  4. SSH into the service, using the Render Shell sidebar (takes a little while to connect)
  5. Configure Prometheus via vi /var/data/prometheus.yml & paste the following, altering STRAPI_API_TOKEN & targets as required:
global:
  scrape_interval: 60s

scrape_configs:
  - job_name: 'api'
    metrics_path: '/api/metrics'
    bearer_token: 'STRAPI_API_TOKEN'
    static_configs:
      - targets: ['api.justabout.com']
  1. Set the Docker Command in Settings to /bin/prometheus --config.file=/var/data/prometheus.yml

Setup Grafana

  1. Create a new Web Service in Render
  2. Deploy from an existing image, use grafana/grafana
  3. Create a persistent disk on the service, 1GB on /var/lib/grafana
  4. Set the environment variables on the service:
GF_SECURITY_ADMIN_USER=admin
GF_SECURITY_ADMIN_PASSWORD=whatever_you_want
  1. Navigate to Grafana via the link on the service, e.g. https://grafana-ldr1.onrender.com
  2. Log in & configure a new Prometheus data source at /connections/datasources/new
  3. Setup the datasource with the server URL being that of the URL of the just created Prometheus service, e.g. https://prometheus-86k2.onrender.com
  4. Create dashboards as you wish!