blob: 3b0ce1bee044976d2e903cf6ef9da58782a4f250 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#pragma once
#include <Interpreters/SystemLog.h>
#include <Common/AsynchronousMetrics.h>
#include <Common/ProfileEvents.h>
#include <Common/CurrentMetrics.h>
#include <Core/NamesAndTypes.h>
#include <Core/NamesAndAliases.h>
#include <vector>
#include <atomic>
#include <ctime>
namespace DB
{
/** AsynchronousMetricLog is a log of metric values measured at regular time interval.
*/
struct AsynchronousMetricLogElement
{
UInt16 event_date;
time_t event_time;
std::string metric_name;
double value;
static std::string name() { return "AsynchronousMetricLog"; }
static NamesAndTypesList getNamesAndTypes();
static NamesAndAliases getNamesAndAliases() { return {}; }
void appendToBlock(MutableColumns & columns) const;
/// Returns the list of columns as in CREATE TABLE statement or nullptr.
/// If it's not nullptr, this list of columns will be used to create the table.
/// Otherwise the list will be constructed from LogElement::getNamesAndTypes and LogElement::getNamesAndAliases.
static const char * getCustomColumnList()
{
return "event_date Date CODEC(Delta(2), ZSTD(1)), "
"event_time DateTime CODEC(Delta(4), ZSTD(1)), "
"metric LowCardinality(String) CODEC(ZSTD(1)), "
"value Float64 CODEC(ZSTD(3))";
}
};
class AsynchronousMetricLog : public SystemLog<AsynchronousMetricLogElement>
{
public:
using SystemLog<AsynchronousMetricLogElement>::SystemLog;
void addValues(const AsynchronousMetricValues &);
/// This table is usually queried for fixed metric name.
static const char * getDefaultOrderBy() { return "metric, event_date, event_time"; }
};
}
|