towerops/lib/towerops/prom_ex.ex
Graham McIntire 50324c61ce feat(metrics): expose Prometheus /metrics via PromEx on :9568
Add PromEx with Application/BEAM/Phoenix/LiveView/Ecto/Oban plugins plus
a custom plugin that bridges existing Towerops Oban/Redis telemetry events.
The metrics HTTP server runs isolated on port 9568 so scrape traffic never
traverses the public Traefik IngressRoute.

The pod template carries prometheus.io annotations (scrape, port, path, job)
so the external Prometheus on 10.0.15.31 discovers each pod through the
existing kubernetes-pods scrape job (apiserver-proxy).
2026-05-08 10:25:25 -05:00

48 lines
1.2 KiB
Elixir

defmodule Towerops.PromEx do
@moduledoc """
PromEx supervisor that aggregates Phoenix, Ecto, Oban, BEAM, and custom Towerops
telemetry into Prometheus metrics.
The metrics endpoint runs on its own HTTP server (port 9568 by default, configured
in `config/runtime.exs`) so scrape traffic never traverses the public Traefik
IngressRoute. The Kubernetes Service is annotated with `prometheus.io/scrape`
for auto-discovery by the home-cluster Prometheus.
"""
use PromEx, otp_app: :towerops
alias PromEx.Plugins
@impl true
def plugins do
[
Plugins.Application,
Plugins.Beam,
{Plugins.Phoenix, router: ToweropsWeb.Router, endpoint: ToweropsWeb.Endpoint},
Plugins.PhoenixLiveView,
Plugins.Ecto,
Plugins.Oban,
Towerops.PromEx.TowerOpsMetrics
]
end
@impl true
def dashboard_assigns do
[
datasource_id: "Prometheus",
default_selected_interval: "30s"
]
end
@impl true
def dashboards do
[
{:prom_ex, "application.json"},
{:prom_ex, "beam.json"},
{:prom_ex, "phoenix.json"},
{:prom_ex, "phoenix_live_view.json"},
{:prom_ex, "ecto.json"},
{:prom_ex, "oban.json"}
]
end
end