Add ClickHouse User and Password variables for external databases

Description

PMM documentation shows the following available variable to connect to an external Clickhouse database:

The Altinity operator does not allow the default user to access from outside of the cluster.

You can find this information below:

If no user and password is set, pmm-managed.log shows the following error:

I've tried adding the user and password to the variable PERCONA_TEST_PMM_CLICKHOUSE_ADDR and obtained the below error:

From PMM container I can access the Clickhouse database using the credentilas:

Please add the following variables to allow connecting to an external Clickhouse:

Dev notes:
Investigate possibility to set default credentials for internal Clickhouse and handle it during upgrade.

How to test

  • set up an external ClickHouse server

  • create a ClickHouse user with a password (follow the recommendations in the doc section below)

  • launch a PMM Server while providing the environment variables allowing it to connect to an external ClickHouse database

    • -e PMM_CLICKHOUSE_USER=<username> and -e PMM_CLICKHOUSE_PASSWORD=<password>, -e PMM_DISABLE_BUILTIN_CLICKHOUSE=1 and others (check the documentation)

  • add a database to monitoring

  • verify that the connection to ClickHouse server is successfully established

  • verify that you can see metrics collected from the database

  • verify that you don’t see Clickhouse user’s password in clear text format in the following logs:

    • pmm-managed.log

    • qan-api2.log

  • verify that telemetry is functional (the metrics are being collected from Clickhouse)

  • verify the you can run queries against ClickHouse database (pmm.metrics) using the Grafana ClickHouse Datasource from the Explore menu (it is now password-protected)

  • run a sanity check of dashboards in PMM, especially those that make use of ClickHouse metrics

How to document

PMM-13171 introduces a few security enhancements to the ClickHouse Server, which contributes to a better security posture of PMM Server.

  1. Two environment variables were added allowing to change credential for an external ClickHouse server connection:

  • PMM_CLICKHOUSE_USER: <username>

  • PMM_CLICKHOUSE_PASSWORD: <password>

  1. The password security was hardened by:

    1. disabling empty passwords

    2. disabling plain text passwords

    3. preventing the implicit creation of users without passwords

For optimal security we recommend to generate random user passwords and hash them using the SHA256 function:

For more details refer to ClickHouse’s User Settings documentation.

Smart Checklist

hide

Activity

Show:

Details

Assignee

Reporter

Priority

Labels

Needs QA

Yes

Needs Doc

Yes

Planned Version/s

Fix versions

Story Points

Sprint

Smart Checklist Progress

Start date

Smart Checklist

Created June 14, 2024 at 11:25 PM
Updated 4 days ago