Skip to content
codemowersPublic

About

Grafana for Prometheus native environments

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Anafarg

Declarative Prometheus dashboards for Kubernetes. Administrators install ClusterChart and ClusterDashboard resources that name discovered metric families. Anafarg compiles them to PromQL that is checked and scoped to each viewer. It renders every output with one Go renderer: SVG in the browser, embeddable components for Driftmower, PNG/MJPEG for old browsers and media players, and a Linux framebuffer helper.

DESIGN.md is the design; chart/files contains the maintained resources. /explore is the metric explorer; the Python spike in spike/ remains the reference for info-join suggestions.

Explore metric controls are grouped into Filters, Data and Display. Split charts produces one chart per label value, including independent histogram heatmaps (for example, PMR channel or speaker instance). Splitting happens before aggregation and pooling, keeps the same authorization as the combined chart, and shows up to 24 groups at once. Filter labels to narrow larger selections. Splits and other view choices are recorded in the URL. YAML export produces a ClusterChart for a combined view or a repeated ClusterDashboard for a split view; queries and diagnostics are available below the charts.

The dashboard list keeps every installed dashboard visible. Dashboards whose required jobs are absent from their Prometheus catalog appear gray and sort below available dashboards, with the missing jobs named on the card. Optional overlay sources do not affect availability; discovery failures are reported as unknown availability rather than missing exporters.

The bundled /dashboards/alerts dashboard puts critical alerts first, followed by warnings and other severities. Each section pairs state timelines with horizontal active-duration bars. Namespace, alert, node and Pod selectors narrow the view; opening a chart groups it by alert name and offers label filters and alternative splits. ALERTS_FOR_STATE uses the shared timestamp interval renderer, with full durations inside bars even when activation predates the visible range. Disable the bundled dashboards with provision.dashboards: false.

Path Contents
cmd/anafarg Service: UI, API, display listener
cmd/anafarg-fb Linux framebuffer helper
internal/ Discovery, compiler, engine, renderer, auth, server
ui/ Dependency-free browser UI and the <anafarg-*> embed library
chart/ Helm chart with CRDs and the bundled Kubernetes resource and alert dashboards

Everything is pure Go (CGO_ENABLED=0).

Compared to Grafana

Anafarg is narrower than Grafana by design: Prometheus metrics on Kubernetes, defined in Git, viewed by people whose access Kubernetes already knows.

Grafana Anafarg
Building a chart Write PromQL, pick a visualisation, set units and legends by hand Metric types, units and the right chart (rate, line, heatmap, state, table) are discovered from Prometheus metadata and naming; a chart names {job, metric} plus typed refinements
Source of truth Its own database. Dashboards and alert rules edited in the browser live there, outside Git; grafana-operator copies CRDs into Grafana through its API, so Git and the UI drift ClusterChart/ClusterDashboard CRDs are watched directly and live the moment kubectl apply or Argo CD writes them. There is no browser editing, so Git is the only state
Alerting Grafana-managed alert rules, edited in the browser and stored in its database Already declarative without Anafarg: PrometheusRule resources evaluated by Prometheus, routed by Alertmanager and its AlertmanagerConfig, reviewed like any other manifest. Anafarg only charts the result
State SQLite/PostgreSQL with schema migrations on upgrade and slow cold starts No database. Restart is ready within a second; replicas are independent
Access control A parallel model of orgs, teams, folders and data source permissions, mapped from IdP groups and kept in sync by hand Kubernetes RBAC: get on the dashboard, Pods visible only in namespaces where you may list pods, monitor get for the explorer. Enforced on every PromQL selector before it reaches Prometheus
Who sees what Anyone who can view a dashboard sees everything its queries return The same dashboard shows each viewer only their namespaces' series
Old and small screens A large JavaScript application; struggles on older smart TVs and low-end devices One Go renderer draws SVG for browsers and the same picture as PNG/MJPEG: plain HTML for Firefox 3.5 or an old TV browser, anafarg-fb for a Linux framebuffer, unlisted links for wall displays without accounts
Memory, measured on ee-lte-1 1425 MiB working set (Grafana 13.1 pod, including its public-dashboards sidecar) 9 MiB idle, 61 MiB peak over a day of deploys and heavy explorer queries
Client A large JavaScript application A 59 KB (17 KB gzipped) dependency-free UI, or no JavaScript at all on legacy displays
Repeated queries Re-queries the whole range on every refresh Step-aligned incremental queries: a refresh fetches only the last few minutes, shared across viewers with the same scope
Embedding iframes with their own login <anafarg-dashboard> web components with the host's token and context (Driftmower)

Deliberately missing: logs and traces, data sources other than Prometheus, plugins, and editing in the browser. Editing in the browser is state outside Git; to change a dashboard, change its manifest. The explorer helps by generating the ClusterChart YAML for whatever you are looking at.

Local development

With the laptop Prometheus port-forward on 127.0.0.1:19090, you can run without Kubernetes or a login:

go build -o .build/anafarg ./cmd/anafarg
.build/anafarg -listen 127.0.0.1:8788 -display-listen 127.0.0.1:8789 \
  -auth-mode anonymous -no-kube \
  -resources chart/files \
  -prometheus monitoring/prometheus=http://127.0.0.1:19090
  • Browser UI: open http://127.0.0.1:8788/.
  • Resources: -resources takes comma-separated directories of Anafarg resources and reloads them on change. Unlisted links need metadata.uid and -link-key-file (at least 32 bytes).
  • Kubernetes: instead of -no-kube, pass -context ee-lte-1.codemowers.io to resolve Prometheus resources, read monitor labels and run SubjectAccessReviews with your kubeconfig.
go test ./...
node ui/test_units.mjs   # browser unit formatting matches internal/units
node ui/test_yaml.mjs    # explorer ClusterChart YAML

Useful URLs:

  • /dashboards/namespace-resources?var-namespace=demo&range=6h
  • /api/v1/dashboards/cluster-resources/dashboard.png?width=1280&height=720&theme=dark
  • /api/v1/charts/node-cpu/render.svg
  • /explore?job=monitoring/node-exporter: metric explorer
  • /api/v1/prometheus/monitoring/prometheus/catalog: discovered jobs and families

Embedding

<script type="module" src="https://anafarg.example/embed/anafarg.js"></script>
<anafarg-dashboard src="https://anafarg.example" name="namespace-resources"
                   vars="namespace=shop" range="6h" hide-title></anafarg-dashboard>
<anafarg-chart src="https://anafarg.example" name="node-cpu" height="240"></anafarg-chart>
  • Authentication: set element.getToken = async () => token with a Passmower access token for Anafarg's audience. The calling origin must be in allowedOrigins.
  • Variables: those bound in vars are hidden; the others stay selectable.
  • Errors: RBAC denials render inside the panel.

Displays

Dashboards are private; links publish them. A ClusterDashboardLink (administrators, any dashboard, scope: {all: true} or {namespaces: [...]}) or a DashboardLink (namespace admins, dashboards with sharing.namespaced: true, own namespace only) is served at /d/TOKEN/ (unlisted, the default) or /public/NAMESPACE/NAME/ (- for cluster links). Charts that would read series outside a namespace link's boundary render "No access". /links lists the links you administer with their URLs. See docs/sharing.md. The same URL works in modern browsers and, through an ES3 fallback, in Firefox 3.5. …/legacy is plain HTML with a refreshing PNG; add ?stream=mjpeg for a continuous image. display.enabled adds a display-only listener and Service with TLS none, legacy (TLS 1.0 for Windows XP) or modern.

Framebuffer (amd64, arm64, armv7):

CGO_ENABLED=0 GOARCH=arm64 go build -o anafarg-fb ./cmd/anafarg-fb
./anafarg-fb -url https://anafarg.example/d/TOKEN/ -var node=worker-1 -fb /dev/fb0
./anafarg-fb -url https://anafarg.example/public/-/lab-status/ -list-vars
./anafarg-fb -url https://anafarg.example/public/-/lab-status/ -png out.png -width 800 -height 480

-discover finds the links in your kubeconfig with kubectl (all contexts, or -contexts a,b; one query per cluster) and shows them. It also prints the same command line with one -url per link, which then runs on a PC without kubectl or a login:

$ ./anafarg-fb -discover -windowed -slide 2
# admin@ee-lte-1.codemowers.io ClusterDashboardLink cluster-resources-wall -> cluster-resources (15/15 charts)
# roadshow53: no Anafarg link resources
./anafarg-fb \
  -windowed \
  -slide 2 \
  -url https://anafarg.monitoring.ee-lte-1.codemowers.io/d/q2BXNPQXLFKRnAg3/

Links whose Ready is False are listed as skipped. Contexts that need an interactive login time out after 20 seconds; log in with kubectl first.

Under a Wayland session (WAYLAND_DISPLAY set) the same binary opens a fullscreen window instead; -output wayland|fbdev forces one, and -windowed starts in a borderless window. Drag anywhere to move the window, press F or double-click to toggle fullscreen, Left/Right to switch between rotated dashboards, 1–9 to pick the time range (15m, 1h, 3h, 6h, 12h, 24h, 7d, 30d, 90d), and Esc to quit. It stays pure Go: the Wayland protocol runs over the compositor socket (neurlang/wayland) with shared-memory buffers, no cgo. /dev/fb0 only shows when no desktop owns the screen, i.e. on a console.

./anafarg-fb -url https://anafarg.example/public/-/lab-status/ -windowed
# rotate between dashboards (1 minute each, progress bar at the bottom) and slide charts smoothly
./anafarg-fb -slide 2 \
  -url 'https://anafarg.example/dashboards/cluster-resources' \
  -url 'https://anafarg.example/dashboards/namespace-resources?var-namespace=monitoring'

When Anafarg is unreachable, the helper keeps the last view and marks it offline. The last data is also cached on disk for reboots.

Docker image

docker build -t anafarg:local .

The image is scratch with one static binary, running as UID 65532 on ports 8787 (main) and 8789 (display). CA trust is mounted at runtime by the cluster's admission policy, and tzdata is embedded for TIMEZONE.

Kubernetes deployment

These must already exist: the namespace, the Prometheus Operator, a Prometheus resource, the Passmower operator, the Ingress controller, the certificate issuer and the trust bundle.

The chart installs:

  • the CRDs (chart/crds)
  • the Deployment, Service, ServiceAccount and Ingress
  • the OIDCClient
  • the ServiceAccount's RBAC: create SubjectAccessReviews, watch namespaces and the Anafarg kinds, read Prometheus resources and monitors; the link key Secret is mounted, not read
  • the anafarg-viewer ClusterRole bound to system:authenticated
  • optionally, the bundled dashboards (provision.dashboards), the cluster-resources-wall link (provision.links) and the display Service

For a multi-user installation, configure ingestion labels and admission together with AUTH_MODE=rbac. See RBAC-aligned monitoring below for the label contract, exporter configuration, trust boundaries and checks.

The chart follows ../tyt: base values in chart/values.yaml, cluster settings in chart/values.ee-lte-1.yaml, and Skaffold supplies the complete image reference. imageRegistry optionally prefixes short image names. imagePullSecrets, env and secretEnv work as before.

docker login zot.registry.ee-lte-1.codemowers.io
skaffold run

The default target is ee-lte-1.codemowers.io, namespace monitoring, Helm release anafarg, with images under zot.registry.ee-lte-1.codemowers.io/laurivosandi/anafarg. No sourced env file or profile is required. Remove stale SKAFFOLD_DEFAULT_REPO overrides from your shell when using the full artifact registry path. The build uses Docker/BuildKit with OCI media types and no provenance/SBOM indexes. Skaffold applies CRDs server-side before upgrading the existing Helm release with --reset-values; deployments use the resolved image digest. skaffold dev removes its Helm release on exit.

With Helm directly:

helm upgrade --install anafarg ./chart \
  --kube-context ee-lte-1.codemowers.io \
  --namespace monitoring \
  -f chart/values.ee-lte-1.yaml \
  --set-string image="$IMAGE_REFERENCE" \
  --wait --timeout 5m

ingress.host defaults to the release name. The OIDCClient's URLs derive from it; oidc.useIngressRef=true needs Passmower ingress discovery. The chart reads Passmower's oidc-client-<release>-owner-secrets. Restart the Deployment after credentials rotate:

kubectl --context ee-lte-1.codemowers.io -n monitoring rollout restart deployment/anafarg

RBAC-aligned monitoring

The recommended setup is a platform-managed, queryable Prometheus behind Anafarg in rbac mode. Kubernetes decides which namespaces a person may read; Prometheus Operator and admission establish trustworthy series labels; Anafarg applies that person's scope to every query. Namespace ownership must be established before ingestion. A dashboard filter or a hidden legend label cannot establish it afterwards.

Layer Responsibility
Kubernetes RBAC and OIDC Identify the caller consistently with kube-apiserver; authorize dashboard access and list pods in each namespace.
Prometheus resource Choose which monitors/rules are accepted, enforce tenant namespace labels, declare trusted exceptions and a default scrape class.
Admission and namespace ownership Restrict monitor/rule configuration so tenant authors cannot bypass the label contract or use the shared scraper's privileges.
Exporters and monitor relabelings Describe the resource being measured: its real namespace, stable node identity, device and other dimensions.
Anafarg Check resource access, derive namespace scope with SubjectAccessReviews, and validate exact job and namespace matchers on every selector, including joins and label lookups.
Network access Keep unfiltered Prometheus access restricted to trusted backends and administrators; prevent a direct-query bypass around Anafarg.

Label contract: resource namespace, exporter job, stable node

For trusted platform exporters, namespace means the namespace of the resource described by the sample. It is not the namespace where the exporter Pod or monitor happens to run. For tenant-authored monitors, the operator stamps the monitor's own namespace onto their samples, regardless of what the target claims.

Series Expected labels Private dashboard visibility in rbac mode
Node CPU, RAM, disks; DRM GPU usage Stable node; no namespace Every viewer authorized to read that dashboard, even without namespace access.
kube-state-metrics Pod requests/limits The Pod's namespace and pod Viewers who may list pods in that namespace.
kube-state-metrics node information Stable node; no namespace Every authorized dashboard viewer. One exporter job can contain both node and namespaced series.
kubelet/cAdvisor container usage The workload's namespace, pod and container Viewers who may list pods in the workload namespace.
Application metrics from a monitor in shop Operator-enforced namespace="shop"; job owned by shop Viewers who may list pods in shop.
Platform recording rules Preserve the subject namespace for tenant results; deliberately omit it only for shared cluster results Determined by the stored output labels, just like raw metrics.

An absent or empty namespace is intentionally shared in private dashboard queries. Removing it from tenant data would publish that data to every dashboard viewer. Conversely, attaching namespace="kube-system" to node-exporter metrics would hide those node metrics from viewers without access to kube-system.

Keep job as the scrape-source identity. Give tenant jobs a namespace-qualified name such as shop/api; preserve established platform jobs such as kube-state-metrics and monitoring/node-exporter. Charts reference the discovered job exactly. Use node for a stable Kubernetes node name, instance for the scrape endpoint, and pod/container for workloads where they are genuine dimensions. Presentation may shorten names, but does not change authorization. Fix labels in the monitor, not through dashboard-specific query relabeling.

cluster and region are platform-controlled Prometheus external labels and routing context, not replacements for namespace authorization. They need not be attached to every local sample.

Prometheus Operator: enforcement and narrowly trusted exceptions

Set spec.enforcedNamespaceLabel: namespace. The operator enforces the originating namespace for selected tenant scrape objects and rules; excludedFromEnforcement exempts explicitly trusted objects. Its namespace-enforcement metric relabeling runs after scrape-class and monitor metric relabelings. See the Operator API reference for the installed version's fields and ordering.

Prefer named-object exceptions. A whole-namespace exception is appropriate only when administrators exclusively control all monitors and rules there. Creating a monitor in an exempt namespace is a privileged operation, even if the monitor itself is namespaced. Keep exemption lists, scrape-class trust lists and admission exemptions consistent; adding an ordinary application namespace to those lists grants ingestion authority, not just read access.

The following is a Prometheus.spec fragment. It exempts the node-exporter monitor used below; add separate, reviewed exceptions for the actual kube-state-metrics, kubelet and platform-rule objects in the installation. The scrape-class example treats monitoring and kube-system as administrator-owned target namespaces; adapt the list to the cluster.

enforcedNamespaceLabel: namespace
excludedFromEnforcement:
  - group: monitoring.coreos.com
    resource: podmonitors
    namespace: monitoring
    name: node-exporter
scrapeClasses:
  - name: namespaced-jobs
    default: true
    relabelings:
      - sourceLabels: [__meta_kubernetes_namespace]
        regex: monitoring|kube-system
        targetLabel: __tmp_trusted_namespace
        replacement: "true"
      - sourceLabels: [__tmp_trusted_namespace, __meta_kubernetes_namespace, job]
        separator: ";"
        regex: ";([^;]+);([^/;]+)"
        targetLabel: job
        replacement: "$1/$2"

The default class runs before monitor-specific relabelings. It prefixes jobs outside the trusted target namespaces and leaves already namespace-qualified jobs alone. This requires admission to keep tenant monitors in their own namespace and prevent them from replacing or removing the resulting job label or opting into another scrape class. Check the generated Prometheus configuration as well as the CR: the trust decision here uses discovered target namespace metadata, whereas enforcement exclusions identify the monitor or rule object.

Do not enable global overrideHonorLabels or ignoreNamespaceSelectors merely to protect tenant monitors without checking the trusted exporters: those global overrides can break the platform's cross-namespace scrapes and workload labels. Apply the tenant restrictions through admission and permit reviewed exceptions only for trusted objects.

Node-exporter and other platform exporters

Run node-exporter as a platform-owned DaemonSet. Its monitor should assign node from Kubernetes discovery and remove the exporter's own Pod metadata from target labels:

apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
  name: node-exporter
  namespace: monitoring
spec:
  namespaceSelector:
    matchNames:
      - kube-system
  attachMetadata:
    node: true
  selector:
    matchLabels:
      app.kubernetes.io/name: node-exporter
  podMetricsEndpoints:
    - port: web
      relabelings:
        - sourceLabels: [__meta_kubernetes_pod_node_name]
          targetLabel: node
        - action: labeldrop
          regex: namespace|pod|container

The matching enforcement exception above is necessary: otherwise the operator would add namespace="monitoring" to these samples after relabeling. Apply the same resource semantics to DRM and other node-wide exporters. Do not remove namespace labels from their workload-specific metrics.

For kube-state-metrics and kubelet/cAdvisor, remove conflicting exporter/target namespace, pod and container labels before scraping while retaining the labels carried by each workload metric. A blanket metric labeldrop would erase the workload boundary. If a trusted monitor needs honorLabels: true, that is a reviewed exception; tenant monitors must not choose it. The desired result is namespace="shop" on a Pod metric even when the exporter lives in kube-system, and no namespace on a node metric from that same exporter.

Review platform recording rules too. sum by (namespace) (...) preserves a tenant boundary; a precomputed sum(...) without it creates a shared cluster result. Preserve the source job or assign a documented platform recording-rule job when the result is intended for Anafarg. Authorization cannot reconstruct tenant ownership after a recording rule has discarded it.

Admission, monitor selection and tenant authority

Kubernetes RBAC controls who can create a monitor; it does not constrain fields inside that monitor. For any tenant-authored objects selected by the shared Prometheus, enforce these invariants on create and update, with a bound, denying admission policy:

  • Tenant ServiceMonitor/PodMonitor objects discover only their own namespace. Apply equivalent restrictions to ingress-based Probes and control static Probe targets and address rewriting separately.
  • Tenant monitors cannot enable honorLabels, select a different scrapeClass, assign Probe jobName, or create free-form ScrapeConfig objects.
  • Reserve job, namespace, cluster, region and the scrape class's trust markers. Reject direct and dynamic writes, labelmap, and labeldrop/labelkeep rules that could remove the protected job label. Validate both target and metric relabelings, Probe static labels and rule output labels.
  • Tenant monitors cannot read Prometheus-container credential files through bearerTokenFile or TLS file paths. Any permitted credentials must come from explicitly authorized Secret references.
  • Tenant-authored rules need additional controls: checking rules[].labels alone does not prevent an expression from synthesizing or replacing labels. Keep unreviewed tenant rules out of the shared Prometheus; use a constrained, reviewed rule-authoring path if they are needed.

Select monitor and rule namespaces explicitly. Namespace labels controlling shared-Prometheus selection must be administrator-managed. Do not allow tenant access to the Prometheus resource, its generated configuration Secrets, additional scrape configuration or trusted monitoring namespaces.

Namespace enforcement does not prove that the scraped data belongs to that namespace: a Probe or redirected scrape can fetch another system and stamp the author's namespace onto the result. Restrict scrape destinations and credential use along with network reach. Fully untrusted sandbox namespaces should not contribute their own monitors or rules to a platform Prometheus with cluster-wide discovery and network access. The ../kube configuration excludes namespaces labelled codemowers.io/sandbox; namespace-scoped Anafarg kinds and tenant-run Prometheus integration remain planned.

The reference implementation is the Prometheus template, node-exporter monitor, and monitor-namespace-integrity policy and binding. It uses one trustedMonitorNamespaces list for the three trust decisions. The current policy checks reserved field writes, but does not yet reject every job-removing labeldrop/labelkeep configuration or inspect rule expressions. The invariants above describe the intended configuration; the reference policy is not a complete isolation boundary for hostile monitor authors.

Viewer RBAC, sharing and query access

Use AUTH_MODE=rbac and configure username/group claims and prefixes to match kube-apiserver. A verified login alone must not grant namespace data. The shipped viewer role grants access to administrator-installed dashboards/charts; ordinary namespace RoleBindings determine where each person may list pods. Anafarg's ServiceAccount can query Prometheus and submit SubjectAccessReviews, but those privileges never stand in for the caller's permissions.

For a viewer allowed in shop, each private-chart selector includes the exact job and namespace=~"|shop": shop plus deliberately shared series with no namespace. Every selector in joins and derived expressions is checked before querying; authorization also runs before cache hits. A cluster-wide list pods grant removes namespace filtering. Dashboard variables only narrow this scope. Monitor get is an additional gate for Explore, not a prerequisite for viewing an administrator-published dashboard.

Namespace-bounded dashboard links are stricter: they exclude the empty namespace alternative, and charts whose families lack the namespace label are Forbidden and are not queried. A namespace administrator's DashboardLink cannot publish node-wide charts. A ClusterDashboardLink with scope: {all: true} deliberately publishes the dashboard's unfiltered data. Review publication independently of login and read roles; see sharing.

Keep the raw Prometheus API private to trusted backends and administrators, with NetworkPolicies admitting Anafarg and the required scraper traffic. OIDC in front of Prometheus authenticates a user but does not apply Anafarg's namespace scope. An ordinary viewer with direct, unfiltered Prometheus access can bypass that scope. The Prometheus security model treats HTTP query access as access to the stored time series. Likewise, restrict unfiltered federation/Thanos endpoints and Kubernetes proxy/exec/port-forward privileges that would provide equivalent access.

Before treating an installation as RBAC-aligned, check stored series and actual authorization behavior:

  1. Node metrics have the expected node and job, with no exporter-Pod namespace. Workload metrics from trusted exporters retain their real namespace.
  2. A tenant target attempting to emit namespace="another-team" is ingested under its own namespace. Attempts to bypass job identity, scrape class or destination restrictions are rejected.
  3. A user with list pods only in shop sees shop workload metrics and shared node metrics, but no other namespace's samples or label values. Use the exact OIDC username/groups when checking SubjectAccessReviews or kubectl auth can-i --as=....
  4. A namespace-scoped link shows only that namespace and does not query node-only families. A viewer cannot widen either scope through URL variables, splitting, aggregation or joins.
  5. Missing enforcement is visible in Anafarg's catalog warning; it must be resolved for a tenant-authored shared-scrape setup. Discovery that cannot read namespace enforcement fails closed for scoped queries. A normal rbac deployment must have Kubernetes access; oidc, anonymous and local -no-kube demos do not provide per-namespace viewer isolation.

Runtime configuration

Setting Purpose
AUTH_MODE / -auth-mode rbac (default), oidc (any login reads everything) or anonymous
OIDC_IDP_URI, OIDC_CLIENT_ID, OIDC_CLIENT_SECRET, OIDC_CLIENT_URI, OIDC_AVAILABLE_SCOPES Passmower client; the callback is OIDC_CLIENT_URI/auth/callback unless OIDC_REDIRECT_URI is set
ANAFARG_AUDIENCE, ALLOWED_CLIENT_IDS Bearer tokens from embedders: required audience (default: the app URL), accepted clients
ALLOWED_ORIGINS Origins allowed to call the API from browsers (Driftmower UI)
KUBERNETES_USERNAME_CLAIM, _USERNAME_PREFIX, _GROUPS_CLAIM, _GROUPS_PREFIX Must match kube-apiserver's OIDC flags; defaults as in Driftmower (sub, <issuer>#, groups, none)
SESSION_KEY Optional session key material; otherwise derived from the client secret
DEFAULT_PROMETHEUS Prometheus for resources without prometheusRef (default monitoring/prometheus)
PROMETHEUS_URLS namespace/name=url overrides, comma-separated
RESOURCES_DIR, KUBECONFIG, KUBE_CONTEXT, KUBERNETES_ENABLED Development: file resources, kubeconfig, or no Kubernetes
LISTEN, DISPLAY_LISTEN, DISPLAY_TLS_MODE, DISPLAY_TLS_CERT, DISPLAY_TLS_KEY Listeners
MAX_SERIES, MAX_POINTS, MAX_RANGE (default 90d), TIMEZONE Query limits and rendering timezone

Spike

uv venv .venv
uv pip install --python .venv/bin/python --require-hashes -r spike/requirements.lock
.venv/bin/python -m unittest discover -s spike -p 'test_*.py'
python3 spike/server.py --auth-mode anonymous --prometheus http://127.0.0.1:19090

See spike/README.md for discovery heuristics and metadata-join experiments.

The optional PROMETHEUS_EXTERNAL_URL environment variable (or -prometheus-external-url) sets the browser-facing URL of the default Prometheus. For ee-lte-1 this is https://prom.ee-lte-1.codemowers.io, configured in chart/values.ee-lte-1.yaml. It enables source and generated-query links in the explorer; query transport still comes from prometheusRef. Links open in a new tab. Unset it to omit them.

Anafarg follows Driftmower’s typography and component styling while keeping its navbar at the top. Inter 4.1 is shared by the interface, SVG charts and pure-Go raster output; code uses JetBrains Mono 2.304. Fonts are self-hosted, bundled under internal/typeface, and ship with their SIL Open Font Licenses. There are no runtime font/CDN dependencies or frontend build step.

YAML resources and configuration use two-space block style. Run make fmt-yaml to format them and make lint-yaml to check; Skaffold checks before builds and deployments. The native Go formatter retains comments and anchors. Helm templates are excluded because they contain Go-template expressions rather than plain YAML.

The chart resources under chart/files/ are authoritative. Schema changes are breaking: update Git manifests to the current schema and redeploy; Anafarg does not migrate old charts. Series use role for usage/cache/request/limit/capacity and read/write/receive/transmit semantics. make generate-schema updates the structural CRDs and browser capability metadata from Go types; make lint-schema checks them.

Historical data for idle charts

Charts can opt into a bounded historical fallback:

spec:
  noData:
    fallback: latest
    maxLookback: 7d

maxLookback defaults to 24h and accepts 1m through 30d (hours and whole days are supported); the installation's maximum range is an additional ceiling. Without this policy, existing empty-panel behavior remains unchanged. The four llama worker efficiency/latency charts enable a seven-day lookup, so an idle worker job does not make the whole llama dashboard unavailable.

An empty opted-in chart shows No data in the selected range and filters. Anafarg searches for the latest finite result of the actual chart queries, including rates and histogram quantiles, and reruns the chart over a window of the same duration ending there. The chart has a visible Historical banner and actual data timestamp. Other dashboard panels and the dashboard's selected time range do not move. Zero values are valid data and do not trigger fallback.

Every probe keeps the exact job, chart matches, selected variables and namespace access scope. Selected labels are never dropped merely because old series lack them. Missing current catalog families are discovered only for the declared, scoped sources within the lookback. Probes use standard PromQL subqueries and range functions; no experimental Prometheus functions are needed.

Lookup starts with recent windows, expands backward within the configured bound, then refines the latest occupied window. It has a 20-second evaluation deadline, at most 16 chart queries and normal engine series/sample limits; final timestamp refinement additionally allows at most 50,000 returned samples. Source discovery and query results are cached with their scoped selectors. Offset/@ selectors and all-jobs (job: '*') sources are not supported for this opt-in policy. Query failures, partial-result warnings and permission failures remain errors; they are never interpreted as empty data or filled with old values.

About

Grafana for Prometheus native environments

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages