这是通过 grafana 使用它的正确方法吗?
Is this the correct way to use it via grafana?
ClickHouse:
┌─name──────────┬─type──────────┬
│ FieldUUID │ UUID │
│ EventDate │ Date │
│ EventDateTime │ DateTime │
│ Metric │ String │
│ LabelNames │ Array(String) │
│ LabelValues │ Array(String) │
│ Value │ Float64 │
└───────────────┴───────────────┴
Row 1:
──────
FieldUUID: 499ca963-2bd4-4c94-bc60-e60757ccaf6b
EventDate: 2021-05-13
EventDateTime: 2021-05-13 09:24:18
Metric: cluster_cm_agent_physical_memory_used
LabelNames: ['host']
LabelValues: ['test01']
Value: 104189952
格拉法纳:
SELECT
EventDateTime,
Value AS cluster_cm_agent_physical_memory_used
FROM
$table
WHERE
Metric = 'cluster_cm_agent_physical_memory_used'
AND $timeFilter
ORDER BY
EventDateTime
没有数据点。
问题:这是通过grafana使用的正确方法吗?
示例:
cluster_cm_agent_physical_memory_used{主机='test01'} 104189952
Grafana 希望您的 SQL 将 return 时间序列数据格式用于大多数可视化。
- 一栏
DateTime\Date\DateTime64 or UInt32
描述
时间戳
- 一列或多列数字类型(Float、Int*、
UInt*) 与指标值(列名将用作时间序列名称)
- 可选的一列可以描述多个时间的字符串
系列名称
或高级“时间序列”格式,第一列为 timestamp
,第二列为 Array(tuple(String, Numeric))
,其中 String
列为时间序列名称(通常与
所以,select table metrics.shell
作为 table 和 EventDateTime
作为 query editor
下拉列表中的字段,您的查询可能是改为
SELECT
EventDateTime,
Value AS cluster_cm_agent_physical_memory_used
FROM
$table
WHERE
Metric = 'cluster_cm_agent_physical_memory_used'
AND $timeFilter
ORDER BY
EventDateTime
来自 post 的 SQL 查询可以在没有变化的情况下仅通过 Table
插件可视化,您应将“时间序列”更改为“table”格式在 grafana 端进行正确的数据转换
promQL 查询的模拟
cluster_cm_agent_physical_memory_used{host='test01'} 104189952
应该看起来像
SELECT
EventDateTime,
Value AS cluster_cm_agent_physical_memory_used
FROM
$table
WHERE
Metric = 'cluster_cm_agent_physical_memory_used'
AND LabelValues[indexOf(LabelNames,'host')] = 'test01'
AND $timeFilter
ORDER BY
EventDateTime
ClickHouse:
┌─name──────────┬─type──────────┬
│ FieldUUID │ UUID │
│ EventDate │ Date │
│ EventDateTime │ DateTime │
│ Metric │ String │
│ LabelNames │ Array(String) │
│ LabelValues │ Array(String) │
│ Value │ Float64 │
└───────────────┴───────────────┴
Row 1:
──────
FieldUUID: 499ca963-2bd4-4c94-bc60-e60757ccaf6b
EventDate: 2021-05-13
EventDateTime: 2021-05-13 09:24:18
Metric: cluster_cm_agent_physical_memory_used
LabelNames: ['host']
LabelValues: ['test01']
Value: 104189952
格拉法纳:
SELECT
EventDateTime,
Value AS cluster_cm_agent_physical_memory_used
FROM
$table
WHERE
Metric = 'cluster_cm_agent_physical_memory_used'
AND $timeFilter
ORDER BY
EventDateTime
没有数据点。
问题:这是通过grafana使用的正确方法吗?
示例:
cluster_cm_agent_physical_memory_used{主机='test01'} 104189952
Grafana 希望您的 SQL 将 return 时间序列数据格式用于大多数可视化。
- 一栏
DateTime\Date\DateTime64 or UInt32
描述 时间戳 - 一列或多列数字类型(Float、Int*、 UInt*) 与指标值(列名将用作时间序列名称)
- 可选的一列可以描述多个时间的字符串 系列名称
或高级“时间序列”格式,第一列为 timestamp
,第二列为 Array(tuple(String, Numeric))
,其中 String
列为时间序列名称(通常与
所以,select table metrics.shell
作为 table 和 EventDateTime
作为 query editor
下拉列表中的字段,您的查询可能是改为
SELECT
EventDateTime,
Value AS cluster_cm_agent_physical_memory_used
FROM
$table
WHERE
Metric = 'cluster_cm_agent_physical_memory_used'
AND $timeFilter
ORDER BY
EventDateTime
来自 post 的 SQL 查询可以在没有变化的情况下仅通过 Table
插件可视化,您应将“时间序列”更改为“table”格式在 grafana 端进行正确的数据转换
promQL 查询的模拟
cluster_cm_agent_physical_memory_used{host='test01'} 104189952
应该看起来像
SELECT
EventDateTime,
Value AS cluster_cm_agent_physical_memory_used
FROM
$table
WHERE
Metric = 'cluster_cm_agent_physical_memory_used'
AND LabelValues[indexOf(LabelNames,'host')] = 'test01'
AND $timeFilter
ORDER BY
EventDateTime