aprs.me/lib/aprsme/prom_ex.ex
Graham McIntire 51e068f3f1
Add PromEx Prometheus exporter and /metrics endpoint
Wire up prom_ex with built-in Application, Beam, Phoenix, PhoenixLiveView,
and Ecto plugins, plus a custom plugin that exposes the existing
app-specific telemetry (packet pipeline, spatial PubSub, repo pool,
postgres stats, insert optimizer) as Prometheus metrics.

Mount PromEx.Plug at /metrics — internal-only, intended to be scraped
by the cluster's external Prometheus through the kube-apiserver pod
proxy. K8s pod template now carries prometheus.io/{scrape,port,path}
annotations so the existing kubernetes-pods scrape job picks it up
automatically.

PromEx is disabled in the test environment.

Also harden the packet cleanup and partition manager tests with
Repo.delete_all setup hooks so they aren't poisoned by residual rows
committed outside a sandbox transaction in earlier runs (which were
inflating delete counts and triggering ATTACH PARTITION check_violation
errors against packets_default).
2026-05-08 10:41:06 -05:00

42 lines
1 KiB
Elixir

defmodule Aprsme.PromEx do
@moduledoc """
PromEx supervision module for the aprs.me application.
Built-in plugins provide metrics for Phoenix, Phoenix LiveView, Ecto, the BEAM
VM, and the Application/release. The custom `Aprsme.PromEx.Plugins.Aprsme`
plugin exposes the app-specific telemetry events emitted by the GenStage
packet pipeline, SpatialPubSub, and the periodic Postgres collectors.
Metrics are scraped at `GET /metrics` on the Phoenix endpoint via
`PromEx.Plug` (mounted in the router).
"""
use PromEx, otp_app: :aprsme
alias PromEx.Plugins
@impl true
def plugins do
[
Plugins.Application,
Plugins.Beam,
{Plugins.Phoenix, router: AprsmeWeb.Router, endpoint: AprsmeWeb.Endpoint},
Plugins.PhoenixLiveView,
{Plugins.Ecto, otp_app: :aprsme, repos: [Aprsme.Repo]},
Aprsme.PromEx.Plugins.Aprsme
]
end
@impl true
def dashboard_assigns do
[
datasource_id: "Prometheus",
default_selected_interval: "30s"
]
end
@impl true
def dashboards do
[]
end
end