Dashboard Templating: Impossible task?

Hi, All!
I use Grafana v.8.5.3.

Datasource - Prometheus/blackbox_exporter.

I have a some groups of hosts and in prometeus blackbox_exporter they look like:

#-------------<Group_1>--------------------
      - targets:
        - 192.168.25.249
        labels:
          HOSTgroup: 'Group_1'
          HOSTname: 'Host_1_1'
          HOSTisp: 'ISP_111'
          HOSTaddress: '12345 First-City, Some st., 12'
      - targets:
        - 192.168.28.1
        labels:
          HOSTgroup: 'Group_1'
          HOSTname: 'Host_1_2'
          HOSTisp: 'Telecom Inc'
          HOSTaddress: '12354 First-City, Some_2 st., 13'
      - targets:
        - 192.168.192.65
        labels:
          HOSTgroup: 'Group_1'
          HOSTname: 'Host_1_3'
          HOSTisp: 'ISP_111'
          HOSTaddress: '12435 First-City, Some_3 st., 1'
#-------------</Group_1>--------------------
#-------------<Group_2>--------------------
      - targets:
        - 192.168.52.24
        labels:
          HOSTgroup: 'Group_2'
          HOSTname: 'Host_2_1'
          HOSTisp: 'ISP_222'
          HOSTaddress: '21345 Second-City, Some st., 21'
      - targets:
        - 192.168.28.1
        labels:
          HOSTgroup: 'Group_2'
          HOSTname: 'Host_2_2'
          HOSTisp: 'Inc Telecom'
          HOSTaddress: '21354 Second-City, 2_Some st., 331'
      - targets:
        - 192.168.192.65
        labels:
          HOSTgroup: 'Group_2'
          HOSTname: 'Host_2_3'
          HOSTisp: 'ISP_121'
          HOSTaddress: '21435 Second-City, Some_3 st., 555'
#-------------</Group_2>--------------------

I want to create templated dashboard to show all hosts in one place:

  • each group as a row;
  • in each row - multiple SingleStat panels with titles and descriptions from Prometheus labels.

I created a Dashboard Variables from queries to Prometheus:

- hGroup: label_values(up{job="blackbox_exporter"},HOSTgroup); Multi-value: On; Include All option: On
- hName: label_values(up{job="blackbox_exporter",HOSTgroup="$hGroup"},HOSTname); Multi-value: On; Include All option: Off
- hIp: label_values(up{job="blackbox_exporter",HOSTgroup="$hGroup",HOSTname="$hName"},instance); Multi-value: On; Include All option: Off
- hIsp: label_values(up{job="blackbox_exporter",HOSTgroup="$hGroup",HOSTname="$hName"},HOSTisp); Multi-value: On; Include All option: Off
- hAddress: label_values(up{job="blackbox_exporter",HOSTgroup="$hGroup",HOSTname="$hName"},HOSTaddress); Multi-value: On; Include All option: Off

And created Row with:

  • Name: ${hGroup}
  • Repeat: hGroup

In Row created SingleStat Panel:

  • Query: probe_success{HOSTgroup="${hGroup}",HOSTname="${hName}"}
  • Title: ${hIp}
  • Description: ${hName}\n\n${hIsp}\n\n${hAddress}
  • Repeat by: hName
  • Max per row: 8
  • Display Name: ${hName}

But… I see only rows with one panel in each.
What i do wrong? Or is it impossible?
Help please!

P.S. Sorry for my English.

It sounds like you want to use chained variables. Here are some useful starting points and example dashboards in our public sandbox :+1:

Thanks for answer and info but I always was read all the docs and examples.

In my case I have multiple grouped hosts with unique labels in a prometheus datasource. And my task is show it all at the same time in one dashboard with row=group and with labels values as additional info (description) for every host.
I see no way to use the labels values in a description or in the panel title, because I made attemp to use the chained variables but the goal has not been achieved.
May be exists way to use labels values in a description and in the panel title?

It should work. See for example this sample dashboard that has two variables (group & host) and has a row for each group and inside each row a Stats panel for each host:

This is the JSON model for the dashboard:

{
“annotations”: {
“list”: [
{
“builtIn”: 1,
“datasource”: {
“type”: “grafana”,
“uid”: “-- Grafana --”
},
“enable”: true,
“hide”: true,
“iconColor”: “rgba(0, 211, 255, 1)”,
“name”: “Annotations & Alerts”,
“target”: {
“limit”: 100,
“matchAny”: false,
“tags”: ,
“type”: “dashboard”
},
“type”: “dashboard”
}
]
},
“editable”: true,
“fiscalYearStartMonth”: 0,
“graphTooltip”: 0,
“iteration”: 1655299077941,
“links”: ,
“liveNow”: false,
“panels”: [
{
“collapsed”: false,
“gridPos”: {
“h”: 1,
“w”: 24,
“x”: 0,
“y”: 0
},
“id”: 4,
“panels”: ,
“repeat”: “group”,
“title”: “$group”,
“type”: “row”
},
{
“datasource”: {
“type”: “datasource”,
“uid”: “grafana”
},
“fieldConfig”: {
“defaults”: {
“color”: {
“mode”: “thresholds”
},
“mappings”: ,
“thresholds”: {
“mode”: “absolute”,
“steps”: [
{
“color”: “green”,
“value”: null
},
{
“color”: “red”,
“value”: 80
}
]
}
},
“overrides”:
},
“gridPos”: {
“h”: 6,
“w”: 8,
“x”: 0,
“y”: 1
},
“id”: 2,
“options”: {
“colorMode”: “value”,
“graphMode”: “area”,
“justifyMode”: “auto”,
“orientation”: “auto”,
“reduceOptions”: {
“calcs”: [
“lastNotNull”
],
“fields”: “”,
“values”: false
},
“textMode”: “auto”
},
“pluginVersion”: “8.5.5”,
“repeat”: “host”,
“repeatDirection”: “h”,
“title”: “$group - $host”,
“type”: “stat”
}
],
“schemaVersion”: 36,
“style”: “dark”,
“tags”: ,
“templating”: {
“list”: [
{
“current”: {
“selected”: true,
“text”: [
“g1”,
“g2”,
“g3”
],
“value”: [
“g1”,
“g2”,
“g3”
]
},
“hide”: 0,
“includeAll”: false,
“label”: “group”,
“multi”: true,
“name”: “group”,
“options”: [
{
“selected”: true,
“text”: “g1”,
“value”: “g1”
},
{
“selected”: true,
“text”: “g2”,
“value”: “g2”
},
{
“selected”: true,
“text”: “g3”,
“value”: “g3”
}
],
“query”: “g1,g2,g3”,
“queryValue”: “”,
“skipUrlSync”: false,
“type”: “custom”
},
{
“current”: {
“selected”: true,
“text”: [
“h1”,
“h2”,
“h3”
],
“value”: [
“h1”,
“h2”,
“h3”
]
},
“hide”: 0,
“includeAll”: false,
“label”: “host”,
“multi”: true,
“name”: “host”,
“options”: [
{
“selected”: true,
“text”: “h1”,
“value”: “h1”
},
{
“selected”: true,
“text”: “h2”,
“value”: “h2”
},
{
“selected”: true,
“text”: “h3”,
“value”: “h3”
}
],
“query”: “h1,h2,h3”,
“queryValue”: “”,
“skipUrlSync”: false,
“type”: “custom”
}
]
},
“time”: {
“from”: “now-6h”,
“to”: “now”
},
“timepicker”: {},
“timezone”: “”,
“title”: “test vars”,
“weekStart”: “”
}

1 Like

It’s very good but I use two variables in query. And want to show all hosts which separated by groups (in each group different number of hosts and it are unically).

Not sure I’m understanding you correctly. Can you provide an example with some values for groups/hosts and how you would like the panels to look like?

It’s a fragment of the hand-worked dashboard which I want to “automatize”/“templatize”.
Some explanation:

  1. Row titles (as group names)
  2. Stat panel (as host)
  3. Panel title (as host’s IP)
  4. and 5) Addition info / description (ISP, post index, post address etc.)
    6 Host’s name

Presented 2 groups of 10 and 36 hosts of 540.
Sample prometheus config - in start post.

I think I understand what you want to achieve, and it doesnt seem possible. You would need to be able to either

  1. Repeat by multiple variables
  2. Populate the single stat panel’s Title and Description fields from a query result (not a dashboard variable)

AFAIK, both of these options aren’t available.

If you only need the stats panel to display a single number/color (as opposed to a graph), then you might be able to achieve your goal by using a table panel (table per group)

1 Like

Okay, first option I resolved by “hardcoded” rows (10 rown is not very mach) and repeated Stat panels on it.

And now one problem - how to extract and use values from prometheus query labels.