Extending grex¶
Practical recipes for common changes. Keep 1.0 non-goals in mind: no mutations, no persistence, no multi-tenancy unless the SPEC and an issue explicitly open that work.
Add a Prometheus metric¶
- Decide server vs fleet registry (see Observability).
- Event-driven counter/gauge updates → extend
metrics.Eventsand thefleet.Events(or opampMetrics) interface if the source is registry/OpAMP. - Scrape-time gauge from fleet state → extend
metrics.FleetCollectorDescribe/Collect. - Register in the correct registry inside
NewEvents/ collector setup. - Add gather/compare tests.
- Document in Metrics.
Cardinality: avoid unbounded labels. Per-agent series already use
instance_uid under a hard cap.
Add an API field¶
- Add data on
fleet.Agentif it is state (populate from OpAMP inopamp/ registry apply paths). - Expose via
AgentViewinfleet/view.go(summary vs detail). - API handlers already encode views as JSON—no DTO layer.
- Extend
handler_test.goassertions. - Update Read API docs.
If the field is filterable, decide whether it is a reserved bool (must update
api.boolFields and fleet.ReservedAttributeKeys together) or an
attribute matcher.
Add an API route¶
- Implement method on
api.Handler. Mountwith Go 1.22 pattern and pass throughwrapfor metrics:
Add a UI page or partial¶
- Template in
internal/ui/templates/. - Handler method +
Mountroute; partials under/partials/...for htmx. - Reuse filters/views from
api/fleet. - CSS only if needed (
static/app.css); keep design tokens. - UI test for status code and a stable selector/string.
Change check-in / eviction policy¶
Logic lives in fleet.Registry with config from fleet.heartbeat_interval
and stale_missed_heartbeats. Adjust tests that encode timing carefully;
document operator-facing behavior in user/admin docs.
Wire authentication (future)¶
Follow issue #11 and the design SPEC milestones (UI mTLS → OIDC). Expect new config structs, middleware on the UI mux, and auth metrics. Do not half-land auth without updating Admin: authentication.
Config field checklist¶
- Struct field on
config.Config(or nested) - Default in
defaults() - Env override in
envOverrides()withGREX_…name - Validation in
validate() config.example.yamlcomment- Admin configuration docs
- Optional: label on
grex_config_infoif operators should see it in metrics (non-secret only)