提交 da629e09 编写于 作者: M Mikhail f. Shiryaev

Add documentation for system.query_thread_log

上级 2d2cae5c
......@@ -578,6 +578,32 @@ If the table doesn't exist, ClickHouse will create it. If the structure of the q
</query_log>
```
## query_thread_log {#server_settings-query-thread-log}
Setting for logging threads of queries received with the [log_query_threads=1](../settings/settings.md#settings-log-query-threads) setting.
Queries are logged in the [system.query_thread_log](../system_tables.md#system_tables-query-thread-log) table, not in a separate file. You can change the name of the table in the `table` parameter (see below).
Use the following parameters to configure logging:
- `database` – Name of the database.
- `table` – Name of the system table the queries will be logged in.
- `partition_by` – Sets a [custom partitioning key](../../operations/table_engines/custom_partitioning_key.md) for a system table.
- `flush_interval_milliseconds` – Interval for flushing data from the buffer in memory to the table.
If the table doesn't exist, ClickHouse will create it. If the structure of the query log changed when the ClickHouse server was updated, the table with the old structure is renamed, and a new table is created automatically.
**Example**
```xml
<query_thread_log>
<database>system</database>
<table>query_log</table>
<partition_by>toMonday(event_date)</partition_by>
<flush_interval_milliseconds>7500</flush_interval_milliseconds>
</query_thread_log>
```
## trace_log {#server_settings-trace_log}
Settings for the [trace_log](../system_tables.md#system_tables-trace_log) system table operation.
......
......@@ -513,6 +513,16 @@ Queries sent to ClickHouse with this setup are logged according to the rules in
log_queries=1
## log_query_threads {#settings-log-query-threads}
Setting up query threads logging.
Queries' threads sent to ClickHouse with this setup are logged according to the rules in the [query_thread_log](../server_settings/settings.md#server_settings-query-thread-log) server configuration parameter.
**Example**:
log_query_threads=1
## max_insert_block_size {#settings-max_insert_block_size}
The size of blocks to form for insertion into a table.
......
......@@ -485,6 +485,75 @@ When the table is deleted manually, it will be automatically created on the fly.
You can specify an arbitrary partitioning key for the `system.query_log` table in the [query_log](server_settings/settings.md#server_settings-query-log) server setting (see the `partition_by` parameter).
## system.query_thread_log {#system_tables-query-thread-log}
The table contains information about each query execution threads.
ClickHouse creates this table only if the [query_thread_log](server_settings/settings.md#server_settings-query-thread-log) server parameter is specified. This parameter sets the logging rules, such as the logging interval or the name of the table the queries will be logged in.
To enable query logging, set the [log_query_threads](settings/settings.md#settings-log-query-threads) parameter to 1. For details, see the [Settings](settings/settings.md) section.
Columns:
- `event_date` (Date) — Event date.
- `event_time` (DateTime) — Event time.
- `query_start_time` (DateTime) — Start time of query execution.
- `query_duration_ms` (UInt64) — Duration of query execution.
- `read_rows` (UInt64) — Number of read rows.
- `read_bytes` (UInt64) — Number of read bytes.
- `written_rows` (UInt64) — For `INSERT` queries, the number of written rows. For other queries, the column value is 0.
- `written_bytes` (UInt64) — For `INSERT` queries, the number of written bytes. For other queries, the column value is 0.
- `memory_usage` (Int64) — Memory consumption by the thread (?).
- `peak_memory_usage` (Int64) — Maximum memory consumption by the thread.
- `thread_name` (String) — Name of the thread function.
- `thread_number` (UInt32) — Internal thread ID.
- `os_thread_id` (Int32) — OS thread ID.
- `master_thread_number` (UInt32) — Internal ID of initial thread.
- `master_os_thread_id` (Int32) — OS initial thread ID.
- `query` (String) — Query string.
- `is_initial_query` (UInt8) — Query type. Possible values:
- 1 — Query was initiated by the client.
- 0 — Query was initiated by another query for distributed query execution.
- `user` (String) — Name of the user who initiated the current query.
- `query_id` (String) — ID of the query.
- `address` (FixedString(16)) — IP address the query was initiated from.
- `port` (UInt16) — The server port that was used to receive the query.
- `initial_user` (String) — Name of the user who ran the parent query (for distributed query execution).
- `initial_query_id` (String) — ID of the parent query.
- `initial_address` (FixedString(16)) — IP address that the parent query was launched from.
- `initial_port` (UInt16) — The server port that was used to receive the parent query from the client.
- `interface` (UInt8) — Interface that the query was initiated from. Possible values:
- 1 — TCP.
- 2 — HTTP.
- `os_user` (String) — User's OS.
- `client_hostname` (String) — Server name that the [clickhouse-client](../interfaces/cli.md) is connected to.
- `client_name` (String) — The [clickhouse-client](../interfaces/cli.md) name.
- `client_revision` (UInt32) — Revision of the [clickhouse-client](../interfaces/cli.md).
- `client_version_major` (UInt32) — Major version of the [clickhouse-client](../interfaces/cli.md).
- `client_version_minor` (UInt32) — Minor version of the [clickhouse-client](../interfaces/cli.md).
- `client_version_patch` (UInt32) — Patch component of the [clickhouse-client](../interfaces/cli.md) version.
- `http_method` (UInt8) — HTTP method that initiated the query. Possible values:
- 0 — The query was launched from the TCP interface.
- 1 — `GET` method was used.
- 2 — `POST` method was used.
- `http_user_agent` (String) — The `UserAgent` header passed in the HTTP request.
- `quota_key` (String) — The quota key specified in the [quotas](quotas.md) setting.
- `revision` (UInt32) — ClickHouse revision.
- `ProfileEvents.Names` (Array(String)) — Counters that measure the following metrics:
- Time spent on reading and writing over the network.
- Time spent on reading and writing to a disk.
- Number of network errors.
- Time spent on waiting when the network bandwidth is limited.
- `ProfileEvents.Values` (Array(UInt64)) — Values of metrics that are listed in the&#160;`ProfileEvents.Names` column.
By default, logs are added to the table at intervals of 7.5 seconds. You can set this interval in the [query_thread_log](server_settings/settings.md#server_settings-query-thread-log) server setting (see the `flush_interval_milliseconds` parameter). To flush the logs forcibly from the memory buffer into the table, use the `SYSTEM FLUSH LOGS` query.
When the table is deleted manually, it will be automatically created on the fly. Note that all the previous logs will be deleted.
!!! note
The storage period for logs is unlimited. Logs aren't automatically deleted from the table. You need to organize the removal of outdated logs yourself.
You can specify an arbitrary partitioning key for the `system.query_thread_log` table in the [query_thread_log](server_settings/settings.md#server_settings-query-thread-log) server setting (see the `partition_by` parameter).
## system.trace_log {#system_tables-trace_log}
......
......@@ -580,6 +580,33 @@ ClickHouse проверит условия `min_part_size` и `min_part_size_rat
```
## query_thread_log {#server_settings-query-thread-log}
Настройка логирования тредов запросов, принятых с настройкой [log_query_threads=1](../settings/settings.md#settings-log-query-threads).
Запросы логируются не в отдельный файл, а в системную таблицу [system.query_thread_log](../system_tables.md#system_tables-query-thread-log). Вы можете изменить название этой таблицы в параметре `table` (см. ниже).
При настройке логирования используются следующие параметры:
- `database` — имя базы данных;
- `table` — имя таблицы, куда будет записываться лог;
- `partition_by`[произвольный ключ партиционирования](../../operations/table_engines/custom_partitioning_key.md) для таблицы с логами;
- `flush_interval_milliseconds` — период сброса данных из буфера в памяти в таблицу.
Если таблица не существует, то ClickHouse создаст её. Если структура журнала запросов изменилась при обновлении сервера ClickHouse, то таблица со старой структурой переименовывается, а новая таблица создается автоматически.
**Пример**
```xml
<query_thread_log>
<database>system</database>
<table>query_log</table>
<partition_by>toMonday(event_date)</partition_by>
<flush_interval_milliseconds>7500</flush_interval_milliseconds>
</query_thread_log>
```
## remote_servers {#server_settings_remote_servers}
Конфигурация кластеров, которые использует движок таблиц [Distributed](../../operations/table_engines/distributed.md) и табличная функция `cluster`.
......
......@@ -488,6 +488,16 @@ ClickHouse использует этот параметр при чтении д
log_queries=1
## log_query_threads {#settings-log-query-threads}
Установка логирования тредов запроса.
Треды запросов, переданных в ClickHouse с этой установкой, логируются согласно правилам конфигурационного параметра сервера [query_thread_log](../server_settings/settings.md#server_settings-query-thread-log).
**Пример** :
log_query_threads=1
## max_insert_block_size {#settings-max_insert_block_size}
Формировать блоки указанного размера, при вставке в таблицу.
......
......@@ -477,6 +477,76 @@ ClickHouse создаёт таблицу только в том случае, к
Можно указать произвольный ключ партиционирования для таблицы `system.query_log` в конфигурации [query_log](server_settings/settings.md#server_settings-query-log) (параметр `partition_by`).
## system.query_thread_log {#system_tables-query-thread-log}
Содержит информацию о каждом треде выполняемых запросов.
ClickHouse создаёт таблицу только в том случае, когда установлен конфигурационный параметр сервера [query_thread_log](server_settings/settings.md#server_settings-query-thread-log). Параметр задаёт правила ведения лога, такие как интервал логирования или имя таблицы, в которую будут логгироваться запросы.
Чтобы включить логирование, задайте значение параметра [log_query_threads](settings/settings.md#settings-log-query-threads) равным 1. Подробности смотрите в разделе [Настройки](settings/settings.md).
Столбцы:
- `event_date` (Date) — дата события.
- `event_time` (DateTime) — время события.
- `query_start_time` (DateTime) — время начала обработки запроса.
- `query_duration_ms` (UInt64) — длительность обработки запроса.
- `read_rows` (UInt64) — количество прочитанных строк.
- `read_bytes` (UInt64) — количество прочитанных байтов.
- `written_rows` (UInt64) — количество записанных строк для запросов `INSERT`. Для других запросов, значение столбца 0.
- `written_bytes` (UInt64) — объем записанных данных в байтах для запросов `INSERT`. Для других запросов, значение столбца 0.
- `memory_usage` (Int64) — Потребление RAM тредом (?).
- `peak_memory_usage` (Int64) — Максимальное потребление RAM тредом.
- `thread_name` (String) — Имя функции треда.
- `thread_number` (UInt32) — Внутренний ID треда.
- `os_thread_id` (Int32) — Системный ID треда.
- `master_thread_number` (UInt32) — Внутренний ID главного треда (?).
- `master_os_thread_id` (Int32) — Системный ID главного треда (?).
- `query` (String) — строка запроса.
- `is_initial_query` (UInt8) — вид запроса. Возможные значения:
- 1 — запрос был инициирован клиентом.
- 0 — запрос был инициирован другим запросом при распределенном запросе.
- `user` (String) — пользователь, запустивший текущий запрос.
- `query_id` (String) — ID запроса.
- `address` (FixedString(16)) — IP адрес, с которого пришел запрос.
- `port` (UInt16) — порт, на котором сервер принял запрос.
- `initial_user` (String) — пользователь, запустивший первоначальный запрос (для распределенных запросов).
- `initial_query_id` (String) — ID родительского запроса.
- `initial_address` (FixedString(16)) — IP адрес, с которого пришел родительский запрос.
- `initial_port` (UInt16) — порт, на котором сервер принял родительский запрос от клиента.
- `interface` (UInt8) — интерфейс, с которого ушёл запрос. Возможные значения:
- 1 — TCP.
- 2 — HTTP.
- `os_user` (String) — операционная система пользователя.
- `client_hostname` (String) — имя сервера, к которому присоединился [clickhouse-client](../interfaces/cli.md).
- `client_name` (String) — [clickhouse-client](../interfaces/cli.md).
- `client_revision` (UInt32) — ревизия [clickhouse-client](../interfaces/cli.md).
- `client_version_major` (UInt32) — старшая версия [clickhouse-client](../interfaces/cli.md).
- `client_version_minor` (UInt32) — младшая версия [clickhouse-client](../interfaces/cli.md).
- `client_version_patch` (UInt32) — патч [clickhouse-client](../interfaces/cli.md).
- `http_method` (UInt8) — HTTP метод, инициировавший запрос. Возможные значения:
- 0 — запрос запущен с интерфейса TCP.
- 1 — `GET`.
- 2 — `POST`.
- `http_user_agent` (String) — HTTP заголовок `UserAgent`.
- `quota_key` (String) — идентификатор квоты из настроек [квот](quotas.md).
- `revision` (UInt32) — ревизия ClickHouse.
- `ProfileEvents.Names` (Array(String)) — Счетчики для изменения метрик:
- Время, потраченное на чтение и запись по сети.
- Время, потраченное на чтение и запись на диск.
- Количество сетевых ошибок.
- Время, потраченное на ожидание, когда пропускная способность сети ограничена.
- `ProfileEvents.Values` (Array(UInt64)) — метрики, перечисленные в столбце `ProfileEvents.Names`.
По умолчанию, строки добавляются в таблицу логирования с интервалом в 7,5 секунд. Можно задать интервал в конфигурационном параметре сервера [query_thread_log](server_settings/settings.md#server_settings-query-thread-log) (смотрите параметр `flush_interval_milliseconds`). Чтобы принудительно записать логи из буффера памяти в таблицу, используйте запрос `SYSTEM FLUSH LOGS`.
Если таблицу удалить вручную, она пересоздастся автоматически "на лету". При этом все логи на момент удаления таблицы будут удалены.
!!! note "Примечание"
Срок хранения логов не ограничен. Логи не удаляются из таблицы автоматически. Вам необходимо самостоятельно организовать удаление устаревших логов.
Можно указать произвольный ключ партиционирования для таблицы `system.query_log` в конфигурации [query_thread_log](server_settings/settings.md#server_settings-query-thread-log) (параметр `partition_by`).
## system.replicas {#system_tables-replicas}
Содержит информацию и статус для реплицируемых таблиц, расположенных на локальном сервере.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册