Skip to content

Database credentials

Database monitoring connects as a monitoring user, so the agent needs that user’s password. You can keep the password on the host and out of KloudMate, or type it into the wizard. Monitoring from eBPF and application traces needs no credentials. For the general flow, see the Database monitoring overview.

The Password field in the wizard has two modes. MongoDB Atlas uses the same two modes for its Atlas private key.

The agent reads the password from an environment variable on its host. KloudMate stores only the variable’s name, so the password never leaves the host. Use this mode in production.

The field shows the variable to create. The agent handles escaping, so passwords containing @, :, /, ?, #, or spaces work without encoding.

You type the password into the wizard, and it’s written into the agent’s configuration in plain text. Use this only for testing.

When you edit a database with an entered password, the field shows it masked. Leave it empty to keep the stored password, or type a new one to replace it. A stored password can be replaced but not cleared, so switch to Environment variable to remove it.

The variable name is KM_SECRET_, then the instance name or, without one, the engine, then the field name. It’s uppercased, and any character other than a letter, digit, or underscore becomes _.

Instance nameEngineVariable
(none)PostgreSQLKM_SECRET_POSTGRESQL_PASSWORD
Orders DBPostgreSQLKM_SECRET_ORDERS_DB_PASSWORD
(none)MongoDB AtlasKM_SECRET_MONGODBATLAS_PRIVATE_KEY

Set the Instance name before you create the variable, because it changes the name. Once a database is saved, renaming it keeps the variable it already uses.

Databases saved before this naming scheme may use an older variable such as KM_SECRET_postgresql. It keeps working.

The agent must see the variable in its own environment, not only in your shell.

  • Linux (systemd): add KM_SECRET_POSTGRESQL_PASSWORD=YOUR_PASSWORD to an EnvironmentFile referenced by the agent’s service, or to a drop-in with Environment=, then restart the agent. This also suits a password written by an external secret manager.
  • Windows: set it as a system environment variable, then restart the KloudMate Agent service.
  • Docker: pass it to the agent container with -e or an env file.
  • Kubernetes: put it in a Kubernetes Secret and set dbMonitoring.secretName. See Database monitoring on Kubernetes.

With Environment variable, change the password on the database, update the variable, and restart the agent, or the collector pod on Kubernetes. The configuration in KloudMate doesn’t change.

With Enter value, change the password on the database, then edit the database in the wizard and type the new password.

The Advanced YAML override has no secret storage. Anything you type there, including a password, is written into the agent configuration in plain text. Keep credentials in the Password field.

Whichever mode you use, the monitoring user needs the grants for the coverages you turn on. The wizard shows them under Setup required, and each engine’s page lists them. The agent doesn’t test the password or grants when you save. A mistake shows up as errors in the agent log and empty tabs in the Databases module. See Engines and coverages.