Skip to main content

API keys

Without keys, the server has no authentication. It then listens on 127.0.0.1 only. Before you open it to other machines, turn on keys and TLS.
Make a key. The line for the key file goes to stdout; the key goes to stderr, and only this once. The file holds a SHA-256 of the key, not the key.
Start the server with the key file:
A request with no key gets 401. With the key it works:
  • A key has the right read (queries and exports), write (OTLP, scores, deletes, purge), or both. An app that sends traces needs write; a dashboard needs read.
  • A key with no right for a route gets 403.
  • The server reads the key file every 2 s. A new line works, and a removed line stops working, within about 2 s, with no restart. To revoke a key, delete its line.
  • With one store (--dir), keys belong to the tenant default.
  • OpenTelemetry SDKs send the key with OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer%20mgp_..." (OpenTelemetry guide).

TLS

--tls-cert and --tls-key turn on TLS on both ports. Give the certificate chain (PEM, the server’s certificate first) and its private key (PEM). For a test, make a CA and a certificate for localhost with openssl. The server certificate must not be a CA (basicConstraints=CA:FALSE), or TLS clients refuse it:
Start the server with keys and TLS:
  • TLS 1.2 and 1.3 (rustls). The HTTP port then speaks HTTPS only.
  • A new certificate needs a restart. At start the server prints the end date of the certificate. When the server’s own certificate (the first of the file) is not valid now, the server does not start (exit code 1); another certificate of the file that is not valid now only gets a warning with its place in the file. One that ends within 30 days gets a warning at start and once a day (for a certificate of under 90 days: within a third of its time). After the end, an error line every hour.
  • A failed TLS handshake is logged: the first at once, then at most one line a minute with a count and the reason (for example received fatal alert: CertificateExpired). If your clients cannot connect, look there.
  • No client certificates (mTLS).
  • A proxy that ends TLS (nginx, Caddy, a cloud load balancer) works too: run the server without --tls-* on a private address behind it, and pass the authorization header on. For gRPC, the proxy must speak HTTP/2 to the server.
  • To accept connections from other machines: --http-addr 0.0.0.0:4318 --grpc-addr 0.0.0.0:4317.