{
  "__inputs": [
    {
      "name": "DS_VECTORSTEP",
      "label": "VectorStep",
      "description": "Infinity data source pointing at VectorStep (see the guide)",
      "type": "datasource",
      "pluginId": "yesoreyeram-infinity-datasource",
      "pluginName": "Infinity"
    },
    {
      "name": "DS_PROMETHEUS",
      "label": "Prometheus",
      "description": "Prometheus scraping VectorStep's /metrics",
      "type": "datasource",
      "pluginId": "prometheus",
      "pluginName": "Prometheus"
    }
  ],
  "__requires": [
    {
      "type": "panel",
      "id": "nodeGraph",
      "name": "Node Graph",
      "version": ""
    },
    {
      "type": "panel",
      "id": "timeseries",
      "name": "Time series",
      "version": ""
    },
    {
      "type": "panel",
      "id": "stat",
      "name": "Stat",
      "version": ""
    },
    {
      "type": "panel",
      "id": "state-timeline",
      "name": "State timeline",
      "version": ""
    },
    {
      "type": "panel",
      "id": "alertlist",
      "name": "Alert list",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "yesoreyeram-infinity-datasource",
      "name": "Infinity",
      "version": "3.0.0"
    },
    {
      "type": "datasource",
      "id": "prometheus",
      "name": "Prometheus",
      "version": "1.0.0"
    }
  ],
  "title": "VectorStep pipelines",
  "uid": "vectorstep-pipelines",
  "description": "Every VectorStep pipeline as a graph (Node Graph panel, from VectorStep's /graph/grafana), with the service's Prometheus metrics and your Grafana alerts alongside.",
  "tags": [
    "vectorstep"
  ],
  "schemaVersion": 39,
  "version": 1,
  "editable": true,
  "graphTooltip": 1,
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "refresh": "30s",
  "templating": {
    "list": [
      {
        "name": "range",
        "label": "Stats range",
        "type": "custom",
        "query": "24h,7d,30d,all",
        "current": {
          "text": "7d",
          "value": "7d"
        },
        "options": [
          {
            "text": "24h",
            "value": "24h",
            "selected": false
          },
          {
            "text": "7d",
            "value": "7d",
            "selected": true
          },
          {
            "text": "30d",
            "value": "30d",
            "selected": false
          },
          {
            "text": "all",
            "value": "all",
            "selected": false
          }
        ]
      },
      {
        "name": "stage",
        "label": "Stage",
        "type": "custom",
        "query": "production,testing,all",
        "current": {
          "text": "production",
          "value": "production"
        },
        "options": [
          {
            "text": "production",
            "value": "production",
            "selected": true
          },
          {
            "text": "testing",
            "value": "testing",
            "selected": false
          },
          {
            "text": "all",
            "value": "all",
            "selected": false
          }
        ]
      },
      {
        "name": "pipeline",
        "label": "Pipelines (comma-separated, empty = all)",
        "type": "textbox",
        "query": "",
        "current": {
          "text": "",
          "value": ""
        },
        "options": [
          {
            "selected": true,
            "text": "",
            "value": ""
          }
        ]
      }
    ]
  },
  "panels": [
    {
      "id": 1,
      "type": "nodeGraph",
      "title": "Pipelines \u2014 rings: green completed, yellow escalated, red failed",
      "description": "Each circle is a step (or a pipeline, for the entry points). The ring shows what share of its runs in the chosen range completed, escalated or failed. Click a node for its details.",
      "gridPos": {
        "h": 18,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "datasource": {
        "type": "yesoreyeram-infinity-datasource",
        "uid": "${DS_VECTORSTEP}"
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "yesoreyeram-infinity-datasource",
            "uid": "${DS_VECTORSTEP}"
          },
          "type": "json",
          "source": "url",
          "parser": "backend",
          "format": "node-graph-nodes",
          "url": "/graph/grafana?time_range=${range}&stage=${stage}&pipeline=${pipeline:csv}",
          "url_options": {
            "method": "GET",
            "data": ""
          },
          "root_selector": "nodes",
          "columns": [],
          "filters": []
        },
        {
          "refId": "B",
          "datasource": {
            "type": "yesoreyeram-infinity-datasource",
            "uid": "${DS_VECTORSTEP}"
          },
          "type": "json",
          "source": "url",
          "parser": "backend",
          "format": "node-graph-edges",
          "url": "/graph/grafana?time_range=${range}&stage=${stage}&pipeline=${pipeline:csv}",
          "url_options": {
            "method": "GET",
            "data": ""
          },
          "root_selector": "edges",
          "columns": [],
          "filters": []
        }
      ],
      "options": {
        "nodes": {
          "arcs": [
            {
              "field": "arc__ok",
              "color": "green"
            },
            {
              "field": "arc__escalated",
              "color": "yellow"
            },
            {
              "field": "arc__failed",
              "color": "red"
            }
          ]
        },
        "edges": {}
      },
      "fieldConfig": {
        "defaults": {},
        "overrides": []
      }
    },
    {
      "id": 2,
      "type": "timeseries",
      "title": "Runs by status",
      "gridPos": {
        "h": 8,
        "w": 8,
        "x": 0,
        "y": 18
      },
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "sum by (status) (increase(vectorstep_pipeline_runs_total[$__rate_interval]))",
          "legendFormat": "{{status}}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "custom": {
            "drawStyle": "bars",
            "fillOpacity": 60,
            "stacking": {
              "mode": "normal"
            }
          }
        },
        "overrides": []
      }
    },
    {
      "id": 3,
      "type": "stat",
      "title": "Approvals pending",
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 8,
        "y": 18
      },
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "sum(vectorstep_human_approvals_pending)"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "yellow",
                "value": 1
              }
            ]
          }
        },
        "overrides": []
      }
    },
    {
      "id": 4,
      "type": "stat",
      "title": "Runs in progress",
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 12,
        "y": 18
      },
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "vectorstep_pipeline_runs_in_progress"
        }
      ],
      "fieldConfig": {
        "defaults": {},
        "overrides": []
      }
    },
    {
      "id": 5,
      "type": "state-timeline",
      "title": "VectorStep scrape state",
      "gridPos": {
        "h": 8,
        "w": 8,
        "x": 16,
        "y": 18
      },
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "up{job=~\".*vectorstep.*\"}",
          "legendFormat": "{{instance}}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "mappings": [
            {
              "type": "value",
              "options": {
                "0": {
                  "text": "down",
                  "color": "red"
                },
                "1": {
                  "text": "up",
                  "color": "green"
                }
              }
            }
          ],
          "custom": {
            "fillOpacity": 70
          }
        },
        "overrides": []
      }
    },
    {
      "id": 6,
      "type": "alertlist",
      "title": "Grafana alerts",
      "gridPos": {
        "h": 4,
        "w": 8,
        "x": 8,
        "y": 22
      },
      "options": {
        "alertName": "",
        "showInstances": false,
        "stateFilter": {
          "firing": true,
          "pending": true,
          "noData": false,
          "normal": false,
          "error": true
        },
        "sortOrder": 1,
        "maxItems": 10,
        "viewMode": "list",
        "groupMode": "default"
      }
    }
  ]
}