{
  "__inputs": [
    {
      "name": "DS_PROMETHEUS",
      "label": "Prometheus",
      "type": "datasource",
      "pluginId": "prometheus",
      "pluginName": "Prometheus"
    }
  ],
  "title": "Axis devices (Prometheus Exporter ACAP)",
  "uid": "axis-prometheus-exporter",
  "description": "Air quality, Object Analytics, image health and device events from the Prometheus Exporter ACAP.",
  "tags": [
    "axis",
    "acap"
  ],
  "editable": true,
  "schemaVersion": 39,
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "refresh": "30s",
  "templating": {
    "list": [
      {
        "name": "datasource",
        "type": "datasource",
        "query": "prometheus",
        "label": "Data source",
        "current": {}
      },
      {
        "name": "job",
        "type": "query",
        "datasource": {
          "type": "prometheus",
          "uid": "${datasource}"
        },
        "query": "label_values(axis_exporter_build_info, job)",
        "refresh": 2,
        "includeAll": true,
        "multi": true,
        "label": "Job",
        "current": {}
      },
      {
        "name": "instance",
        "type": "query",
        "datasource": {
          "type": "prometheus",
          "uid": "${datasource}"
        },
        "query": "label_values(axis_device_info{job=~\"$job\"}, instance)",
        "refresh": 2,
        "includeAll": true,
        "multi": true,
        "label": "Device",
        "current": {}
      }
    ]
  },
  "panels": [
    {
      "type": "row",
      "title": "Overview",
      "id": 1,
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "panels": []
    },
    {
      "type": "stat",
      "title": "Devices",
      "id": 2,
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 0,
        "y": 1
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "count(axis_device_info{instance=~\"$instance\"})",
          "legendFormat": ""
        }
      ],
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "fixed",
            "fixedColor": "text"
          }
        },
        "overrides": []
      },
      "options": {
        "graphMode": "none",
        "colorMode": "value"
      }
    },
    {
      "type": "stat",
      "title": "Scrapes",
      "id": 3,
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 4,
        "y": 1
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "min(up{job=~\"$job\", instance=~\"$instance\"})",
          "legendFormat": ""
        }
      ],
      "fieldConfig": {
        "defaults": {
          "mappings": [
            {
              "type": "value",
              "options": {
                "0": {
                  "text": "Down",
                  "color": "red"
                },
                "1": {
                  "text": "Up",
                  "color": "green"
                }
              }
            }
          ],
          "color": {
            "mode": "thresholds"
          }
        },
        "overrides": []
      },
      "options": {
        "graphMode": "none"
      }
    },
    {
      "type": "stat",
      "title": "Event topics",
      "id": 4,
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 8,
        "y": 1
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "sum(axis_exporter_subscribed_topics{instance=~\"$instance\"})",
          "legendFormat": ""
        }
      ],
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "fixed",
            "fixedColor": "text"
          }
        },
        "overrides": []
      },
      "options": {
        "graphMode": "none",
        "colorMode": "value"
      }
    },
    {
      "type": "stat",
      "title": "Active alarms",
      "id": 5,
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 12,
        "y": 1
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "count(axis_image_health_alarm{instance=~\"$instance\", alarm!=\"any\"} == 1 or axis_air_quality_alarm{instance=~\"$instance\"} == 1) or vector(0)",
          "legendFormat": ""
        }
      ],
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 1
              }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "graphMode": "none"
      },
      "description": "Image health and air quality alarms that are active now."
    },
    {
      "type": "table",
      "title": "Devices",
      "id": 6,
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 4,
        "w": 8,
        "x": 16,
        "y": 1
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "axis_device_info{instance=~\"$instance\"}",
          "legendFormat": "",
          "instant": true,
          "format": "table"
        }
      ],
      "fieldConfig": {
        "defaults": {},
        "overrides": []
      },
      "options": {},
      "transformations": [
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Time": true,
              "Value": true,
              "__name__": true,
              "job": true
            }
          }
        }
      ]
    },
    {
      "type": "row",
      "title": "Air quality",
      "id": 7,
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 5
      },
      "panels": []
    },
    {
      "type": "timeseries",
      "title": "Particulate matter",
      "id": 8,
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 6
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "axis_air_quality_pm_micrograms_per_cubic_meter{instance=~\"$instance\"}",
          "legendFormat": "PM{{size}} {{instance}}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "conμgm3"
        },
        "overrides": []
      },
      "options": {}
    },
    {
      "type": "timeseries",
      "title": "CO₂",
      "id": 9,
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 6
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "axis_air_quality_co2_ppm{instance=~\"$instance\"}",
          "legendFormat": "{{instance}}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "ppm"
        },
        "overrides": []
      },
      "options": {}
    },
    {
      "type": "timeseries",
      "title": "VOC and NOx index",
      "id": 10,
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 8,
        "w": 8,
        "x": 0,
        "y": 14
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "axis_air_quality_voc_index{instance=~\"$instance\"}",
          "legendFormat": "VOC {{instance}}"
        },
        {
          "refId": "B",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "axis_air_quality_nox_index{instance=~\"$instance\"}",
          "legendFormat": "NOx {{instance}}"
        }
      ],
      "fieldConfig": {
        "defaults": {},
        "overrides": []
      },
      "options": {}
    },
    {
      "type": "timeseries",
      "title": "Temperature",
      "id": 11,
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 8,
        "w": 8,
        "x": 8,
        "y": 14
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "axis_air_quality_temperature{instance=~\"$instance\"}",
          "legendFormat": "{{instance}}"
        },
        {
          "refId": "B",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "axis_air_quality_heat_index{instance=~\"$instance\"}",
          "legendFormat": "Heat index {{instance}}"
        }
      ],
      "fieldConfig": {
        "defaults": {},
        "overrides": []
      },
      "options": {},
      "description": "In the temperature unit set on the device."
    },
    {
      "type": "timeseries",
      "title": "Humidity",
      "id": 12,
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 8,
        "w": 8,
        "x": 16,
        "y": 14
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "axis_air_quality_humidity_percent{instance=~\"$instance\"}",
          "legendFormat": "{{instance}}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "humidity"
        },
        "overrides": []
      },
      "options": {}
    },
    {
      "type": "stat",
      "title": "Air quality index",
      "id": 13,
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 6,
        "w": 6,
        "x": 0,
        "y": 22
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "axis_air_quality_index{instance=~\"$instance\"}",
          "legendFormat": "{{instance}}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "yellow",
                "value": 51
              },
              {
                "color": "orange",
                "value": 101
              },
              {
                "color": "red",
                "value": 151
              }
            ]
          }
        },
        "overrides": []
      },
      "options": {}
    },
    {
      "type": "state-timeline",
      "title": "Air quality alarms",
      "id": 14,
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 6,
        "w": 18,
        "x": 6,
        "y": 22
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "axis_air_quality_alarm{instance=~\"$instance\"}",
          "legendFormat": "{{alarm}} {{measurement}} {{instance}}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "mappings": [
            {
              "type": "value",
              "options": {
                "0": {
                  "text": "OK",
                  "color": "green"
                },
                "1": {
                  "text": "Active",
                  "color": "red"
                }
              }
            }
          ],
          "color": {
            "mode": "thresholds"
          },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 1
              }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "showValue": "never",
        "mergeValues": true,
        "rowHeight": 0.8
      }
    },
    {
      "type": "row",
      "title": "Object Analytics",
      "id": 15,
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 28
      },
      "panels": []
    },
    {
      "type": "timeseries",
      "title": "Occupancy",
      "id": 16,
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 29
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "axis_aoa_occupancy_all{instance=~\"$instance\"} * on(instance, scenario) group_left(name) axis_aoa_scenario_info",
          "legendFormat": "{{name}} {{instance}}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "custom": {
            "drawStyle": "line",
            "lineInterpolation": "stepAfter"
          },
          "decimals": 0
        },
        "overrides": []
      },
      "options": {}
    },
    {
      "type": "timeseries",
      "title": "Crossline counts per interval",
      "id": 17,
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 29
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "sum by (instance, scenario, class) (increase(axis_aoa_crossline_count_total{instance=~\"$instance\"}[$__interval]))",
          "legendFormat": "{{class}} scenario {{scenario}} {{instance}}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "custom": {
            "drawStyle": "bars",
            "fillOpacity": 60,
            "stacking": {
              "mode": "normal"
            }
          },
          "decimals": 0
        },
        "overrides": []
      },
      "options": {},
      "interval": "5m"
    },
    {
      "type": "state-timeline",
      "title": "Scenarios triggered",
      "id": 18,
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 6,
        "w": 24,
        "x": 0,
        "y": 37
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "axis_aoa_scenario_active{instance=~\"$instance\"} * on(instance, scenario) group_left(name) axis_aoa_scenario_info or axis_aoa_scenario_active{instance=~\"$instance\", scenario=\"any\"}",
          "legendFormat": "{{name}} {{instance}}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "mappings": [
            {
              "type": "value",
              "options": {
                "0": {
                  "text": "OK",
                  "color": "green"
                },
                "1": {
                  "text": "Active",
                  "color": "red"
                }
              }
            }
          ],
          "color": {
            "mode": "thresholds"
          },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 1
              }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "showValue": "never",
        "mergeValues": true,
        "rowHeight": 0.8
      }
    },
    {
      "type": "row",
      "title": "Image health",
      "id": 19,
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 43
      },
      "panels": []
    },
    {
      "type": "state-timeline",
      "title": "Image Health Analytics",
      "id": 20,
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 7,
        "w": 16,
        "x": 0,
        "y": 44
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "axis_image_health_alarm{instance=~\"$instance\", alarm!=\"any\"}",
          "legendFormat": "{{alarm}} {{instance}}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "mappings": [
            {
              "type": "value",
              "options": {
                "0": {
                  "text": "OK",
                  "color": "green"
                },
                "1": {
                  "text": "Active",
                  "color": "red"
                }
              }
            }
          ],
          "color": {
            "mode": "thresholds"
          },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 1
              }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "showValue": "never",
        "mergeValues": true,
        "rowHeight": 0.8
      }
    },
    {
      "type": "table",
      "title": "Alarms in range",
      "id": 21,
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 7,
        "w": 8,
        "x": 16,
        "y": 44
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "sum by (instance, topic) (increase(axis_event_activations_total{instance=~\"$instance\", topic=~\".*AXISImageHealthAnalytics/.*\"}[$__range]))",
          "legendFormat": "",
          "instant": true,
          "format": "table"
        }
      ],
      "fieldConfig": {
        "defaults": {},
        "overrides": []
      },
      "options": {},
      "transformations": [
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Time": true
            },
            "renameByName": {
              "Value": "Alarms"
            }
          }
        }
      ]
    },
    {
      "type": "row",
      "title": "Device events",
      "id": 22,
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 51
      },
      "panels": []
    },
    {
      "type": "table",
      "title": "Event states that are on",
      "id": 23,
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 0,
        "y": 52
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "axis_event_state{instance=~\"$instance\"} == 1",
          "legendFormat": "",
          "instant": true,
          "format": "table"
        }
      ],
      "fieldConfig": {
        "defaults": {},
        "overrides": []
      },
      "options": {},
      "description": "Event fields whose state is 1 now, for example a digital input, a relay, day mode or system ready.",
      "transformations": [
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Time": true,
              "Value": true,
              "__name__": true,
              "job": true
            }
          }
        }
      ]
    },
    {
      "type": "bargauge",
      "title": "Most frequent events in range",
      "id": 24,
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 12,
        "y": 52
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "topk(10, sum by (topic) (increase(axis_event_notifications_total{instance=~\"$instance\"}[$__range])))",
          "legendFormat": "{{topic}}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "orientation": "horizontal",
        "displayMode": "basic",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ]
        }
      }
    },
    {
      "type": "table",
      "title": "Event values",
      "id": 25,
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 8,
        "w": 24,
        "x": 0,
        "y": 61
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "axis_event_value{instance=~\"$instance\"}",
          "legendFormat": "",
          "instant": true,
          "format": "table"
        }
      ],
      "fieldConfig": {
        "defaults": {},
        "overrides": []
      },
      "options": {},
      "transformations": [
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Time": true,
              "__name__": true,
              "job": true
            }
          }
        }
      ]
    }
  ]
}