Skip to main content

Monitoring and signals

almad exposes health and metrics endpoints on two configurable listeners:

  • /healthz and /readyz - liveness and readiness, on the address ALMA_DIAG_LISTEN binds. It has no default, so the endpoint is off until you set one. This page uses :3000 throughout.
  • /metrics - Prometheus exposition format, on the address ALMA_METRICS_LISTEN binds. An address given without a port gets :3081. While the variable is unset, the diagnostic listener serves /metrics itself, so binding only ALMA_DIAG_LISTEN still exposes metrics.

The diagnostic port is what your load balancer health-checks. The metrics port is what Prometheus scrapes. Both should stay on private networks.

almad can also push metrics, logs and traces to an OpenTelemetry Collector instead of, or as well as, being scraped. See OpenTelemetry export.

Scrape configuration​

Enable both endpoints in /etc/almaforge/almad.env:

/etc/almaforge/almad.env
ALMA_DIAG_LISTEN=0.0.0.0:3000
ALMA_METRICS_LISTEN=0.0.0.0:3081

The metrics listener serves mutual TLS or plaintext, with nothing in between. To require a certificate from the scraper, set all three of these next to ALMA_METRICS_LISTEN:

env
ALMA_METRICS_TLS_CERT=/etc/almaforge/metrics.crt
ALMA_METRICS_TLS_KEY=/etc/almaforge/metrics.key
ALMA_METRICS_CLIENT_CA=/etc/almaforge/scraper-ca.crt

Setting only some of them fails at startup rather than quietly serving plaintext. Prometheus then needs a tls_config presenting a certificate that ALMA_METRICS_CLIENT_CA issued. Full descriptions are in the environment reference.

Add each almad metrics listener to your Prometheus targets:

prometheus-static.yaml:

examples/monitoring/prometheus-static.yaml
# Static Prometheus scrape targets for the almad metrics endpoint.
# Use hostnames reachable from your Prometheus server.
- job_name: almad
static_configs:
- targets:
- 'almaforge-1.internal:3081'
- 'almaforge-2.internal:3081'
- 'almaforge-3.internal:3081'

On Kubernetes, enable integrations.prometheus.serviceMonitor.enabled: true in the cluster or agent Helm chart to create a ServiceMonitor for the Prometheus operator.

For the full metric catalog, see the Metrics Reference.

OpenTelemetry export​

almad exports metrics, logs and traces over OTLP to an OpenTelemetry Collector, or to any backend that accepts OTLP directly. It is configured with the standard OpenTelemetry environment variables, the same ones every OpenTelemetry SDK reads, so a collector's own documentation applies unchanged.

Nothing is exported until you name an endpoint. Point every signal at one collector:

/etc/almaforge/almad.env
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318

almad appends /v1/metrics, /v1/logs and /v1/traces to that base URL. To use gRPC instead of OTLP/HTTP, add OTEL_EXPORTER_OTLP_PROTOCOL=grpc and point at the gRPC port, usually 4317. Use https:// whenever the collector sits across a network you do not trust.

Send each signal to its own backend​

Each signal can have its own endpoint, protocol, headers and certificates. A signal endpoint is used exactly as written, path included, and only that signal turns on:

/etc/almaforge/almad.env
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://tempo.example.com/v1/traces
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=https://mimir.example.com/otlp/v1/metrics
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=https://loki.example.com/otlp/v1/logs
OTEL_EXPORTER_OTLP_LOGS_HEADERS=authorization=Bearer <token>

To switch one signal off while the shared endpoint stays set, use OTEL_TRACES_EXPORTER=none, OTEL_METRICS_EXPORTER=none or OTEL_LOGS_EXPORTER=none. Each signal goes to one destination. To send a signal to two backends, or to filter it on the way, point almad at a collector and route it there.

Supported variables​

VariableDefaultWhat it controls
OTEL_EXPORTER_OTLP_ENDPOINTnoneBase URL for every signal. Setting it turns export on.
OTEL_EXPORTER_OTLP_<SIGNAL>_ENDPOINTnoneFull URL for one signal, used as written. Setting it turns that signal on.
OTEL_EXPORTER_OTLP_[<SIGNAL>_]PROTOCOLhttp/protobufhttp/protobuf or grpc.
OTEL_<SIGNAL>_EXPORTERotlpotlp or none.
OTEL_EXPORTER_OTLP_[<SIGNAL>_]HEADERSnoneRequest headers, as key=value pairs separated by commas, for collector authentication.
OTEL_EXPORTER_OTLP_[<SIGNAL>_]CERTIFICATEsystem CA storeCA bundle that verifies an https:// collector.
OTEL_EXPORTER_OTLP_[<SIGNAL>_]CLIENT_CERTIFICATE, ..._CLIENT_KEYnoneClient certificate for a collector that requires mutual TLS.
OTEL_EXPORTER_OTLP_[<SIGNAL>_]COMPRESSIONnonegzip to compress exports.
OTEL_EXPORTER_OTLP_[<SIGNAL>_]TIMEOUT10000Export timeout in milliseconds.
OTEL_METRIC_EXPORT_INTERVAL60000Milliseconds between metric pushes.
OTEL_BLRP_MAX_QUEUE_SIZE, OTEL_BLRP_MAX_EXPORT_BATCH_SIZE, OTEL_BLRP_SCHEDULE_DELAY2048, 512, 1000Log record queue size, batch size and milliseconds between batches.
OTEL_BSP_MAX_QUEUE_SIZE, OTEL_BSP_MAX_EXPORT_BATCH_SIZE, OTEL_BSP_SCHEDULE_DELAY2048, 512, 5000The same for spans.
OTEL_TRACES_SAMPLER, OTEL_TRACES_SAMPLER_ARGparentbased_always_onWhich traces are recorded, for example parentbased_traceidratio with an argument of 0.1.
OTEL_SERVICE_NAME, OTEL_RESOURCE_ATTRIBUTESsee Resource attributesOverride or add resource attributes.

<SIGNAL> is TRACES, METRICS or LOGS, and a signal variable wins over its shared form. An endpoint that is not an http:// or https:// URL, an exporter other than otlp or none, and a protocol other than the two listed all stop almad at startup, rather than sending to the wrong place.

Metrics​

Every 60 seconds, or as often as OTEL_METRIC_EXPORT_INTERVAL says, almad pushes the metrics that /metrics serves, with the same names and labels. Dashboards and alerts written against a Prometheus scrape work on the pushed data without changes. A counter arrives as a monotonic sum, and a gauge and a histogram keep their types.

The push is independent of ALMA_METRICS_LISTEN. You can push only, scrape only, or do both.

Logs​

Every record at ALMA_LOG_LEVEL or above is exported. It is also still written to ALMA_LOG_OUTPUT as before, so journalctl keeps working. The message becomes the record body, the level becomes the severity, and fields keep their names, except for the ones in this table, which take their OpenTelemetry names:

Local log fieldOTLP attribute
componentalma.component
workeralma.worker
errorexception.message
stack, on ERROR records onlyexception.stacktrace
caller, at debug level onlycode.file.path, code.line.number and code.function.name, on every record

Nested fields use dotted names, such as request.addr. Credentials are redacted from exported records the same way they are from the local log.

Traces​

almad exports the spans it records. By default every new trace is recorded. A request that arrives with its caller's sampling decision keeps that decision, so a trace is never cut off partway through almad. Set OTEL_TRACES_SAMPLER to record fewer.

Resource attributes​

Every exported metric, log record and span identifies its source with standard OpenTelemetry resource attributes:

AttributeValue
service.namealmad
service.versionThe almad version
host.nameThe node name, ALMA_NODE_NAME when set, otherwise the OS hostname
host.idThe machine ID, when the host has one
host.archamd64 or arm64
os.typelinux or darwin
process.pidThe almad process ID

OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES are applied last, so they can rename the service or add attributes such as deployment.environment.name=prod. Spans also carry alma.version, alma.host.name, alma.host.uuid and alma.process.id.

When the collector is down​

A failed export is logged as a warning with component=otel in the local log only, never exported itself, and almad keeps running. Metrics are cumulative, so the next successful push carries the current totals and only the samples in between are lost. Log records are held in a bounded in-memory queue, so a long outage drops the oldest records rather than growing memory. Spans are queued the same way and dropped once their queue is full. The OTEL_BLRP_* and OTEL_BSP_* variables size those queues.

Signals to watch​

These are the metrics most likely to catch a problem before users do:

SignalMetricWhat it means
Storage backend write latencybackend_write_seconds (p99)State backend (etcd, PostgreSQL, DynamoDB, or Firestore) is the bottleneck
Host certificate generation pressureauth_generate_requests_throttled_totalAuth is throttling host and service certificate generation
Audit emit failuresaudit_failed_emit_eventsAudit event emission is failing. Investigations may have gaps
Active SSH sessionsproxy_ssh_sessions_totalProxy load envelope
File-descriptor pressureprocess_open_fds / process_max_fdsProxy or Auth is close to running out of sockets
Process CPUrate(process_cpu_seconds_total[5m])Sustained pressure means add replicas or bigger nodes
Recording upload latencys3_requests_seconds, gcs_event_storage_uploads_secondsSession recordings backing up at the object store

See the Scaling Guide for the full breakdown of what each signal means and how to act on it.

Alerts that earn their keep​

Wire these as a starting set. Tune the thresholds for your shape:

  • /readyz returning non-200 for more than 30 seconds. The process exists but is not serving. Page on-call.
  • audit_failed_emit_events rate above zero for more than 5 minutes. Audit event delivery is failing. Page on-call, preserve daemon logs for the affected interval, and investigate missing records. Document any audit gap and report it under your audit policy.
  • auth_generate_requests_throttled_total rate sustained above zero. Host and service certificate generation is being throttled. Check Auth load and state backend latency before resizing Auth.
  • LockCreate events (from your audit sink, not Prometheus). Every lock is a security event worth a notification.
  • process_open_fds / process_max_fds above 0.7 for any replica. Resize before the limit is hit.

For audit event codes and fields, see Audit Events.

Where to look first​

When an alert fires:

  1. Check /readyz on every replica. A non-200 response identifies process state, not the failed dependency.
  2. Check journalctl -u almad -n 200 on the affected host for the exact error.
  3. Cross-reference with the Troubleshooting guide for the failing surface.
  4. Check the state backend's own health (etcd member-list, Postgres primary status, DynamoDB throttling metrics).

References​