ClickHouse and custom reports: configuration via pyrus-setup
Custom reports are designed to analyze exactly the metrics that matter to your company. They let you see not only the current status of tasks, but also the entire history of actions — this gives a much more complete picture than standard exports.
Learn more about the purpose and benefits of custom reports
The reporting engine runs on top of ClickHouse. All configuration operations are performed using a dedicated migrator, pyrus-setup. It runs as a one-off container via the docker-compose run --rm command.
1. Environment variables for the ClickHouse container
Please note: these variables take effect only on the very first launch, when the data folder (/var/lib/clickhouse, the pyrus_clickhouse_data volume) is still empty. If the database is already up, changing the variables has no effect.
| Variable | Value | Purpose |
|---|---|---|
CLICKHOUSE_USER | user name | the user to be created; |
CLICKHOUSE_PASSWORD | string | their password |
CLICKHOUSE_DB | database name | the database created at startup (in our case, public) |
CLICKHOUSE_DEFAULT_ACCESS_ | 0 / 1 | 1 — allow managing users and permissions via SQL |
clickhouse:
image: cr.yandex/crpl4n1nijtqddto2029/dev-pyrus-clickhouse:1.26.0
container_name: pyrus-clickhouse
environment:
- CLICKHOUSE_USER=default
- CLICKHOUSE_PASSWORD=default
- CLICKHOUSE_DB=public
- CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1
volumes:
- pyrus_clickhouse_data:/var/lib/clickhouse
- pyrus_clickhouse_logs:/var/log/clickhouse-server
networks:
- pyrus-backend
Creating users, granting permissions, and changing passwords are standard ClickHouse operations. Here are some useful links to the documentation:
- Users and passwords in
users.xml: https://clickhouse.com/docs/operations/settings/settings-users CREATE USER: https://clickhouse.com/docs/sql-reference/statements/create/userALTER USER(including for changing a password): https://clickhouse.com/docs/sql-reference/statements/alter/user- SQL-based access management: https://clickhouse.com/docs/operations/access-rights
If you change the password, don't forget to pass the new credentials to Pyrus. To do this, use the enable-report-engine command from the next section.
2. enable-report-engine — enabling and configuring
What the command does:
- saves the ClickHouse connection settings in the Pyrus configuration;
- brings the ClickHouse schema up to the current version (applies migrations);
- enables the
ReportEnginefeature flag; - starts the online crawler that transfers new events into the analytics database.
The command is safe to run repeatedly — you can run it several times without any negative consequences.
Parameters:
| Parameter | Values | Required | Default |
|---|---|---|---|
--clickhouseMode | SingleNode / Replicated | required | — |
--clickhouseCluster | cluster name from remote_servers | required for Replicated, not allowed for SingleNode | — |
--clickhouseHost | host or service name in the docker network | optional | pyrus-clickhouse |
--clickhousePort | ClickHouse HTTP port, 1–65535 | optional | 8123 |
--clickhouseUser | ClickHouse user name | optional | pyrus_writer |
--clickhousePassword | password (in single quotes) | optional | pyruspwd |
How values are determined: explicit argument → value already saved in the configuration → the standard default.
If a parameter is not passed, it is not overwritten.
Please note: the port is the HTTP interface (8123), not the native one (9000).
SingleNode:
docker-compose run --rm pyrus-setup enable-report-engine \ --clickhouseMode SingleNode \ --clickhouseHost pyrus-clickhouse \ --clickhousePort 8123 \ --clickhouseUser default \ --clickhousePassword 'PASSWORD'
Replicated (cluster):
docker-compose run --rm pyrus-setup enable-report-engine \ --clickhouseMode Replicated \ --clickhouseCluster CLUSTER_NAME \ --clickhouseHost clickhouse-01 \ --clickhousePort 8123 \ --clickhouseUser pyrus_writer \ --clickhousePassword 'PASSWORD'
If you only want to change the password in the Pyrus configuration — the remaining parameters will stay unchanged:
docker-compose run --rm pyrus-setup enable-report-engine \ --clickhouseMode SingleNode \ --clickhouseUser default \ --clickhousePassword 'NEW_PASSWORD'
After changing the password, restart the consumers:
docker-compose restart pyrus-web-api pyrus-async-worker
3. disable-report-engine — disabling
What the command does: stops the online crawler and clears the ReportEngine feature flag.
Important: the connection settings and all accumulated data in ClickHouse remain untouched. If you later re-enable the engine, you won't need to enter the login and password again.
The command has no parameters.
docker-compose run --rm pyrus-setup disable-report-engine
And if you just want to check the current state of the flag (without changing anything):
docker-compose run --rm pyrus-setup --setflag -f ReportEngine -v true -ls
4. --notes-to-analytic — indexing history
What the command does: transfers already accumulated historical task comments into the ClickHouse analytics database. When you enable the reporting engine, it processes only new events. To be able to build reports on historical data as well, this separate run is required.
The process can be interrupted and resumed — the position is set by the -start cursor.
Parameters:
| Parameter | Values | Default | Purpose |
|---|---|---|---|
-prof | Tiny / Small / Medium / Large / XLarge | Small | base load profile |
-sqlprof | same values | value of -prof | profile for the SQL side only |
-chprof | same values | value of -prof | profile for the ClickHouse side only |
-tune | fractional number | 1.0 | multiplier applied to the profile |
-pc | integer | from profile | number of processors |
-fbs | integer | from profile | read batch size |
-pbs | integer | from profile | processing batch size |
-ibs | integer | from profile | ClickHouse insert batch size |
-idop | integer | from profile | insert parallelism |
-ibc / -ebc / -tbc | integer | from profile | buffer capacity: input, events, tasks |
-logi | seconds | from profile | interval between log entries |
-forms | list of form IDs | all forms | migrate only tasks of these forms |
-start | task ID | from the beginning | resume from the specified task |
-tns | string | — | suffix for the table name |
Trial run for a single form only:
docker-compose run --rm pyrus-setup --notes-to-analytic -pc 2 -forms 12345
Full run:
docker-compose run --rm pyrus-setup --notes-to-analytic -pc 2
Run with increased load:
docker-compose run --rm pyrus-setup --notes-to-analytic -prof Medium -pc 4
Resuming after a stop:
docker-compose run --rm pyrus-setup --notes-to-analytic -pc 2 -start 372820809
5. Where the settings are stored in Pyrus
When you run enable-report-engine, the values are written into the Pyrus configuration. Here is which configuration key each parameter maps to:
| Command parameter | Configuration key |
|---|---|
--clickhouseMode | AnalyticDatabaseConnectio |
--clickhouseCluster | AnalyticDatabaseConnectio |
--clickhouseHost | AnalyticDatabaseConnectio |
--clickhousePort | AnalyticDatabaseConnectio |
--clickhouseUser | AnalyticDatabaseConnectio |
--clickhousePassword | AnalyticDatabaseConnectio (encrypted) |
Please note: the password is stored encrypted, so change it only through the enable-report-engine command. Do not try to edit it directly in the database or via SQL queries.