Part 1: Adding custom metrics to a Phoenix 1.5 live dashboard

The code for this demo is available here

As I mentioned in the previous post, one of the downsides to the new Phoenix live dashboard is that the metrics and graphs are transient. In order to see longer term trends, we’re going to send our telemetry metrics to InfluxDB via StatsD.

Add the statsd reporter to your Phoenix app

Open lib/metrics_demo_web/telemetry.ex and add the following line to the deps:

{:telemetry_metrics_statsd, "~> 0.4"},

It should now look like this:

defp deps do
[
{:phoenix, "~> 1.5.3"},
{:phoenix_ecto, "~> 4.1"},
{:ecto_sql, "~> 3.4"},
{:postgrex, ">= 0.0.0"},
{:phoenix_live_view, "~> 0.13.0"},
{:floki, ">= 0.0.0", only: :test},
{:phoenix_html, "~> 2.11"},
{:phoenix_live_reload, "~> 1.2", only: :dev},
{:phoenix_live_dashboard, "~> 0.2.0"},
{:telemetry_metrics, "~> 0.4"}, …

About

Marc Delagrammatikas

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store