Database monitoring on Kubernetes
On Kubernetes, the agent monitors the databases running in your cluster. The flow is the same as on a virtual machine, with two Kubernetes differences. Credentials come from a Kubernetes Secret, and database monitoring needs managed mode. For the general model, see the Database monitoring overview.
One monitor per cluster
Section titled “One monitor per cluster”On Kubernetes, one collector in the cluster monitors your databases. Each database is monitored once for the whole cluster, not once per node.
Discovery prefills the endpoint
Section titled “Discovery prefills the endpoint”The agent finds databases running in your cluster. It prefills the wizard with their in-cluster address, <service>.<namespace>.svc.cluster.local:<port>. Use this address. It is the name your applications connect to, so the database’s metrics and traces line up. Databases outside the cluster are not discovered, so add them manually.
Managed mode is required
Section titled “Managed mode is required”Database monitoring needs the agent in managed mode. On Kubernetes, use the “Configure databases” action on the agent. If the agent is still in manual mode, it prompts you to switch. See the configuration model.
Available coverages
Section titled “Available coverages”On Kubernetes, the agent collects database metrics and query coverages: standard metrics, query performance, locks, and query logs. Database log coverages are available on a virtual machine, not on Kubernetes. See Engines and coverages.
Provide credentials with a Kubernetes Secret
Section titled “Provide credentials with a Kubernetes Secret”Credentials use an environment reference backed by a Kubernetes Secret you provide. Set it up before you configure any database, because the collector reads the Secret when its pod starts.
-
Create a Kubernetes Secret with a key of the form
KM_SECRET_<name>for each database credential. For example, a keyKM_SECRET_postgresqlholding the monitoring user’s password. -
Point the Helm release at the Secret with the
dbMonitoring.secretNamevalue, and upgrade the release. The cluster collector then reads the Secret throughenvFrom. -
Configure the database in the wizard, referencing the key by name. The password stays in the cluster and never reaches KloudMate.
Worked example: PostgreSQL
Section titled “Worked example: PostgreSQL”-
Create a monitoring role in PostgreSQL and grant it the built-in
pg_monitorrole: -
Store the password in a Kubernetes Secret under
KM_SECRET_postgresqland setdbMonitoring.secretName, as above. -
Configure PostgreSQL in the wizard with the Service DNS endpoint (prefilled from discovery), the
kmmonitoruser, and an environment reference to the secret. Choose the coverages you want, such as standard metrics, locks, and query performance. -
Enable query performance prerequisites, if used. Query performance reads
pg_stat_statements. Add it toshared_preload_librariesand create the extension, which needs a PostgreSQL restart:
After you apply the configuration, the cluster collector starts collecting from PostgreSQL. Its metrics carry the same database identity as the application spans that hit it.