Skip to main content
The server does not create system log tables (system.query_log, system.part_log, system.s3queue_log, system.azure_queue_log and the other *_log tables) when it starts. It creates each table the first time it flushes rows into it. A log that has nothing to write yet has no table, even though its section is in the server configuration. To create the tables right away, run SYSTEM FLUSH LOGS.

Example

Enable the log of the S3Queue table engine in a file under config.d and restart the server:
The table is not there yet:
Flush the log and check again:
The table now exists and is empty until an S3Queue table processes files.

Why this happens

Every system log collects its rows in memory, and a background thread writes them to the table every flush_interval_milliseconds (7500 by default). The table is created by the first flush that has rows to write:
  • system.query_log appears a few seconds after the first query.
  • system.s3queue_log and system.azure_queue_log get rows only when an S3Queue or AzureQueue table processes files, so on a server without such tables they never appear by themselves.
SYSTEM FLUSH LOGS writes the collected rows immediately and also creates the tables of all configured logs, including the empty ones. With a list of names, such as SYSTEM FLUSH LOGS s3queue_log, query_log, it handles only those logs.

Create the tables at startup

If scripts or monitoring queries expect the tables to exist from the start, set the server setting prepare_system_log_tables_on_startup and restart the server:
The server then creates all configured system.*_log tables before it accepts queries. The setting is off by default. If startup_scripts are configured and the setting is not set explicitly, the server turns it on by itself.

If the table is still missing

SYSTEM FLUSH LOGS creates tables only for logs that are configured, and it does not report a log whose section is absent. If the table does not exist after the flush, the server did not pick up the section:
  • The section name must match the log, for example s3queue_log or azure_queue_log, and be a direct child of the root element.
  • System logs are set up at startup, so restart the server after you add a section.
  • The preprocessed configuration file that the server writes at startup shows the configuration it uses.