首页 > 解决方案 > 这是通过grafana使用它的正确方法吗?

问题描述


点击屋:

┌─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{host='test01'} 104189952

标签: sqlperformanceprometheusgrafanaclickhouse

解决方案


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


推荐阅读