Skip to content

Prometheus and Grafana

Kieran edited this page Jan 9, 2025 · 3 revisions

⚠️ This functionality isn't released yet ⚠️

You can optionally use Pinchflat's Prometheus agent if you want to collect application metrics. Note that these are generic metrics more related to performance rather than being application-specific metrics about things like, say, video size on disk. I'm open to PRs if you want to capture different metrics!

Enabling

Set the ENABLE_PROMETHEUS environment variable to any non-empty value. Metrics will then be made available at /metrics for Prometheus to consume

Grafana Dashboards

Assuming you've got Pinchflat and Prometheus talking to each other, there are some pre-made Grafana dashboards to simplify visualization. The ones to choose from are:

  • application.json
  • beam.json (the underlying Erlang virtual machine)
  • phoenix.json (the web framework itself)
  • ecto.json (the database connector)
  • oban.json (the job runner)
  • phoenix_live_view.json (the websocket tech that renders certain views)

Here's how to them them in Grafana:

  • In Grafana, go to Connections > Data Sources > Select your Prometheus data source > take note of the "Name" field. We'll need this later
  • Open the Docker console for your Pinchflat instance
  • Run mix prom_ex.dashboard.export -a datasource_id="<Prometheus name from step one>" --stdout -d <dashboard name.json>
    • NOTE: this will output the dashboard JSON to stdout for you to copy into Grafana
    • For example, if I wanted the phoenix.json dashboard and my Prometheus datasource name was "my_prometheus", I'd run:
mix prom_ex.dashboard.export -a datasource_id="my_prometheus" --stdout -d phoenix.json
  • Repeat for the other dashboards you're interested in!