Grafana data source TLS: limits of CA certificate reloads and DNS caching without restart
0 reputation · 24 Mar 2023, 07:20 UTC
0 reputation · 24 Mar 2023, 07:20 UTC
I am operating Grafana (assume a current LTS release) with several provisioned data sources (Prometheus and Loki) that use TLS with a custom CA supplied via tls_ca. I want to understand the operational limits of certificate validation and DNS resolution for these connections, specifically around rotation and failover scenarios.
My understanding is that Grafana validates data source certificates against the system trust store unless tls_ca is set, and that hostname resolution depends on the host OS resolver plus Go HTTP client connection reuse. Two behaviors are unclear to me: whether updating the CA file referenced by tls_ca takes effect without restarting Grafana or re-saving the data source, and how long stale DNS answers can persist for a data source hostname after the record changes, given TCP connection reuse.
tls_ca file for existing data sources without a full restart?32775 reputation · 24 Mar 2023, 10:22 UTC
Below are the confirmed behaviors for a current Grafana LTS release, based on the Go runtime it uses.
Grafana does not monitor the tls_ca file for changes. The CA is loaded when the data source is first provisioned or when it is saved via the UI or API. Updating the underlying file without re-saving the data source or restarting Grafana has no effect on active connections.
Grafana's HTTP client relies on the OS resolver and Go's net/http package, which does not honor DNS TTLs for pooled connections. A connection that resolves a hostname once may reuse the resulting IP address for the duration of the idle-connection timeout (default 90s), even if the DNS record changes. The timeout is configurable via connection_idle_timeout in grafana.ini.
Grafana does not perform CRL or OCSP revocation checking for data source TLS handshakes. It only verifies the certificate chain against the supplied CA and checks the validity period. If revocation status is critical, it must be handled externally (e.g., via a proxy or CA configuration that enforces online checks).
tls_ca field via the UI or API, then restart Grafana or re-save the data source. Confirm the new certificate chain is accepted by checking Grafana logs for TLS handshake entries.(Note: if you have set a custom connection_idle_timeout in grafana.ini, its value will affect how long stale DNS answers can persist.)
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.