chenzw2
V2EX  ›  数据库

grafana 中 dashboard 里的数据显示为空,实际通过 Queries 查询是有数据的?

  •  
  •   chenzw2 · Nov 24, 2025 · 2490 views
    This topic created in 169 days ago, the information mentioned may be changed or developed.

    1763945261171.png

    1763945261365.png

    1763945261516.png

    如上所示,指标单独查询是有数据,但是放在 dashbord 中就是显示为空,这种是什么原因,要怎么排查?

    9 replies    2025-11-25 00:39:30 +08:00
    sanyue
        1
    sanyue  
       Nov 24, 2025
    没用过的小白路过,我的话,会找一个有数据的,对比一下配置、数据差异
    cuiweiqiang
        2
    cuiweiqiang  
       Nov 24, 2025
    应该是 instance="$instance" 吧
    bahuite
        3
    bahuite  
       Nov 24, 2025
    如果有数据,很明显是你的变量问题
    jimmzhou
        4
    jimmzhou  
       Nov 24, 2025
    图二 显示 结果 明明是 0 rows 啊 你把 B 那个 object 展开看看
    veni2023
        5
    veni2023  
       Nov 24, 2025
    两个查询的时间范围一致吗
    chenzw2
        6
    chenzw2  
    OP
       Nov 24, 2025
    ```
    {
    "request": {
    "url": "api/ds/query?ds_type=prometheus&requestId=SQR408",
    "method": "POST",
    "data": {
    "queries": [
    {
    "editorMode": "code",
    "exemplar": false,
    "expr": "clamp_min((1 - (node_memory_MemAvailable_bytes{instance=\"node-exporter:9100\", job=\"node-exporter\"} / node_memory_MemTotal_bytes{instance=\"node-exporter:9100\", job=\"node-exporter\"})) * 100, 0)",
    "format": "time_series",
    "instant": true,
    "range": false,
    "refId": "B",
    "step": 240,
    "datasource": {
    "type": "prometheus",
    "uid": "PBFA97CFB590B2093"
    },
    "requestId": "16B",
    "utcOffsetSec": 28800,
    "scopes": [],
    "adhocFilters": [],
    "interval": "",
    "legendFormat": "",
    "datasourceId": 1,
    "intervalMs": 15000,
    "maxDataPoints": 1066
    }
    ],
    "from": "1763949579191",
    "to": "1763950479191"
    },
    "hideFromInspector": false
    },
    "response": {
    "results": {
    "B": {
    "status": 200,
    "frames": [
    {
    "schema": {
    "refId": "B",
    "meta": {
    "typeVersion": [
    0,
    0
    ],
    "executedQueryString": "Expr: clamp_min((1 - (node_memory_MemAvailable_bytes{instance=\"node-exporter:9100\", job=\"node-exporter\"} / node_memory_MemTotal_bytes{instance=\"node-exporter:9100\", job=\"node-exporter\"})) * 100, 0)\nStep: 15s"
    },
    "fields": []
    },
    "data": {
    "values": []
    }
    }
    ],
    "refId": "B"
    }
    }
    }
    }

    ```
    @jimmzhou 如上是 object 的完整数据,求大佬指教,小白第一次用这个
    Kevinyy
        7
    Kevinyy  
       Nov 24, 2025
    不行换成 table 看看有没有数据,没有数据说明这个查询就是没有结果返回的。建议去 prometheus 管理页面单独执行看看
    alaneuler
        8
    alaneuler  
       Nov 24, 2025
    instance 用 ${node:raw} 试一下
    nuII
        9
    nuII  
       Nov 25, 2025
    你把 dashboard 查询语句里的$node 换成 node-exporter:9100 应该就有数据了,应该是变量的问题。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1035 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 18:32 · PVG 02:32 · LAX 11:32 · JFK 14:32
    ♥ Do have faith in what you're doing.