{
  "__inputs": [
    {
      "name": "DS_PIPETRICS",
      "label": "pipetrics",
      "description": "",
      "type": "datasource",
      "pluginId": "grafana-postgresql-datasource",
      "pluginName": "PostgreSQL"
    }
  ],
  "__elements": {},
  "__requires": [
    {
      "type": "panel",
      "id": "barchart",
      "name": "Bar chart",
      "version": ""
    },
    {
      "type": "panel",
      "id": "gauge",
      "name": "Gauge",
      "version": ""
    },
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "12.1.1"
    },
    {
      "type": "datasource",
      "id": "grafana-postgresql-datasource",
      "name": "PostgreSQL",
      "version": "12.1.1"
    },
    {
      "type": "panel",
      "id": "table",
      "name": "Table",
      "version": ""
    },
    {
      "type": "panel",
      "id": "timeseries",
      "name": "Time series",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "grafana",
          "uid": "-- Grafana --"
        },
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 1,
  "id": null,
  "links": [],
  "panels": [
    {
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 5,
      "panels": [],
      "title": "Overview",
      "type": "row"
    },
    {
      "datasource": {
        "type": "grafana-postgresql-datasource",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": 0
              },
              {
                "color": "yellow",
                "value": 75
              },
              {
                "color": "green",
                "value": 85
              }
            ]
          },
          "unit": "percent"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 7,
        "w": 12,
        "x": 0,
        "y": 1
      },
      "id": 11,
      "options": {
        "minVizHeight": 75,
        "minVizWidth": 75,
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "showThresholdLabels": false,
        "showThresholdMarkers": true,
        "sizing": "auto"
      },
      "pluginVersion": "12.1.1",
      "targets": [
        {
          "datasource": {
            "type": "grafana-postgresql-datasource",
            "uid": "${DS_PIPETRICS}"
          },
          "editorMode": "code",
          "format": "time_series",
          "rawQuery": true,
          "rawSql": "WITH w AS (\n  SELECT\n    r.full_name AS repo,\n    CASE WHEN '${showOrgName}' = 'no' THEN split_part(r.full_name, '/', 2) ELSE r.full_name END AS repo_label,\n    runs.conclusion\n  FROM minion_workflow_runs runs\n  JOIN minion_repositories r ON r.id = runs.repository_id\n  WHERE $__timeFilter(runs.started_at)\n    AND r.full_name IN ($repository)\n)\nSELECT\n  NOW() AS time,\n  repo_label AS metric,\n  100.0 * SUM(CASE WHEN conclusion = 'success' THEN 1 ELSE 0 END)::float / NULLIF(COUNT(*), 0) AS value\nFROM w\nGROUP BY repo_label\nORDER BY repo_label;\n",
          "refId": "A",
          "sql": {
            "columns": [
              {
                "parameters": [],
                "type": "function"
              }
            ],
            "groupBy": [
              {
                "property": {
                  "type": "string"
                },
                "type": "groupBy"
              }
            ],
            "limit": 50
          }
        }
      ],
      "title": "Overall repository success rate",
      "type": "gauge"
    },
    {
      "datasource": {
        "type": "grafana-postgresql-datasource",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {
            "align": "auto",
            "cellOptions": {
              "type": "auto"
            },
            "inspect": false
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": 0
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "overhead_pct"
            },
            "properties": [
              {
                "id": "unit",
                "value": "percent"
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 7,
        "w": 12,
        "x": 12,
        "y": 1
      },
      "id": 12,
      "options": {
        "cellHeight": "sm",
        "footer": {
          "countRows": false,
          "fields": "",
          "reducer": [
            "sum"
          ],
          "show": false
        },
        "showHeader": true,
        "sortBy": [
          {
            "desc": true,
            "displayName": "total_workflow_runs"
          }
        ]
      },
      "pluginVersion": "12.1.1",
      "targets": [
        {
          "datasource": {
            "type": "grafana-postgresql-datasource",
            "uid": "${DS_PIPETRICS}"
          },
          "editorMode": "code",
          "format": "table",
          "rawQuery": true,
          "rawSql": "WITH jobs_w AS (\n  SELECT\n    r.full_name AS repo,\n    CASE\n      WHEN '${showOrgName}' = 'no' THEN split_part(r.full_name, '/', 2)\n      ELSE r.full_name\n    END AS repo_label,\n    EXTRACT(EPOCH FROM (j.completed_at - j.started_at)) / 60.0 AS minutes\n  FROM minion_workflow_jobs j\n  JOIN minion_workflow_runs wr ON wr.id = j.run_id\n  JOIN minion_repositories r ON r.id = wr.repository_id\n  WHERE\n    $__timeFilter(j.started_at)\n    AND r.full_name IN ($repository)\n    AND j.started_at IS NOT NULL\n    AND j.completed_at IS NOT NULL\n),\nruns_w AS (\n  SELECT\n    CASE\n      WHEN '${showOrgName}' = 'no' THEN split_part(r.full_name, '/', 2)\n      ELSE r.full_name\n    END AS repo_label,\n    COUNT(*) AS total_workflow_runs,\n    COUNT(DISTINCT wr.workflow_file_id) AS workflow_files\n  FROM minion_workflow_runs wr\n  JOIN minion_repositories r ON r.id = wr.repository_id\n  WHERE\n    $__timeFilter(wr.started_at)\n    AND r.full_name IN ($repository)\n  GROUP BY repo_label\n)\nSELECT\n  j.repo_label AS repository_name,\n  SUM(CEIL(j.minutes)) AS github_minutes,\n  SUM(j.minutes)::float AS real_minutes,\n  100.0 * (SUM(CEIL(j.minutes)) - SUM(j.minutes)) / NULLIF(SUM(j.minutes), 0) AS overhead_pct,\n  COALESCE(r.workflow_files, 0) AS workflow_files,\n  COALESCE(r.total_workflow_runs, 0) AS total_workflow_runs\nFROM jobs_w j\nLEFT JOIN runs_w r ON r.repo_label = j.repo_label\nGROUP BY j.repo_label, r.workflow_files, r.total_workflow_runs\nORDER BY j.repo_label;\n",
          "refId": "A",
          "sql": {
            "columns": [
              {
                "parameters": [],
                "type": "function"
              }
            ],
            "groupBy": [
              {
                "property": {
                  "type": "string"
                },
                "type": "groupBy"
              }
            ],
            "limit": 50
          }
        }
      ],
      "title": "GitHub minutes overhead",
      "type": "table"
    },
    {
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 8
      },
      "id": 13,
      "panels": [],
      "title": "Usage by repositories",
      "type": "row"
    },
    {
      "datasource": {
        "type": "grafana-postgresql-datasource",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "barWidthFactor": 0.6,
            "drawStyle": "line",
            "fillOpacity": 40,
            "gradientMode": "opacity",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "insertNulls": false,
            "lineInterpolation": "smooth",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": 0
              }
            ]
          },
          "unit": "min"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byRegexp",
              "options": "/real_minutes.*/"
            },
            "properties": [
              {
                "id": "custom.lineStyle",
                "value": {
                  "dash": [
                    0,
                    10
                  ],
                  "fill": "dot"
                }
              },
              {
                "id": "custom.fillOpacity",
                "value": 20
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 9
      },
      "id": 1,
      "options": {
        "legend": {
          "calcs": [
            "sum"
          ],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true,
          "sortBy": "Total",
          "sortDesc": true
        },
        "tooltip": {
          "hideZeros": false,
          "mode": "multi",
          "sort": "asc"
        }
      },
      "pluginVersion": "12.1.1",
      "targets": [
        {
          "datasource": {
            "type": "grafana-postgresql-datasource",
            "uid": "${DS_PIPETRICS}"
          },
          "editorMode": "code",
          "format": "time_series",
          "hide": false,
          "rawQuery": true,
          "rawSql": "SELECT\n  $__timeGroup(jobs.started_at, $aggregation, 0) AS time,\n  (CASE WHEN '${showOrgName}' = 'no' THEN split_part(r.full_name, '/', 2) ELSE r.full_name END) || ' → real_minutes' AS metric,\n  SUM(EXTRACT(EPOCH FROM (jobs.completed_at - jobs.started_at)) / 60) AS value\nFROM minion_workflow_jobs jobs\nJOIN minion_workflow_runs wr ON jobs.run_id = wr.id\nJOIN minion_repositories r ON wr.repository_id = r.id\nWHERE\n  $__timeFilter(jobs.started_at)\n  AND r.full_name IN ($repository)\n  AND jobs.started_at IS NOT NULL\n  AND jobs.completed_at IS NOT NULL\nGROUP BY time, metric\n\nUNION ALL\n\nSELECT\n  $__timeGroup(jobs.started_at, $aggregation, 0) AS time,\n  (CASE WHEN '${showOrgName}' = 'no' THEN split_part(r.full_name, '/', 2) ELSE r.full_name END) || ' → github_minutes' AS metric,\n  SUM(CEIL(EXTRACT(EPOCH FROM (jobs.completed_at - jobs.started_at)) / 60)) AS value\nFROM minion_workflow_jobs jobs\nJOIN minion_workflow_runs wr ON jobs.run_id = wr.id\nJOIN minion_repositories r ON wr.repository_id = r.id\nWHERE\n  $__timeFilter(jobs.started_at)\n  AND r.full_name IN ($repository)\n  AND jobs.started_at IS NOT NULL\n  AND jobs.completed_at IS NOT NULL\nGROUP BY time, metric\n\nORDER BY time;",
          "refId": "A",
          "sql": {
            "columns": [
              {
                "parameters": [],
                "type": "function"
              }
            ],
            "groupBy": [
              {
                "property": {
                  "type": "string"
                },
                "type": "groupBy"
              }
            ],
            "limit": 50
          },
          "table": "minion_workflow_jobs"
        }
      ],
      "title": "Minutes usage by repository",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "grafana-postgresql-datasource",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "barWidthFactor": 0.6,
            "drawStyle": "line",
            "fillOpacity": 10,
            "gradientMode": "opacity",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "insertNulls": false,
            "lineInterpolation": "smooth",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": 0
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "min"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 9
      },
      "id": 8,
      "options": {
        "legend": {
          "calcs": [
            "sum"
          ],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true,
          "sortBy": "Total",
          "sortDesc": true
        },
        "tooltip": {
          "hideZeros": false,
          "mode": "multi",
          "sort": "none"
        }
      },
      "pluginVersion": "12.1.1",
      "targets": [
        {
          "datasource": {
            "type": "grafana-postgresql-datasource",
            "uid": "${DS_PIPETRICS}"
          },
          "editorMode": "code",
          "format": "time_series",
          "rawQuery": true,
          "rawSql": "SELECT\n  $__timeGroup(jobs.started_at, $aggregation, 0) AS time,\n  CONCAT((CASE WHEN '${showOrgName}' = 'no' THEN split_part(r.full_name, '/', 2) ELSE r.full_name END), ' → ', runs.event) AS metric,\n  SUM(CEIL(EXTRACT(EPOCH FROM (jobs.completed_at - jobs.started_at)) / 60)) AS value\nFROM minion_workflow_jobs jobs\nJOIN minion_workflow_runs runs ON jobs.run_id = runs.id\nJOIN minion_repositories r ON runs.repository_id = r.id\nWHERE\n  $__timeFilter(jobs.started_at)\n  AND r.full_name IN ($repository)\n  AND jobs.started_at IS NOT NULL\n  AND jobs.completed_at IS NOT NULL\nGROUP BY time, metric\nORDER BY time;",
          "refId": "A",
          "sql": {
            "columns": [
              {
                "parameters": [],
                "type": "function"
              }
            ],
            "groupBy": [
              {
                "property": {
                  "type": "string"
                },
                "type": "groupBy"
              }
            ],
            "limit": 50
          }
        }
      ],
      "title": "GitHub minutes usage by trigger event",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "grafana-postgresql-datasource",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "barWidthFactor": 0.6,
            "drawStyle": "line",
            "fillOpacity": 10,
            "gradientMode": "opacity",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "insertNulls": false,
            "lineInterpolation": "smooth",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": 0
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 17
      },
      "id": 2,
      "options": {
        "legend": {
          "calcs": [
            "sum"
          ],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true,
          "sortBy": "Total",
          "sortDesc": true
        },
        "tooltip": {
          "hideZeros": false,
          "mode": "multi",
          "sort": "none"
        }
      },
      "pluginVersion": "12.1.1",
      "targets": [
        {
          "datasource": {
            "type": "grafana-postgresql-datasource",
            "uid": "${DS_PIPETRICS}"
          },
          "editorMode": "code",
          "format": "time_series",
          "rawQuery": true,
          "rawSql": "SELECT\n  $__timeGroup(runs.started_at, $aggregation, 0) AS time,\n  CONCAT((CASE WHEN '${showOrgName}' = 'no' THEN split_part(r.full_name, '/', 2) ELSE r.full_name END), ' → ', runs.event) AS metric,\n  COUNT(*) AS value\nFROM minion_workflow_runs runs\nJOIN minion_repositories r ON runs.repository_id = r.id\nWHERE\n  $__timeFilter(runs.started_at)\n  AND r.full_name IN ($repository)\nGROUP BY time, metric\nORDER BY time;",
          "refId": "A",
          "sql": {
            "columns": [
              {
                "parameters": [],
                "type": "function"
              }
            ],
            "groupBy": [
              {
                "property": {
                  "type": "string"
                },
                "type": "groupBy"
              }
            ],
            "limit": 50
          }
        }
      ],
      "title": "Workflow runs by event",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "grafana-postgresql-datasource",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "barWidthFactor": 0.6,
            "drawStyle": "line",
            "fillOpacity": 10,
            "gradientMode": "opacity",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "insertNulls": false,
            "lineInterpolation": "smooth",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": 0
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "s"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 17
      },
      "id": 4,
      "options": {
        "legend": {
          "calcs": [
            "sum"
          ],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true,
          "sortBy": "Total",
          "sortDesc": true
        },
        "tooltip": {
          "hideZeros": false,
          "mode": "multi",
          "sort": "none"
        }
      },
      "pluginVersion": "12.1.1",
      "targets": [
        {
          "datasource": {
            "type": "grafana-postgresql-datasource",
            "uid": "${DS_PIPETRICS}"
          },
          "editorMode": "code",
          "format": "time_series",
          "rawQuery": true,
          "rawSql": "SELECT\n  $__timeGroup(jobs.started_at, $aggregation, 0) AS time,\n  (CASE WHEN '${showOrgName}' = 'no' THEN split_part(r.full_name, '/', 2) ELSE r.full_name END) AS metric,\n  SUM(GREATEST(0, EXTRACT(EPOCH FROM (jobs.started_at - jobs.created_at)))) AS value\nFROM minion_workflow_jobs jobs\nJOIN minion_workflow_runs wr ON jobs.run_id = wr.id\nJOIN minion_repositories r ON wr.repository_id = r.id\nWHERE\n  $__timeFilter(jobs.started_at)\n  AND r.full_name IN ($repository)\n  AND jobs.started_at IS NOT NULL\n  AND jobs.created_at IS NOT NULL\nGROUP BY time, metric\nORDER BY time;",
          "refId": "A",
          "sql": {
            "columns": [
              {
                "parameters": [],
                "type": "function"
              }
            ],
            "groupBy": [
              {
                "property": {
                  "type": "string"
                },
                "type": "groupBy"
              }
            ],
            "limit": 50
          }
        }
      ],
      "title": "Time spent waiting in queues",
      "type": "timeseries"
    },
    {
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 25
      },
      "id": 6,
      "panels": [],
      "repeat": "repository",
      "title": "$repository",
      "type": "row"
    },
    {
      "datasource": {
        "type": "grafana-postgresql-datasource",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "fillOpacity": 60,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineWidth": 0,
            "scaleDistribution": {
              "type": "linear"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": 0
              }
            ]
          },
          "unit": "min"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 26
      },
      "id": 9,
      "options": {
        "barRadius": 0,
        "barWidth": 0.97,
        "fullHighlight": false,
        "groupWidth": 0.7,
        "legend": {
          "calcs": [
            "sum"
          ],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true
        },
        "orientation": "auto",
        "showValue": "auto",
        "stacking": "normal",
        "tooltip": {
          "hideZeros": false,
          "mode": "multi",
          "sort": "desc"
        },
        "xTickLabelRotation": 0,
        "xTickLabelSpacing": 100
      },
      "pluginVersion": "12.1.1",
      "targets": [
        {
          "datasource": {
            "type": "grafana-postgresql-datasource",
            "uid": "${DS_PIPETRICS}"
          },
          "editorMode": "code",
          "format": "time_series",
          "hide": false,
          "rawQuery": true,
          "rawSql": "SELECT\n  $__timeGroup(minion_workflow_jobs.started_at, $aggregation, 0) AS time,\n  CONCAT(\n    minion_workflow_files.name,\n    ' (',\n    CASE WHEN '${showFullFilePath}' = 'no'\n      THEN regexp_replace(minion_workflow_files.path, '^.*/', '')\n      ELSE minion_workflow_files.path\n    END,\n    ')'\n  ) AS metric,\n  SUM(CEIL(EXTRACT(EPOCH FROM (minion_workflow_jobs.completed_at - minion_workflow_jobs.started_at)) / 60.0)) AS value\nFROM minion_workflow_jobs\nJOIN minion_workflow_runs ON minion_workflow_runs.id = minion_workflow_jobs.run_id\nJOIN minion_repositories ON minion_repositories.id = minion_workflow_runs.repository_id\nJOIN minion_workflow_files ON minion_workflow_files.id = minion_workflow_runs.workflow_file_id\nWHERE\n  $__timeFilter(minion_workflow_jobs.started_at)\n  AND minion_workflow_jobs.started_at IS NOT NULL\n  AND minion_workflow_jobs.completed_at IS NOT NULL\n  AND minion_repositories.full_name IN ($repository)\nGROUP BY time, minion_repositories.full_name, minion_workflow_files.name, minion_workflow_files.path\nORDER BY time;",
          "refId": "A",
          "sql": {
            "columns": [
              {
                "parameters": [],
                "type": "function"
              }
            ],
            "groupBy": [
              {
                "property": {
                  "type": "string"
                },
                "type": "groupBy"
              }
            ],
            "limit": 50
          },
          "table": "minion_workflow_jobs"
        }
      ],
      "title": "Minutes usage by workflow",
      "type": "barchart"
    },
    {
      "datasource": {
        "type": "grafana-postgresql-datasource",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "fillOpacity": 60,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineWidth": 0,
            "scaleDistribution": {
              "type": "linear"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": 0
              }
            ]
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "failure"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "red",
                  "mode": "fixed"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "success"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "green",
                  "mode": "fixed"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "skipped"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "mode": "fixed"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "cancelled"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "mode": "fixed"
                }
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 26
      },
      "id": 10,
      "options": {
        "barRadius": 0,
        "barWidth": 0.97,
        "fullHighlight": false,
        "groupWidth": 0.7,
        "legend": {
          "calcs": [
            "sum"
          ],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true,
          "sortBy": "Total",
          "sortDesc": true
        },
        "orientation": "auto",
        "showValue": "auto",
        "stacking": "normal",
        "tooltip": {
          "hideZeros": false,
          "mode": "multi",
          "sort": "asc"
        },
        "xTickLabelRotation": 0,
        "xTickLabelSpacing": 100
      },
      "pluginVersion": "12.1.1",
      "targets": [
        {
          "datasource": {
            "type": "grafana-postgresql-datasource",
            "uid": "${DS_PIPETRICS}"
          },
          "editorMode": "code",
          "format": "time_series",
          "rawQuery": true,
          "rawSql": "SELECT $__timeGroup(minion_workflow_runs.started_at, $aggregation, 0) AS time,\n  minion_workflow_runs.conclusion AS metric,\n  COUNT(*) AS value\nFROM minion_workflow_runs\nJOIN minion_repositories ON minion_workflow_runs.repository_id = minion_repositories.id\nWHERE\n  $__timeFilter(minion_workflow_runs.started_at)\n  AND minion_repositories.full_name IN ($repository)\nGROUP BY metric, time\nORDER BY time;",
          "refId": "A",
          "sql": {
            "columns": [
              {
                "parameters": [],
                "type": "function"
              }
            ],
            "groupBy": [
              {
                "property": {
                  "type": "string"
                },
                "type": "groupBy"
              }
            ],
            "limit": 50
          }
        }
      ],
      "title": "Executions by conclusion",
      "type": "barchart"
    },
    {
      "datasource": {
        "type": "grafana-postgresql-datasource",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "barWidthFactor": 0.6,
            "drawStyle": "line",
            "fillOpacity": 10,
            "gradientMode": "opacity",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "insertNulls": false,
            "lineInterpolation": "smooth",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": 0
              }
            ]
          },
          "unit": "min"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byRegexp",
              "options": "/real_minutes.*/"
            },
            "properties": [
              {
                "id": "custom.lineStyle",
                "value": {
                  "dash": [
                    0,
                    10
                  ],
                  "fill": "dot"
                }
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 34
      },
      "id": 14,
      "options": {
        "legend": {
          "calcs": [
            "sum"
          ],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true,
          "sortBy": "Total",
          "sortDesc": true
        },
        "tooltip": {
          "hideZeros": false,
          "mode": "multi",
          "sort": "asc"
        }
      },
      "pluginVersion": "12.1.1",
      "targets": [
        {
          "datasource": {
            "type": "grafana-postgresql-datasource",
            "uid": "${DS_PIPETRICS}"
          },
          "editorMode": "code",
          "format": "time_series",
          "hide": false,
          "rawQuery": true,
          "rawSql": "SELECT\n    $__timeGroup(jobs.started_at, $aggregation, 0) AS time,\n  CONCAT(\n    minion_workflow_files.name,\n    ' (',\n    CASE\n      WHEN '${showFullFilePath}' = 'no' THEN regexp_replace(minion_workflow_files.path, '^.*/', '')\n      ELSE minion_workflow_files.path\n    END,\n    ')'\n  ) || ' → ' || jobs.name AS metric,\n  percentile_disc(0.95) WITHIN GROUP (\n    ORDER BY\n    EXTRACT(\n    EPOCH\n    FROM\n    (jobs.completed_at - jobs.started_at)\n    ) / 60.0\n    ) AS value\nFROM\n    minion_workflow_jobs AS jobs\n    JOIN minion_workflow_runs ON jobs.run_id = minion_workflow_runs.id\n    JOIN minion_repositories ON minion_workflow_runs.repository_id = minion_repositories.id\n    JOIN minion_workflow_files ON minion_workflow_files.id = minion_workflow_runs.workflow_file_id\nWHERE\n    $__timeFilter(jobs.started_at)\n  AND minion_repositories.full_name IN ($repository)\n  AND minion_workflow_files.path IN ($workflow)\n  AND jobs.started_at IS NOT NULL\n  AND jobs.completed_at IS NOT NULL\nGROUP BY\n    time,\n    metric\nORDER BY\n    time;",
          "refId": "A",
          "sql": {
            "columns": [
              {
                "parameters": [],
                "type": "function"
              }
            ],
            "groupBy": [
              {
                "property": {
                  "type": "string"
                },
                "type": "groupBy"
              }
            ],
            "limit": 50
          },
          "table": "minion_workflow_jobs"
        }
      ],
      "title": "Workflow jobs time p95",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "grafana-postgresql-datasource",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "barWidthFactor": 0.6,
            "drawStyle": "line",
            "fillOpacity": 10,
            "gradientMode": "opacity",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "insertNulls": false,
            "lineInterpolation": "smooth",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": 0
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byRegexp",
              "options": "/.*failure/"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "red",
                  "mode": "fixed"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byRegexp",
              "options": "/.*success/"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "fixedColor": "green",
                  "mode": "fixed"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byRegexp",
              "options": "/.*skipped/"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "mode": "fixed"
                }
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 34
      },
      "id": 15,
      "options": {
        "legend": {
          "calcs": [
            "sum"
          ],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true,
          "sortBy": "Total",
          "sortDesc": true
        },
        "tooltip": {
          "hideZeros": false,
          "mode": "multi",
          "sort": "none"
        }
      },
      "pluginVersion": "12.1.1",
      "targets": [
        {
          "datasource": {
            "type": "grafana-postgresql-datasource",
            "uid": "${DS_PIPETRICS}"
          },
          "editorMode": "code",
          "format": "time_series",
          "rawQuery": true,
          "rawSql": "SELECT\n  $__timeGroup(runs.started_at, $aggregation, 0) AS time,\n  CONCAT(\n    minion_workflow_files.name,\n    ' (',\n    CASE\n      WHEN '${showFullFilePath}' = 'no' THEN regexp_replace(minion_workflow_files.path, '^.*/', '')\n      ELSE minion_workflow_files.path\n    END,\n    ')'\n  ) || ' → ' || runs.conclusion AS metric,\n  COUNT(*) AS value\nFROM\n  minion_workflow_runs AS runs\n  JOIN minion_repositories ON minion_repositories.id = runs.repository_id\n  JOIN minion_workflow_files ON minion_workflow_files.id = runs.workflow_file_id\nWHERE\n  $__timeFilter(runs.started_at)\n  AND minion_repositories.full_name IN ($repository)\n  AND minion_workflow_files.path IN ($workflow)\nGROUP BY\n  time,\n  metric\nORDER BY\n  time;",
          "refId": "A",
          "sql": {
            "columns": [
              {
                "parameters": [],
                "type": "function"
              }
            ],
            "groupBy": [
              {
                "property": {
                  "type": "string"
                },
                "type": "groupBy"
              }
            ],
            "limit": 50
          }
        }
      ],
      "title": "Finished workflow runs by result ",
      "type": "timeseries"
    }
  ],
  "schemaVersion": 41,
  "tags": [],
  "templating": {
    "list": [
      {
        "allowCustomValue": false,
        "current": {},
        "name": "datasource",
        "options": [],
        "query": "grafana-postgresql-datasource",
        "refresh": 1,
        "regex": "",
        "type": "datasource"
      },
      {
        "allowCustomValue": false,
        "current": {
          "text": "no",
          "value": "no"
        },
        "label": "Show organization name",
        "name": "showOrgName",
        "options": [
          {
            "selected": false,
            "text": "yes",
            "value": "yes"
          },
          {
            "selected": true,
            "text": "no",
            "value": "no"
          }
        ],
        "query": "yes, no",
        "type": "custom"
      },
      {
        "allowCustomValue": false,
        "current": {
          "text": "no",
          "value": "no"
        },
        "label": "Show full workflow file path",
        "name": "showFullFilePath",
        "options": [
          {
            "selected": false,
            "text": "yes",
            "value": "yes"
          },
          {
            "selected": true,
            "text": "no",
            "value": "no"
          }
        ],
        "query": "yes, no",
        "type": "custom"
      },
      {
        "allowCustomValue": false,
        "current": {},
        "datasource": {
          "type": "grafana-postgresql-datasource",
          "uid": "${datasource}"
        },
        "definition": "SELECT full_name FROM minion_repositories;",
        "includeAll": true,
        "multi": true,
        "name": "repository",
        "options": [],
        "query": "SELECT full_name FROM minion_repositories;",
        "refresh": 1,
        "regex": "",
        "sort": 1,
        "type": "query"
      },
      {
        "current": {},
        "datasource": {
          "type": "grafana-postgresql-datasource",
          "uid": "${DS_PIPETRICS}"
        },
        "definition": "SELECT CASE WHEN '${showFullFilePath}' = 'no' THEN regexp_replace(path, '^.*/', '') ELSE path END AS __text, path AS __value FROM minion_workflow_files JOIN minion_repositories r ON repository_id = r.id WHERE r.full_name IN ($repository) ORDER BY path; ",
        "includeAll": true,
        "multi": true,
        "name": "workflow",
        "options": [],
        "query": "SELECT CASE WHEN '${showFullFilePath}' = 'no' THEN regexp_replace(path, '^.*/', '') ELSE path END AS __text, path AS __value FROM minion_workflow_files JOIN minion_repositories r ON repository_id = r.id WHERE r.full_name IN ($repository) ORDER BY path; ",
        "refresh": 1,
        "regex": "",
        "type": "query"
      },
      {
        "auto": false,
        "auto_count": 30,
        "auto_min": "10s",
        "current": {
          "text": "1w",
          "value": "1w"
        },
        "name": "aggregation",
        "options": [
          {
            "selected": false,
            "text": "1h",
            "value": "1h"
          },
          {
            "selected": false,
            "text": "6h",
            "value": "6h"
          },
          {
            "selected": false,
            "text": "12h",
            "value": "12h"
          },
          {
            "selected": false,
            "text": "1d",
            "value": "1d"
          },
          {
            "selected": true,
            "text": "1w",
            "value": "1w"
          },
          {
            "selected": false,
            "text": "1M",
            "value": "1M"
          }
        ],
        "query": "1h,6h,12h,1d,1w,1M",
        "refresh": 2,
        "type": "interval"
      }
    ]
  },
  "time": {
    "from": "now/M",
    "to": "now/M"
  },
  "timepicker": {},
  "timezone": "browser",
  "title": "Github Actions - pipetrics.com insights",
  "uid": "8ac361ec-f335-4401-8d70-9fff391522a8",
  "version": 53,
  "weekStart": "",
  "gnetId": 24157,
  "description": "End-to-end GitHub Actions insights with Pipetrics: success rate, billed vs. actual minutes, usage by trigger, queue delays, and workflow reliability across repositories."
}