1
2#include <Common/CurrentMetrics.h>
3#include <DataTypes/DataTypeString.h>
4#include <DataTypes/DataTypesNumber.h>
5#include <Storages/System/StorageSystemMetrics.h>
6
7
8namespace DB
9{
10
11NamesAndTypesList StorageSystemMetrics::getNamesAndTypes()
12{
13 return {
14 {"metric", std::make_shared<DataTypeString>()},
15 {"value", std::make_shared<DataTypeInt64>()},
16 {"description", std::make_shared<DataTypeString>()},
17 };
18}
19
20void StorageSystemMetrics::fillData(MutableColumns & res_columns, const Context &, const SelectQueryInfo &) const
21{
22 for (size_t i = 0, end = CurrentMetrics::end(); i < end; ++i)
23 {
24 Int64 value = CurrentMetrics::values[i].load(std::memory_order_relaxed);
25
26 res_columns[0]->insert(CurrentMetrics::getName(CurrentMetrics::Metric(i)));
27 res_columns[1]->insert(value);
28 res_columns[2]->insert(CurrentMetrics::getDocumentation(CurrentMetrics::Metric(i)));
29 }
30}
31
32}
33