Comments (1)
Here is a template for all types of charts that are now available to be built from system tables using new features:
CurrentMetric (system.metric_log)
Single line
SELECT
toStartOfInterval(event_time, INTERVAL {rounding:UInt32} SECOND)::INT AS t,
avg(metric)
FROM (
SELECT event_time, sum(CurrentMetric_Query) AS metric
FROM clusterAllReplicas(default, merge('system', '^metric_log'))
WHERE event_date >= toDate(now() - {seconds:UInt32})
AND event_time >= now() - {seconds:UInt32}
GROUP BY event_time)
GROUP BY t
ORDER BY t WITH FILL STEP {rounding:UInt32} SETTINGS skip_unavailable_shards = 1
Two-lines
SELECT
toStartOfInterval(event_time, INTERVAL {rounding:UInt32} SECOND)::INT AS t,
avg(SystemReplicasThreads),
avg(SystemReplicasThreadsActive)
FROM (
SELECT event_time,
sum(CurrentMetric_SystemReplicasThreads) AS SystemReplicasThreads,
sum(CurrentMetric_SystemReplicasThreadsActive) AS SystemReplicasThreadsActive
FROM clusterAllReplicas(default, merge('system', '^metric_log'))
WHERE event_date >= toDate(now() - {seconds:UInt32})
AND event_time >= now() - {seconds:UInt32}
GROUP BY event_time)
GROUP BY t
ORDER BY t SETTINGS skip_unavailable_shards = 1
Single line per host (double group by is not required)
SELECT
toStartOfInterval(event_time, INTERVAL {rounding:UInt32} SECOND)::INT AS t,
hostname() as label,
avg(CurrentMetric_SystemReplicasThreadsActive)
FROM clusterAllReplicas(default, merge('system', '^metric_log'))
WHERE event_date >= toDate(now() - {seconds:UInt32})
AND event_time >= now() - {seconds:UInt32}
GROUP BY t, label
ORDER BY t, label SETTINGS skip_unavailable_shards = 1
ProfileEvent (system.metric_log)
Single line
SELECT
toStartOfInterval(event_time, INTERVAL {rounding:UInt32} SECOND)::INT AS t,
avg(metric)
FROM (
SELECT event_time, sum(ProfileEvent_Query) AS metric
FROM clusterAllReplicas(default, merge('system', '^metric_log'))
WHERE event_date >= toDate(now() - {seconds:UInt32})
AND event_time >= now() - {seconds:UInt32}
GROUP BY event_time)
GROUP BY t
ORDER BY t WITH FILL STEP {rounding:UInt32} SETTINGS skip_unavailable_shards = 1
Two-line
SELECT
toStartOfInterval(event_time, INTERVAL {rounding:UInt32} SECOND)::INT AS t,
avg(SelectQuery),
avg(InsertQuery)
FROM (
SELECT event_time,
sum(ProfileEvent_SelectQuery) AS SelectQuery,
sum(ProfileEvent_InsertQuery) AS InsertQuery
FROM clusterAllReplicas(default, merge('system', '^metric_log'))
WHERE event_date >= toDate(now() - {seconds:UInt32})
AND event_time >= now() - {seconds:UInt32}
GROUP BY event_time)
GROUP BY t
ORDER BY t SETTINGS skip_unavailable_shards = 1
Single line per host (double group by is required: first sum on second scale, then average over rounding interval)
SELECT
toStartOfInterval(event_time, INTERVAL {rounding:UInt32} SECOND)::INT AS t,
label,
avg(metric)
FROM (
SELECT event_time,
hostname() as label,
sum(ProfileEvent_Query) AS metric
FROM clusterAllReplicas(default, merge('system', '^metric_log'))
WHERE event_date >= toDate(now() - {seconds:UInt32})
AND event_time >= now() - {seconds:UInt32}
GROUP BY event_time, label)
GROUP BY t, label
ORDER BY t, label SETTINGS skip_unavailable_shards = 1
AsynchronousMetrics (system.asynchronous_metric_log)
Single line
SELECT
toStartOfInterval(event_time, INTERVAL {rounding:UInt32} SECOND)::INT AS t,
avg(value)
FROM
clusterAllReplicas(default, merge('system', '^asynchronous_metric_log'))
WHERE event_date >= toDate(now() - {seconds:UInt32})
AND event_time >= now() - {seconds:UInt32}
AND metric = 'OSSystemTimeNormalized'
GROUP BY t
ORDER BY t WITH FILL STEP {rounding:UInt32} SETTINGS skip_unavailable_shards = 1
Multiple metrics
SELECT
toStartOfInterval(event_time, INTERVAL {rounding:UInt32} SECOND)::INT AS t,
metric as label,
avg(value)
FROM
clusterAllReplicas(default, merge('system', '^asynchronous_metric_log'))
WHERE event_date >= toDate(now() - {seconds:UInt32})
AND event_time >= now() - {seconds:UInt32}
AND metric in ['OSSystemTimeNormalized', 'OSUserTimeNormalized', 'OSIrqTimeNormalized']
GROUP BY t, label
ORDER BY t, label SETTINGS skip_unavailable_shards = 1
Single line per host (double group by is not required)
SELECT
toStartOfInterval(event_time, INTERVAL {rounding:UInt32} SECOND)::INT AS t,
hostname() as label,
avg(value)
FROM
clusterAllReplicas(default, merge('system', '^asynchronous_metric_log'))
WHERE event_date >= toDate(now() - {seconds:UInt32})
AND event_time >= now() - {seconds:UInt32}
AND metric = 'OSUserTimeNormalized'
GROUP BY t, label
ORDER BY t, label SETTINGS skip_unavailable_shards = 1
Read/Write on the same chart (I'm not sure if this one is actually a good idea)
SELECT
toStartOfInterval(event_time, INTERVAL {rounding:UInt32} SECOND)::INT AS t,
label,
avg(if(label='NetworkReceiveBytes', value, -value))
FROM (
SELECT event_time,
sum(value) AS value,
if(metric LIKE 'NetworkReceiveBytes%', 'NetworkReceiveBytes', 'NetworkSendBytes') as label
FROM clusterAllReplicas(default, merge('system', '^asynchronous_metric_log'))
WHERE event_date >= toDate(now() - {seconds:UInt32})
AND event_time >= now() - {seconds:UInt32}
AND (metric LIKE 'NetworkReceiveBytes%' OR metric LIKE 'NetworkSendBytes%')
GROUP BY event_time, label)
GROUP BY t, label
ORDER BY t, label SETTINGS skip_unavailable_shards = 1
from clickhouse.
Related Issues (20)
- ubsan: Unsafe integer cast in `replaceNodesWithPositionalArguments` HOT 1
- Context has expired in `SetOrJoinSink::consume` (when writing through MV)
- (experimental transactions) An EXPLAIN query causes a segfault
- After using projection, the same query statement has different values ββand cannot be hit. HOT 7
- Wrong result in left join HOT 2
- query with view is slower HOT 4
- Clickhouse reads too many marks on large parts when query filter by PK HOT 2
- cross-version query : Not found column ip in block HOT 4
- Unable to Connect to HDFS for Tiered Storage Setup HOT 6
- Not found column in block, optimize_skip_unused_shards = 1, analyzer
- Filtering by `dictGet()` column leads to `TYPE_MISMATCH` exception HOT 1
- Unexpected exception when using final modifier with non MergeTree table HOT 1
- LOGICAL_ERROR Pipeline for PushingPipelineExecutor was finished before all data was inserted HOT 1
- clickhouse-keeper-client: add flag to allow rm & rmr command non-interactive
- Parallel replicas and join throw error 'expected to process query to fetch columns stage. Actual WithMergeableState'
- Log down the checked privileges to the system.query_log HOT 1
- Freebsd + Mysql compiling error
- Logs are sent over network not instantly. HOT 1
- ClickHouse Zookeeper API automatically optimize `multi` to `mutiRead` HOT 4
- Create BigRedButton script to cancel all the worflows with a given name HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clickhouse.