Dashboard JSON Modell

Ein Dashboard in SmartCollect SC² wird durch ein JSON-Objekt dargestellt, das Metadaten seines Dashboards speichert. Die Dashboard-Metadaten umfassen Dashboard-Eigenschaften, Metadaten aus Panels, Vorlagenvariablen, Panel-Abfragen usw.

Um das JSON eines Dashboards anzuzeigen, führen Sie die folgenden Schritte aus:

  1. Gehen Sie zu einem Dashboard
  2. Klicken Sie auf das Menü “Dashboard verwalten” in der oberen Navigationsleiste
  3. Wählen Sie “JSON anzeigen” aus dem Dropdown-Menü

JSON Felder

Wenn ein Benutzer ein neues Dashboard erstellt, wird ein neues Dashboard-JSON-Objekt mit den folgenden Feldern initialisiert:

Hinweis: Im folgenden JSON wird id als Null angezeigt, was der Standardwert ist, der ihm zugewiesen wird, bis ein Dashboard gespeichert ist. Sobald ein Dashboard gespeichert ist, wird dem Feld “id” ein Ganzzahlwert zugewiesen.

{
  "id": null,
  "uid": "cLV5GDCkz",
  "title": "New dashboard",
  "tags": [],
  "style": "dark",
  "timezone": "browser",
  "editable": true,
  "hideControls": false,
  "graphTooltip": 1,
  "panels": [],
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {
    "time_options": [],
    "refresh_intervals": []
  },
  "templating": {
    "list": []
  },
  "annotations": {
    "list": []
  },
  "refresh": "5s",
  "schemaVersion": 17,
  "version": 0,
  "links": []
}

Jedes Feld im Dashboard-JSON wird unten mit seiner Verwendung erklärt:

Name Usage
id unique numeric identifier for the dashboard. (generated by the db)
uid unique dashboard identifier that can be generated by anyone. string (8-40)
title current title of dashboard
tags tags associated with dashboard, an array of strings
style theme of dashboard, i.e. dark or light
timezone timezone of dashboard, i.e. utc or browser
editable whether a dashboard is editable or not
graphTooltip 0 for no shared crosshair or tooltip (default), 1 for shared crosshair, 2 for shared crosshair AND shared tooltip
time time range for dashboard, i.e. last 6 hours, last 7 days, etc
timepicker timepicker metadata, see timepicker section for details
templating templating metadata, see templating section for details
annotations annotations metadata, see annotations section for details
refresh auto-refresh interval
schemaVersion version of the JSON schema (integer), incremented each time a SmartCollect SC² update brings changes to said schema
version version of the dashboard (integer), incremented each time the dashboard is updated
panels panels array, see below for detail.

Panels

Panels sind die Bausteine eines Dashboards. Sie bestehen aus Datenquellenabfragen, Arten von Diagrammen, Aliases usw. Panel JSON besteht aus einem Array von JSON-Objekten, die jeweils ein anderes Panel darstellen. Die meisten Felder sind für alle Panels gleich, aber einige Felder hängen vom Paneltyp ab. Nachfolgend ein Beispiel für Panel JSON eines Text-Panels.

"panels": [
  {
    "type": "text",
    "title": "Panel Title",
    "gridPos": {
      "x": 0,
      "y": 0,
      "w": 12,
      "h": 9
    },
    "id": 4,
    "mode": "markdown",
    "content": "# title"
  }

Größe und Position des Panels

Die Eigenschaft gridPos beschreibt die Größe und Position des Panels in Gitterkoordinaten.

  • w 1-24 (die Breite des Dashboards ist in 24 Spalten unterteilt)
  • h In Rasterhöheneinheiten, jede repräsentiert 30 Pixel.
  • x Die x-Position, in der gleichen Einheit wie w.
  • yDie y-Position, in der gleichen Einheit wieh`.

Das Raster hat eine negative Schwerkraft, die Felder nach oben verschiebt, wenn über einem Feld ein leerer Platz ist.

Time Picker

"timepicker": {
    "collapse": false,
    "enable": true,
    "notice": false,
    "now": true,
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ],
    "status": "Stable",
    "type": "timepicker"
  }

Die Verwendung der Felder wird im Folgenden erläutert:

Name Usage
collapse whether timepicker is collapsed or not
enable whether timepicker is enabled or not
notice TODO
now TODO
refresh_intervals TODO
status TODO
type TODO

templating

Das Feld templating enthält ein Array von Template-Variablen mit ihren gespeicherten Werten zusammen mit einigen anderen Metadaten, zum Beispiel:

 "templating": {
    "enable": true,
    "list": [
      {
        "allFormat": "wildcard",
        "current": {
          "tags": [],
          "text": "prod",
          "value": "prod"
        },
        "datasource": null,
        "includeAll": true,
        "name": "env",
        "options": [
          {
            "selected": false,
            "text": "All",
            "value": "*"
          },
          {
            "selected": false,
            "text": "stage",
            "value": "stage"
          },
          {
            "selected": false,
            "text": "test",
            "value": "test"
          }
        ],
        "query": "tag_values(cpu.utilization.average,env)",
        "refresh": false,
        "type": "query"
      },
      {
        "allFormat": "wildcard",
        "current": {
          "text": "apache",
          "value": "apache"
        },
        "datasource": null,
        "includeAll": false,
        "multi": false,
        "multiFormat": "glob",
        "name": "app",
        "options": [
          {
            "selected": true,
            "text": "tomcat",
            "value": "tomcat"
          },
          {
            "selected": false,
            "text": "cassandra",
            "value": "cassandra"
          }
        ],
        "query": "tag_values(cpu.utilization.average,app)",
        "refresh": false,
        "regex": "",
        "type": "query"
      }
    ]
  }

Die Verwendung der oben genannten Felder im Schablonenbereich wird im Folgenden erläutert:

Name Usage
enable whether templating is enabled or not
list an array of objects each representing one template variable
allFormat format to use while fetching all values from data source, eg: wildcard, glob, regex, pipe, etc.
current shows current selected variable text/value on the dashboard
data source shows data source for the variables
includeAll whether all value option is available or not
multi whether multiple values can be selected or not from variable value list
multiFormat format to use while fetching timeseries from data source
name name of variable
options array of variable text/value pairs available for selection on dashboard
query data source query used to fetch values for a variable
refresh TODO
regex TODO
type type of variable, i.e. custom, query or interval