Using TelemetryMetricsPrometheus and Plugs Instrumenter/Exporter

I am very much enjoying using GitHub - deadtrickster/prometheus-plugs: Prometheus.erl Elixir Plugs for all the conveniences out of the box, however, I would like to start adding my own telemetry events to be exposed via Prometheus too. Seems like TelemetryMetricsPrometheus — telemetry_metrics_prometheus v1.0.0 specifically TelemetryMetricsPrometheus.Core is the way to go. However, I’m not sure if it’s possible to make both of these interoperate. My ideal solution would be to define a list of telemetry events like so:

defp metrics, do:
    sum("http.request.payload_size", unit: :byte),
    last_value("", unit: :byte)

and have the appear along side the metrics already gathered by prometheus_plugs and prometheus_phoenix


For those coming across this, I’m currently using a workaround by service metrics on two endpoints:

This is plugged into k8s service monitors on our end so solves the issue for the time being.

1 Like

I may be biased here given I am the author of PromEx…but it sounds like it fits your current needs. PromEx is built on top of Telemetry and TelemetryMetricsPrometheus and collections of metrics are grouped into plugins (Oban plugin, BEAM plugin, LiveView plugin, etc). This also allows you to create your own plugins and have PromEx expose those on your /metrics endpoint. As an added bonus, PromEx can also take care of uploading your dashboards for you to Grafana as it can interface with the Grafana HTTP API. Give it a try and let me know what you think :slight_smile:.