{
  "__inputs": [
    {
      "name": "DS_Metrics",
      "label": "Prometheus",
      "description": "",
      "type": "datasource",
      "pluginId": "prometheus",
      "pluginName": "Prometheus"
    }
  ],
  "title": "Exordos Elements",
  "uid": "exordos-elements",
  "description": "Status of Exordos elements and their resources, current and over time. Fed by the core state metrics (exordos_em_*), which exordos_core writes every 15s for the node_exporter textfile collector.",
  "tags": [
    "exordos",
    "elements"
  ],
  "editable": true,
  "graphTooltip": 1,
  "schemaVersion": 39,
  "version": 1,
  "refresh": "30s",
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timezone": "",
  "links": [],
  "annotations": {
    "list": []
  },
  "templating": {
    "list": [
      {
        "name": "DS_Metrics",
        "label": "Metrics",
        "type": "datasource",
        "query": "prometheus",
        "current": {},
        "hide": 0,
        "includeAll": false,
        "multi": false,
        "options": [],
        "refresh": 1,
        "regex": ""
      },
      {
        "name": "element",
        "label": "Element",
        "type": "query",
        "datasource": {
          "type": "prometheus",
          "uid": "${DS_Metrics}"
        },
        "definition": "label_values(exordos_em_element_status, element)",
        "query": {
          "qryType": 1,
          "query": "label_values(exordos_em_element_status, element)",
          "refId": "PrometheusVariableQueryEditor-VariableQuery"
        },
        "refresh": 2,
        "multi": true,
        "includeAll": true,
        "allValue": ".*",
        "current": {
          "selected": true,
          "text": [
            "All"
          ],
          "value": [
            "$__all"
          ]
        },
        "sort": 1
      },
      {
        "name": "kind",
        "label": "Kind",
        "type": "query",
        "datasource": {
          "type": "prometheus",
          "uid": "${DS_Metrics}"
        },
        "definition": "label_values(exordos_em_resource_status{element=~\"$element\"}, kind)",
        "query": {
          "qryType": 1,
          "query": "label_values(exordos_em_resource_status{element=~\"$element\"}, kind)",
          "refId": "PrometheusVariableQueryEditor-VariableQuery"
        },
        "refresh": 2,
        "multi": true,
        "includeAll": true,
        "allValue": ".*",
        "current": {
          "selected": true,
          "text": [
            "All"
          ],
          "value": [
            "$__all"
          ]
        },
        "sort": 1
      }
    ]
  },
  "panels": [
    {
      "id": 1,
      "type": "row",
      "title": "Overview",
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "panels": []
    },
    {
      "id": 2,
      "type": "stat",
      "title": "Elements",
      "description": "Number of elements (filtered by the variables).",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_Metrics}"
      },
      "gridPos": {
        "h": 4,
        "w": 3,
        "x": 0,
        "y": 1
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_Metrics}"
          },
          "expr": "count(exordos_em_element_status{element=~\"$element\"})",
          "instant": true,
          "range": false
        }
      ],
      "options": {
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "value",
        "justifyMode": "center",
        "orientation": "auto",
        "showPercentChange": false
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "fixed",
            "fixedColor": "text"
          },
          "unit": "short",
          "decimals": 0,
          "noValue": "0"
        },
        "overrides": []
      }
    },
    {
      "id": 3,
      "type": "stat",
      "title": "Elements ACTIVE",
      "description": "Elements that are ACTIVE now.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_Metrics}"
      },
      "gridPos": {
        "h": 4,
        "w": 3,
        "x": 3,
        "y": 1
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_Metrics}"
          },
          "expr": "count(exordos_em_element_status{element=~\"$element\"} == 3)",
          "instant": true,
          "range": false
        }
      ],
      "options": {
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "value",
        "justifyMode": "center",
        "orientation": "auto",
        "showPercentChange": false
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "fixed",
            "fixedColor": "green"
          },
          "unit": "short",
          "decimals": 0,
          "noValue": "0"
        },
        "overrides": []
      }
    },
    {
      "id": 4,
      "type": "stat",
      "title": "Elements IN_PROGRESS",
      "description": "Elements that are IN_PROGRESS now.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_Metrics}"
      },
      "gridPos": {
        "h": 4,
        "w": 3,
        "x": 6,
        "y": 1
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_Metrics}"
          },
          "expr": "count(exordos_em_element_status{element=~\"$element\"} == 2)",
          "instant": true,
          "range": false
        }
      ],
      "options": {
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "value",
        "justifyMode": "center",
        "orientation": "auto",
        "showPercentChange": false
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "fixed",
            "fixedColor": "orange"
          },
          "unit": "short",
          "decimals": 0,
          "noValue": "0"
        },
        "overrides": []
      }
    },
    {
      "id": 5,
      "type": "stat",
      "title": "Elements NEW",
      "description": "Elements that are NEW now.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_Metrics}"
      },
      "gridPos": {
        "h": 4,
        "w": 3,
        "x": 9,
        "y": 1
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_Metrics}"
          },
          "expr": "count(exordos_em_element_status{element=~\"$element\"} == 1)",
          "instant": true,
          "range": false
        }
      ],
      "options": {
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "value",
        "justifyMode": "center",
        "orientation": "auto",
        "showPercentChange": false
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "fixed",
            "fixedColor": "blue"
          },
          "unit": "short",
          "decimals": 0,
          "noValue": "0"
        },
        "overrides": []
      }
    },
    {
      "id": 6,
      "type": "stat",
      "title": "Resources",
      "description": "Number of resources (filtered by the variables).",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_Metrics}"
      },
      "gridPos": {
        "h": 4,
        "w": 3,
        "x": 12,
        "y": 1
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_Metrics}"
          },
          "expr": "count(exordos_em_resource_status{element=~\"$element\", kind=~\"$kind\"})",
          "instant": true,
          "range": false
        }
      ],
      "options": {
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "value",
        "justifyMode": "center",
        "orientation": "auto",
        "showPercentChange": false
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "fixed",
            "fixedColor": "text"
          },
          "unit": "short",
          "decimals": 0,
          "noValue": "0"
        },
        "overrides": []
      }
    },
    {
      "id": 7,
      "type": "stat",
      "title": "Resources ACTIVE",
      "description": "Resources that are ACTIVE now.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_Metrics}"
      },
      "gridPos": {
        "h": 4,
        "w": 3,
        "x": 15,
        "y": 1
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_Metrics}"
          },
          "expr": "count(exordos_em_resource_status{element=~\"$element\", kind=~\"$kind\"} == 3)",
          "instant": true,
          "range": false
        }
      ],
      "options": {
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "value",
        "justifyMode": "center",
        "orientation": "auto",
        "showPercentChange": false
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "fixed",
            "fixedColor": "green"
          },
          "unit": "short",
          "decimals": 0,
          "noValue": "0"
        },
        "overrides": []
      }
    },
    {
      "id": 8,
      "type": "stat",
      "title": "Resources IN_PROGRESS",
      "description": "Resources that are IN_PROGRESS now.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_Metrics}"
      },
      "gridPos": {
        "h": 4,
        "w": 3,
        "x": 18,
        "y": 1
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_Metrics}"
          },
          "expr": "count(exordos_em_resource_status{element=~\"$element\", kind=~\"$kind\"} == 2)",
          "instant": true,
          "range": false
        }
      ],
      "options": {
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "value",
        "justifyMode": "center",
        "orientation": "auto",
        "showPercentChange": false
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "fixed",
            "fixedColor": "orange"
          },
          "unit": "short",
          "decimals": 0,
          "noValue": "0"
        },
        "overrides": []
      }
    },
    {
      "id": 9,
      "type": "stat",
      "title": "Resources NEW",
      "description": "Resources that are NEW now.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_Metrics}"
      },
      "gridPos": {
        "h": 4,
        "w": 3,
        "x": 21,
        "y": 1
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_Metrics}"
          },
          "expr": "count(exordos_em_resource_status{element=~\"$element\", kind=~\"$kind\"} == 1)",
          "instant": true,
          "range": false
        }
      ],
      "options": {
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "value",
        "justifyMode": "center",
        "orientation": "auto",
        "showPercentChange": false
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "fixed",
            "fixedColor": "blue"
          },
          "unit": "short",
          "decimals": 0,
          "noValue": "0"
        },
        "overrides": []
      }
    },
    {
      "id": 10,
      "type": "row",
      "title": "Elements",
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 5
      },
      "panels": []
    },
    {
      "id": 11,
      "type": "table",
      "title": "Elements",
      "description": "Current status of every element. \"Not ACTIVE in range\" is how long the element spent outside ACTIVE within the selected time range. Click an element name to focus the dashboard on it.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_Metrics}"
      },
      "gridPos": {
        "h": 10,
        "w": 24,
        "x": 0,
        "y": 6
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_Metrics}"
          },
          "expr": "max without (instance, job) (exordos_em_element_status{element=~\"$element\"})",
          "format": "table",
          "instant": true,
          "range": false
        },
        {
          "refId": "B",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_Metrics}"
          },
          "expr": "max without (instance, job) (exordos_em_element_info{element=~\"$element\"})",
          "format": "table",
          "instant": true,
          "range": false
        },
        {
          "refId": "C",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_Metrics}"
          },
          "expr": "max without (instance, job) ((1 - share_eq_over_time(exordos_em_element_status{element=~\"$element\"}[$__range], 3)) * lifetime(exordos_em_element_status{element=~\"$element\"}[$__range]) and on(element) exordos_em_element_status{element=~\"$element\"})",
          "format": "table",
          "instant": true,
          "range": false
        }
      ],
      "transformations": [
        {
          "id": "merge",
          "options": {}
        },
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Time": true,
              "__name__": true,
              "Value #B": true,
              "element_uuid": true,
              "project_id": true
            },
            "indexByName": {
              "element": 0,
              "Value #A": 1,
              "version": 2,
              "install_type": 3,
              "Value #C": 4
            },
            "renameByName": {
              "element": "Element",
              "Value #A": "Status",
              "version": "Version",
              "install_type": "Install type",
              "Value #C": "Not ACTIVE in range"
            }
          }
        },
        {
          "id": "sortBy",
          "options": {
            "sort": [
              {
                "field": "Status"
              }
            ]
          }
        }
      ],
      "options": {
        "showHeader": true,
        "cellHeight": "sm",
        "footer": {
          "show": false
        }
      },
      "fieldConfig": {
        "defaults": {
          "custom": {
            "align": "auto",
            "filterable": true,
            "cellOptions": {
              "type": "auto"
            }
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Status"
            },
            "properties": [
              {
                "id": "mappings",
                "value": [
                  {
                    "type": "value",
                    "options": {
                      "1": {
                        "text": "NEW",
                        "color": "blue",
                        "index": 0
                      },
                      "2": {
                        "text": "IN_PROGRESS",
                        "color": "orange",
                        "index": 1
                      },
                      "3": {
                        "text": "ACTIVE",
                        "color": "green",
                        "index": 2
                      }
                    }
                  }
                ]
              },
              {
                "id": "custom.cellOptions",
                "value": {
                  "type": "color-background",
                  "mode": "basic"
                }
              },
              {
                "id": "custom.width",
                "value": 130
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Not ACTIVE in range"
            },
            "properties": [
              {
                "id": "unit",
                "value": "s"
              },
              {
                "id": "decimals",
                "value": 0
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Element"
            },
            "properties": [
              {
                "id": "links",
                "value": [
                  {
                    "title": "Focus on ${__value.text}",
                    "url": "/d/exordos-elements/exordos-elements?var-element=${__value.text}&${__url_time_range}&${DS_Metrics:queryparam}"
                  }
                ]
              }
            ]
          }
        ]
      }
    },
    {
      "id": 13,
      "type": "row",
      "title": "Resources",
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 16
      },
      "panels": []
    },
    {
      "id": 14,
      "type": "table",
      "title": "Resources not ACTIVE",
      "description": "Resources of the selected elements that are not ACTIVE right now.",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_Metrics}"
      },
      "gridPos": {
        "h": 10,
        "w": 24,
        "x": 0,
        "y": 17
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_Metrics}"
          },
          "expr": "max without (instance, job) (exordos_em_resource_status{element=~\"$element\", kind=~\"$kind\"} < 3)",
          "format": "table",
          "instant": true,
          "range": false
        }
      ],
      "transformations": [
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Time": true,
              "__name__": true
            },
            "indexByName": {
              "element": 0,
              "kind": 1,
              "resource": 2,
              "Value": 3,
              "resource_uuid": 4
            },
            "renameByName": {
              "element": "Element",
              "kind": "Kind",
              "resource": "Resource",
              "Value": "Status",
              "resource_uuid": "UUID"
            }
          }
        },
        {
          "id": "sortBy",
          "options": {
            "sort": [
              {
                "field": "Element"
              }
            ]
          }
        }
      ],
      "options": {
        "showHeader": true,
        "cellHeight": "sm",
        "footer": {
          "show": false
        }
      },
      "fieldConfig": {
        "defaults": {
          "custom": {
            "align": "auto",
            "filterable": true,
            "cellOptions": {
              "type": "auto"
            }
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Status"
            },
            "properties": [
              {
                "id": "mappings",
                "value": [
                  {
                    "type": "value",
                    "options": {
                      "1": {
                        "text": "NEW",
                        "color": "blue",
                        "index": 0
                      },
                      "2": {
                        "text": "IN_PROGRESS",
                        "color": "orange",
                        "index": 1
                      },
                      "3": {
                        "text": "ACTIVE",
                        "color": "green",
                        "index": 2
                      }
                    }
                  }
                ]
              },
              {
                "id": "custom.cellOptions",
                "value": {
                  "type": "color-background",
                  "mode": "basic"
                }
              },
              {
                "id": "custom.width",
                "value": 130
              }
            ]
          }
        ]
      }
    }
  ]
}
