PhoenixKit plugin module for collecting and charting time-series stats.
An admin creates a stats group (e.g. "server1") representing one
external data source. Each group gets its own Barograph
database (a single SQLite file) and a dedicated Graphite plaintext TCP
port. Whatever collector process runs on that source writes
metric value timestamp lines to the port; the admin picks a metric on
the group's page and gets a live SVG chart.
How it works
use PhoenixKit.Modulemarks this module as a plugin (persists a@phoenix_kit_moduleattribute in the.beamfile).- PhoenixKit scans
.beamfiles at startup and discovers this module automatically — no config line needed. children/0startsPhoenixKitStats.DatabaseManager, which opens every active group's Barograph database + Graphite listener.migration_module/0points atPhoenixKitStats.Migrations.Schema, whichmix phoenix_kit.updateuses to create/upgradephoenix_kit_stats_groupsin the host app's database — no corephoenix_kitPR required.
Installation
Add to your parent app's mix.exs:
{:phoenix_kit_stats, "~> 0.2"}Then configure where per-group Barograph files are stored (required):
config :phoenix_kit_stats, data_dir: "/var/data/phoenix_kit_stats"Optionally override the port range groups auto-allocate collector ports
from (default 9100..9200):
config :phoenix_kit_stats, port_range: 9100..9200Run mix deps.get, then mix phoenix_kit.update to create the
phoenix_kit_stats_groups table. The module appears in the admin
sidebar and Modules page automatically.
Security note
Graphite's plaintext protocol has no built-in authentication — each group's collector port is a bare TCP listener. Restrict who can reach those ports at the network layer (firewall / VPN / private interface); this module cannot enforce access control on the wire protocol itself.
Navigation paths
All navigation goes through PhoenixKitStats.Paths, which wraps
PhoenixKit.Utils.Routes.path/1 for prefix/locale handling.
Summary
Functions
Admin sidebar tabs: a parent tab plus a visible "Groups" list and
hidden leaf tabs for the new/edit/show pages. Static /new is ordered
before the :uuid wildcard tabs so PhoenixKit's route generation
(which registers routes in list order) doesn't let the wildcard shadow it.
Starts PhoenixKitStats.DatabaseManager under the host's
PhoenixKit.Supervisor (via PhoenixKit.ModuleRegistry.static_children/0).
No host-app supervision tree changes needed.
OTP apps whose templates Tailwind should scan for CSS classes.
Disables the module. Same pattern as enable_system/0.
Enables the module by persisting a boolean setting.
Whether the module is currently enabled.
Versioned migration coordinator for phoenix_kit_stats_groups. Picked
up automatically by mix phoenix_kit.update — this module's table is
not part of core phoenix_kit's own migration chain.
Unique key for this module. Used in settings, permissions, and PubSub events.
Display name shown in the admin UI.
Permission metadata for the roles/permissions matrix.
Version string. Shown on the admin Modules page.
Functions
Admin sidebar tabs: a parent tab plus a visible "Groups" list and
hidden leaf tabs for the new/edit/show pages. Static /new is ordered
before the :uuid wildcard tabs so PhoenixKit's route generation
(which registers routes in list order) doesn't let the wildcard shadow it.
Starts PhoenixKitStats.DatabaseManager under the host's
PhoenixKit.Supervisor (via PhoenixKit.ModuleRegistry.static_children/0).
No host-app supervision tree changes needed.
OTP apps whose templates Tailwind should scan for CSS classes.
Disables the module. Same pattern as enable_system/0.
Enables the module by persisting a boolean setting.
Whether the module is currently enabled.
Reads from the DB-backed settings table. Defensive against DB not
being available yet (startup ordering, missing table, sandbox
artifacts in tests) — always falls back to false.
Versioned migration coordinator for phoenix_kit_stats_groups. Picked
up automatically by mix phoenix_kit.update — this module's table is
not part of core phoenix_kit's own migration chain.
Unique key for this module. Used in settings, permissions, and PubSub events.
Display name shown in the admin UI.
Permission metadata for the roles/permissions matrix.
Version string. Shown on the admin Modules page.