Document the log_formatted_queries setting

Задокументировал настройку.
This commit is contained in:
Dmitriy 2021-11-03 19:31:50 +03:00
parent 6dc51bf540
commit bdd039a21c
2 changed files with 49 additions and 36 deletions

View File

@ -992,6 +992,16 @@ Example:
log_query_views=1 log_query_views=1
``` ```
## log_formatted_queries {#settings-log-formatted-queries}
Allows a user to log formatted queries and to write to the [system.query_log](../../operations/system-tables/query_log.md) system table.
Possible values:
- 0 — Formatted queries are not logged.
- 1 — Formatted queries are logged.
Default value: `0`.
## log_comment {#settings-log-comment} ## log_comment {#settings-log-comment}

View File

@ -26,6 +26,8 @@ Each query creates one or two rows in the `query_log` table, depending on the st
You can use the [log_queries_probability](../../operations/settings/settings.md#log-queries-probability) setting to reduce the number of queries, registered in the `query_log` table. You can use the [log_queries_probability](../../operations/settings/settings.md#log-queries-probability) setting to reduce the number of queries, registered in the `query_log` table.
You can use the [log_formatted_queries](../../operations/settings/settings.md#settings-log-formatted-queries) setting to log formatted queries to the `formatted_query` column.
Columns: Columns:
- `type` ([Enum8](../../sql-reference/data-types/enum.md)) — Type of an event that occurred when executing the query. Values: - `type` ([Enum8](../../sql-reference/data-types/enum.md)) — Type of an event that occurred when executing the query. Values:
@ -48,6 +50,7 @@ Columns:
- `memory_usage` ([UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges)) — Memory consumption by the query. - `memory_usage` ([UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges)) — Memory consumption by the query.
- `current_database` ([String](../../sql-reference/data-types/string.md)) — Name of the current database. - `current_database` ([String](../../sql-reference/data-types/string.md)) — Name of the current database.
- `query` ([String](../../sql-reference/data-types/string.md)) — Query string. - `query` ([String](../../sql-reference/data-types/string.md)) — Query string.
- `formatted_query` ([String](../../sql-reference/data-types/string.md)) — Formatted_query string.
- `normalized_query_hash` ([UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges)) — Identical hash value without the values of literals for similar queries. - `normalized_query_hash` ([UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges)) — Identical hash value without the values of literals for similar queries.
- `query_kind` ([LowCardinality(String)](../../sql-reference/data-types/lowcardinality.md)) — Type of the query. - `query_kind` ([LowCardinality(String)](../../sql-reference/data-types/lowcardinality.md)) — Type of the query.
- `databases` ([Array](../../sql-reference/data-types/array.md)([LowCardinality(String)](../../sql-reference/data-types/lowcardinality.md))) — Names of the databases present in the query. - `databases` ([Array](../../sql-reference/data-types/array.md)([LowCardinality(String)](../../sql-reference/data-types/lowcardinality.md))) — Names of the databases present in the query.
@ -114,68 +117,68 @@ SELECT * FROM system.query_log WHERE type = 'QueryFinish' ORDER BY query_start_t
Row 1: Row 1:
────── ──────
type: QueryFinish type: QueryFinish
event_date: 2021-07-28 event_date: 2021-11-03
event_time: 2021-07-28 13:46:56 event_time: 2021-11-03 16:13:54
event_time_microseconds: 2021-07-28 13:46:56.719791 event_time_microseconds: 2021-11-03 16:13:54.953024
query_start_time: 2021-07-28 13:46:56 query_start_time: 2021-11-03 16:13:54
query_start_time_microseconds: 2021-07-28 13:46:56.704542 query_start_time_microseconds: 2021-11-03 16:13:54.952325
query_duration_ms: 14 query_duration_ms: 0
read_rows: 8393 read_rows: 69
read_bytes: 374325 read_bytes: 6187
written_rows: 0 written_rows: 0
written_bytes: 0 written_bytes: 0
result_rows: 4201 result_rows: 69
result_bytes: 153024 result_bytes: 48256
memory_usage: 4714038 memory_usage: 0
current_database: default current_database: default
query: SELECT DISTINCT arrayJoin(extractAll(name, '[\\w_]{2,}')) AS res FROM (SELECT name FROM system.functions UNION ALL SELECT name FROM system.table_engines UNION ALL SELECT name FROM system.formats UNION ALL SELECT name FROM system.table_functions UNION ALL SELECT name FROM system.data_type_families UNION ALL SELECT name FROM system.merge_tree_settings UNION ALL SELECT name FROM system.settings UNION ALL SELECT cluster FROM system.clusters UNION ALL SELECT macro FROM system.macros UNION ALL SELECT policy_name FROM system.storage_policies UNION ALL SELECT concat(func.name, comb.name) FROM system.functions AS func CROSS JOIN system.aggregate_function_combinators AS comb WHERE is_aggregate UNION ALL SELECT name FROM system.databases LIMIT 10000 UNION ALL SELECT DISTINCT name FROM system.tables LIMIT 10000 UNION ALL SELECT DISTINCT name FROM system.dictionaries LIMIT 10000 UNION ALL SELECT DISTINCT name FROM system.columns LIMIT 10000) WHERE notEmpty(res) query: DESCRIBE TABLE system.query_log
normalized_query_hash: 6666026786019643712 formatted_query:
query_kind: Select normalized_query_hash: 8274064835331539124
databases: ['system'] query_kind:
tables: ['system.aggregate_function_combinators','system.clusters','system.columns','system.data_type_families','system.databases','system.dictionaries','system.formats','system.functions','system.macros','system.merge_tree_settings','system.settings','system.storage_policies','system.table_engines','system.table_functions','system.tables'] databases: []
columns: ['system.aggregate_function_combinators.name','system.clusters.cluster','system.columns.name','system.data_type_families.name','system.databases.name','system.dictionaries.name','system.formats.name','system.functions.is_aggregate','system.functions.name','system.macros.macro','system.merge_tree_settings.name','system.settings.name','system.storage_policies.policy_name','system.table_engines.name','system.table_functions.name','system.tables.name'] tables: []
columns: []
projections: [] projections: []
views: []
exception_code: 0 exception_code: 0
exception: exception:
stack_trace: stack_trace:
is_initial_query: 1 is_initial_query: 1
user: default user: default
query_id: a3361f6e-a1fd-4d54-9f6f-f93a08bab0bf query_id: 7c28bbbb-753b-4eba-98b1-efcbe2b9bdf6
address: ::ffff:127.0.0.1 address: ::ffff:127.0.0.1
port: 51006 port: 40452
initial_user: default initial_user: default
initial_query_id: a3361f6e-a1fd-4d54-9f6f-f93a08bab0bf initial_query_id: 7c28bbbb-753b-4eba-98b1-efcbe2b9bdf6
initial_address: ::ffff:127.0.0.1 initial_address: ::ffff:127.0.0.1
initial_port: 51006 initial_port: 40452
initial_query_start_time: 2021-07-28 13:46:56 initial_query_start_time: 2021-11-03 16:13:54
initial_query_start_time_microseconds: 2021-07-28 13:46:56.704542 initial_query_start_time_microseconds: 2021-11-03 16:13:54.952325
interface: 1 interface: 1
os_user: os_user: sevirov
client_hostname: client_hostname: clickhouse.ru-central1.internal
client_name: ClickHouse client client_name: ClickHouse
client_revision: 54449 client_revision: 54449
client_version_major: 21 client_version_major: 21
client_version_minor: 8 client_version_minor: 10
client_version_patch: 0 client_version_patch: 1
http_method: 0 http_method: 0
http_user_agent: http_user_agent:
http_referer: http_referer:
forwarded_for: forwarded_for:
quota_key: quota_key:
revision: 54453 revision: 54456
log_comment: log_comment:
thread_ids: [5058,22097,22110,22094] thread_ids: [30776,31174]
ProfileEvents.Names: ['Query','SelectQuery','ArenaAllocChunks','ArenaAllocBytes','FunctionExecute','NetworkSendElapsedMicroseconds','SelectedRows','SelectedBytes','ContextLock','RWLockAcquiredReadLocks','RealTimeMicroseconds','UserTimeMicroseconds','SystemTimeMicroseconds','SoftPageFaults','OSCPUWaitMicroseconds','OSCPUVirtualTimeMicroseconds','OSWriteBytes','OSWriteChars'] ProfileEvents: {'Query':1,'NetworkSendElapsedMicroseconds':59,'NetworkSendBytes':2643,'SelectedRows':69,'SelectedBytes':6187,'ContextLock':9,'RWLockAcquiredReadLocks':1,'RealTimeMicroseconds':817,'UserTimeMicroseconds':427,'SystemTimeMicroseconds':212,'OSCPUVirtualTimeMicroseconds':639,'OSReadChars':894,'OSWriteChars':319}
ProfileEvents.Values: [1,1,39,352256,64,360,8393,374325,412,440,34480,13108,4723,671,19,17828,8192,10240] Settings: {'load_balancing':'random','max_memory_usage':'10000000000'}
Settings.Names: ['load_balancing','max_memory_usage']
Settings.Values: ['random','10000000000']
used_aggregate_functions: [] used_aggregate_functions: []
used_aggregate_function_combinators: [] used_aggregate_function_combinators: []
used_database_engines: [] used_database_engines: []
used_data_type_families: ['UInt64','UInt8','Nullable','String','date'] used_data_type_families: []
used_dictionaries: [] used_dictionaries: []
used_formats: [] used_formats: []
used_functions: ['concat','notEmpty','extractAll'] used_functions: []
used_storages: [] used_storages: []
used_table_functions: [] used_table_functions: []
``` ```