File size: 1,058 Bytes
4e83772 | 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 | export interface IAnalytics {
projectId: string;
path: string;
statusCode: number;
responseTime: number;
responseSize: number;
ip: string;
uaBrowser?: string;
uaOs?: string;
referer?: string;
timestamp: number;
}
export interface BufferAnalytics {
project_id: string;
path: string;
status_code: number;
response_time: number;
response_size: number;
ip: string;
ua_browser: string | null;
ua_os: string | null;
referer: null | string;
timestamp: number;
}
/**
*
*
*
CREATE TABLE analytics (
project_id String,
path String,
status_code UInt16,
response_time Float32,
response_size UInt32,
ip IPv6,
ua_os LowCardinality(Nullable(String)),
ua_browser LowCardinality(Nullable(String)),
referer Nullable(String),
timestamp DateTime64(3, 'UTC'),
date Date MATERIALIZED toDate(timestamp)
)
ENGINE = MergeTree()
PARTITION BY toYYYYMM(date)
ORDER BY (project_id, timestamp, path)
TTL date + INTERVAL 30 DAY
SETTINGS index_granularity = 8192;
CREATE INDEX idx_status_code ON analytics(status_code) TYPE minmax GRANULARITY 4;
*/
|