首页  

grafana使用模板变量     所属分类 grafana 浏览量 6052
dashboard settings  / Variables
新建或修改

变量名  
类型  query datasource custom  constant 

数据源

label_values(press_now_time_ms,instance)
获取 press_now_time_ms 指标 instance 标签 值列表


label_values(dubbo_consumer_seconds_sum{job=~"$job", instance=~"$instance"}, interface)


图例 legend
{{interface}}【{{method}}】

是否支持多选
是否包含 all

Label 界面中变量的显示名称

hide       
label 隐藏 变量名   
variable   隐藏整个变量  变量名 和 下拉框

变量值支持单选或者多选
正则匹配  =~     
变量 使用     value1|value2|value3 代替


Preview of values (预览)
All 10.57.239.117:9000 10.57.239.117:9001

查询语句中使用变量
runTime_count{instance=~"$instance"}

rate(runTime_count{instance=~"$instance"}[1m])

dashboard 左上角  下拉框 
支持多选的 变量选择后 点击 变量名 才会生效

是否包含 ALL
 "includeAll": false
是否支持多选
  "multi": false



label_values(metric,label) is a Grafana function, not a Prometheus function. 


grafana里prometheus查询语法
label_values(label)	返回label标签值列表 
label_values(metric, label)	Returns a list of label values for the label in the specified metric.

metrics(metric)	返回与指定metric正则表达式匹配的指标列表
query_result(query)	返回Prometheus查询结果列表

 
JSON Model
The JSON Model below is data structure that defines the dashboard. 
Including settings, panel settings & layout, queries etc.

dashboard 配置   json 格式


模板变量定义 json 格式


 "templating": {
    "list": [
      {
        "allValue": null,
        "current": {
          "text": "All",
          "value": [
            "$__all"
          ]
        },
        "datasource": "Prometheus",
        "definition": "label_values(press_now_time_ms,instance)",
        "hide": 0,
        "includeAll": true,
        "label": "instance",
        "multi": true,
        "name": "instance",
        "options": [
          {
            "selected": true,
            "text": "All",
            "value": "$__all"
          },
          {
            "selected": false,
            "text": "10.57.239.117:9000",
            "value": "10.57.239.117:9000"
          },
          {
            "selected": false,
            "text": "10.57.239.117:9001",
            "value": "10.57.239.117:9001"
          }
        ],
        "query": "label_values(press_now_time_ms,instance)",
        "refresh": 0,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      }
    ]
  }

上一篇     下一篇
prometheus job 和 instance

rate与irate的区别

prometheus要点整理

dubbo架构及调用模型

dubbo支持的rpc协议及使用场景

dubbo常用配置