AI AdminPanel Documentation

Prometheus Metrics

If you already run Prometheus and Grafana, the panel can join them. GET /api/metrics serves host, service and panel gauges in the Prometheus text format, so your existing dashboards and alerts can watch the panel like any other server.

The endpoint is off by default. While it is off, /api/metrics answers 404.

Turn it on

  1. Open Settings → System → Prometheus metrics.
  2. Click Generate token. Copy the token now: it is shown once. The panel keeps only a fingerprint (SHA-256) of it, the same way it stores admin API keys, so a lost token is replaced, not recovered.
  3. Switch on Enable the metrics endpoint. The next scrape is served; no restart.

Replace token issues a new token and stops the old one at once. Use it when a token may have leaked or when someone who knew it leaves. Both the switch and every token change are recorded in the audit log as settings changes; the token itself is never logged.

Configure Prometheus

Save the token in a file on your Prometheus host that only Prometheus can read:

install -m 600 -o prometheus -g prometheus /dev/null /etc/prometheus/aap-scrape-token
printf '%s' 'PASTE-THE-TOKEN-HERE' > /etc/prometheus/aap-scrape-token

Then add a scrape job. The Settings page shows this block with your panel's address filled in:

scrape_configs:
  - job_name: ai-admin-panel
    scheme: https
    metrics_path: /api/metrics
    authorization:
      type: Bearer
      credentials_file: /etc/prometheus/aap-scrape-token
    static_configs:
      - targets: ['panel.example.com']

Reload Prometheus and check Status → Targets: the ai-admin-panel target should be UP. A scrape interval of 30 seconds or more matches how often the panel samples; a shorter one returns the same values twice.

The token only works in the Authorization: Bearer header. A token in the URL (?token=…) is refused, because URLs end up in proxy and access logs.

What the endpoint answers

ResponseWhen
200 with the metricsThe endpoint is on and the request carries the current token.
401The token is missing, wrong, replaced, or sent another way than Authorization: Bearer. An admin's sign-in session or API key does not open it either: only the scrape token does.
404The endpoint is switched off.
503The panel could not read its settings (for example, the database is down).

Metrics

Every series is a gauge, named aap_*.

MetricLabelsMeaning
aap_up1 while the panel answers scrapes.
aap_build_infoversionThe panel's version; the value is always 1.
aap_host_cpu_usage_percentHost CPU in use, 0–100.
aap_host_memory_usage_percentHost RAM in use, 0–100.
aap_host_disk_usage_percentDisk in use on the panel's filesystem, 0–100.
aap_panel_goroutinesGoroutines in the panel process.
aap_host_metrics_last_sample_timestamp_secondsUnix time of the newest host sample.
aap_servicesstatusNumber of services in each status.
aap_service_statusservice_id, status1 for a service's current status, 0 for the others.
aap_service_cpu_usage_percentservice_idCurrent verified single-container CPU; 100 means one logical core.
aap_service_memory_usage_percentservice_idCurrent verified single-container raw Docker memory usage/container limit.

The per-service CPU and memory percentage families are emitted only for verified single-container services. A multi-container service exposes separate aap_container_* gauges with opaque service_id and full container_id labels: CPU percentage (100 is one logical core), raw memory percentage, memory usage bytes, memory limit bytes and actual last-sample timestamp seconds. Missing or older than one minute observations are omitted, not converted to 0. No whole-service multi-container percentage is invented. Current-generation repository fences run on each scrape before service usage is released; the sampler inventory still supplies status/count labels. Host/system gauges keep their existing behavior. No customer, owner generation, organization, container name or customer-selected service name is exported as a label.

A scrape copies one bounded set of retained newest observations before projecting service usage. Concurrent collection cannot inflate that retained set. Service usage is sealed before one final database snapshot checks the retained capture identities together. A stale or malformed retained capture loses only its own usage samples; verified siblings remain. A metric family's HELP/TYPE header appears once, only when that family has an included sample. A missing, unreadable or malformed batch source withholds all unverifiable service usage, while host gauges and the inventory's status/count families retain their existing behavior. It never turns missing usage into zero. Newest-point reads do not copy the retained history.

The statuses are pending, deploying, running, stopped, error, removing and degraded. They are always present, so an alert on status="error" has a series to watch before the first failure.

Values come from the samples the panel already takes (host every 30 seconds, services every 15 seconds). A scrape adds no Docker stats calls. It reads settings and rechecks current service capture identity in the repository before releasing qualified service usage. A value the panel has not sampled yet (just after a restart, or a service that has just started) is left out rather than reported as 0.

Find the service behind a service_id

The service_id is the ID the panel uses for the service. To see which service it is, open https://<your panel>/services/<service_id> while signed in as an admin, or search for the ID on the Services page. In Grafana you can turn the label into a link with a data link such as https://panel.example.com/services/${__field.labels.service_id}.

What it does not include

The export is for the operator who runs the panel. It carries no customer, organization, reseller or owner label. A service is identified only by its service_id, never by its name: names are free text that customers choose, and your Prometheus may keep them longer, and show them to more people, than the panel does. Bundled internal services (such as the shared Ollama) are left out, as on the Services page.

Shipping a bundled Prometheus or Loki stack is not part of this feature.

Example alerts

groups:
  - name: ai-admin-panel
    rules:
      - alert: AAPServiceInError
        expr: aap_service_status{status="error"} == 1
        for: 5m
        annotations:
          summary: "Service {{ $labels.service_id }} is in error"
      - alert: AAPDiskAlmostFull
        expr: aap_host_disk_usage_percent > 90
        for: 10m
      - alert: AAPMetricsStale
        expr: time() - aap_host_metrics_last_sample_timestamp_seconds > 120
        for: 5m