#include "QueryThreadLog.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace DB { Block QueryThreadLogElement::createBlock() { return { {std::make_shared(), "event_date"}, {std::make_shared(), "event_time"}, {std::make_shared(), "query_start_time"}, {std::make_shared(), "query_duration_ms"}, {std::make_shared(), "read_rows"}, {std::make_shared(), "read_bytes"}, {std::make_shared(), "written_rows"}, {std::make_shared(), "written_bytes"}, {std::make_shared(), "memory_usage"}, {std::make_shared(), "peak_memory_usage"}, {std::make_shared(), "thread_name"}, {std::make_shared(), "thread_number"}, {std::make_shared(), "os_thread_id"}, {std::make_shared(), "master_thread_number"}, {std::make_shared(), "master_os_thread_id"}, {std::make_shared(), "query"}, {std::make_shared(), "is_initial_query"}, {std::make_shared(), "user"}, {std::make_shared(), "query_id"}, {std::make_shared(16), "address"}, {std::make_shared(), "port"}, {std::make_shared(), "initial_user"}, {std::make_shared(), "initial_query_id"}, {std::make_shared(16), "initial_address"}, {std::make_shared(), "initial_port"}, {std::make_shared(), "interface"}, {std::make_shared(), "os_user"}, {std::make_shared(), "client_hostname"}, {std::make_shared(), "client_name"}, {std::make_shared(), "client_revision"}, {std::make_shared(), "client_version_major"}, {std::make_shared(), "client_version_minor"}, {std::make_shared(), "client_version_patch"}, {std::make_shared(), "http_method"}, {std::make_shared(), "http_user_agent"}, {std::make_shared(), "quota_key"}, {std::make_shared(), "revision"}, {std::make_shared(std::make_shared()), "ProfileEvents.Names"}, {std::make_shared(std::make_shared()), "ProfileEvents.Values"} }; } void QueryThreadLogElement::appendToBlock(Block & block) const { MutableColumns columns = block.mutateColumns(); size_t i = 0; columns[i++]->insert(UInt64(DateLUT::instance().toDayNum(event_time))); columns[i++]->insert(UInt64(event_time)); columns[i++]->insert(UInt64(query_start_time)); columns[i++]->insert(UInt64(query_duration_ms)); columns[i++]->insert(UInt64(read_rows)); columns[i++]->insert(UInt64(read_bytes)); columns[i++]->insert(UInt64(written_rows)); columns[i++]->insert(UInt64(written_bytes)); columns[i++]->insert(Int64(memory_usage)); columns[i++]->insert(Int64(peak_memory_usage)); columns[i++]->insertData(thread_name.data(), thread_name.size()); columns[i++]->insert(UInt64(thread_number)); columns[i++]->insert(Int64(os_thread_id)); columns[i++]->insert(UInt64(master_thread_number)); columns[i++]->insert(Int64(master_os_thread_id)); columns[i++]->insertData(query.data(), query.size()); QueryLogElement::appendClientInfo(client_info, columns, i); columns[i++]->insert(UInt64(ClickHouseRevision::get())); if (profile_counters) { auto column_names = columns[i++].get(); auto column_values = columns[i++].get(); dumpToArrayColumns(*profile_counters, column_names, column_values, true); } else { columns[i++]->insertDefault(); columns[i++]->insertDefault(); } } }