Setup monitoring

Backend provides 2 endpoints with Prometheus compatible metrics:

  • GET /monitoring/metrics - server metrics, like number of requests per path and response status, CPU and RAM usage, and so on.

Example
# Generated in CI
  • GET /monitoring/stats - usage statistics, like number of users, namespaces, HWMs.

Example
# Generated in CI

These endpoints are enabled and configured using settings below:

pydantic model horizon.backend.settings.server.monitoring.MonitoringSettings

Monitoring Settings.

See starlette-exporter documentation.

Note

You can pass here any extra option supported by starlette-exporter, even if it is not mentioned in documentation.

Examples

HORIZON__SERVER__MONITORING__ENABLED=True
HORIZON__SERVER__MONITORING__SKIP_PATHS=["/some/path"]
HORIZON__SERVER__MONITORING__SKIP_METHODS=["OPTIONS"]
Fields:
field enabled: bool = True

Set to True to enable middleware

field labels: Dict[str, str] [Optional]

Custom labels added to all metrics, e.g. {"instance": "production"}

field skip_paths: Set[str] [Optional]

Custom paths should be skipped from metrics, like /some/endpoint

field skip_methods: Set[str] = {'OPTIONS'}

HTTP methods which should be excluded from metrics

field group_paths: bool = True

If True (recommended), add request path to metrics literally as described in OpenAPI schema, e.g. /namespaces/{id}, without substitution with path real values.

If False, all real request paths to metrics, e.g. /namespaces/123.

field filter_unhandled_paths: bool = True

If True, add metrics for paths only mentioned in OpenAPI schema.

If False, add all requested paths to metrics.

class Config