Grafana dashboard: K8S Packages Update Cadence
Description: Uses git history of a gitops repo to show update cadence in terms of deployment frequency and lead time. 

For usage, see the associated blog post [here](https://github.com/benjvi/benjvi.github.io/blob/master/_drafts/2021-08-24-measure-patching-cadence.markdown)

{
  "__inputs": [
    {
      "name": "DS_ASKGIT",
      "label": "askgit",
      "description": "Uses tables populated as described in the associated blog post",
      "type": "datasource",
      "pluginId": "postgres",
      "pluginName": "PostgreSQL"
    },
    {
      "name": "DS_PROMETHEUS",
      "label": "prometheus",
      "description": "Uses kube-trivy-exporter (https://github.com/kaidotdev/kube-trivy-exporter) data to populate critical CVEs panel",
      "type": "datasource",
      "pluginId": "prometheus",
      "pluginName": "Prometheus"
    }
  ],
  "__requires": [
    {
      "type": "panel",
      "id": "bargauge",
      "name": "Bar gauge",
      "version": ""
    },
    {
      "type": "panel",
      "id": "gauge",
      "name": "Gauge",
      "version": ""
    },
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "7.5.4"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": ""
    },
    {
      "type": "panel",
      "id": "piechart",
      "name": "Pie chart v2",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "postgres",
      "name": "PostgreSQL",
      "version": "1.0.0"
    },
    {
      "type": "datasource",
      "id": "prometheus",
      "name": "Prometheus",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "stat",
      "name": "Stat",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "gnetId": 14970,
  "graphTooltip": 0,
  "id": null,
  "links": [],
  "panels": [
    {
      "datasource": "${DS_ASKGIT}",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "decimals": 3,
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 6,
        "x": 0,
        "y": 0
      },
      "id": 8,
      "interval": "28d",
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "text": {
          "valueSize": 70
        },
        "textMode": "value_and_name"
      },
      "pluginVersion": "7.5.4",
      "targets": [
        {
          "format": "table",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "queryType": "randomWalk",
          "rawQuery": true,
          "rawSql": "select \n  (percentile_cont(0.5) WITHIN GROUP (ORDER BY days_between_vendor_and_deploy)) as \"last 3 months\"\nfrom package_commit_pair_cause_to_deploy\nWHERE deploy_commit_parent_folder='prod'\nand deploy_commit_author_when > now() - interval '3 months'",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "days_between_vendor_and_deploy"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "package_deploy_and_cause_pair",
          "timeColumn": "deploy_commit_author_when",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        },
        {
          "format": "table",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "select \n  (percentile_cont(0.5) WITHIN GROUP (ORDER BY days_between_vendor_and_deploy)) as \"current month\"\nfrom package_commit_pair_cause_to_deploy\nWHERE deploy_commit_parent_folder='prod'\nand date_trunc('month',deploy_commit_author_when)=date_trunc('month', now())",
          "refId": "B",
          "select": [
            [
              {
                "params": [
                  "days_between_vendor_and_deploy"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "package_deploy_and_cause_pair",
          "timeColumn": "deploy_commit_author_when",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Deployment Lead Time (days)",
      "transparent": true,
      "type": "stat"
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_ASKGIT}",
      "description": "Aggregates based on time taken to deploy vendored packages",
      "fieldConfig": {
        "defaults": {},
        "overrides": []
      },
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 9,
        "w": 7,
        "x": 6,
        "y": 0
      },
      "hiddenSeries": false,
      "id": 6,
      "interval": "2w",
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "alertThreshold": true
      },
      "percentage": false,
      "pluginVersion": "7.5.4",
      "pointradius": 2,
      "points": true,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "format": "time_series",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "queryType": "randomWalk",
          "rawQuery": true,
          "rawSql": "select \n    date_trunc('month',deploy_commit_author_when) as \"time\",\n    min(days_between_vendor_and_deploy),\n    percentile_cont(0.5) WITHIN GROUP (ORDER BY days_between_vendor_and_deploy) as \"median\",\n    max(days_between_vendor_and_deploy)\nfrom package_commit_pair_cause_to_deploy\nWHERE\n  $__timeFilter(deploy_commit_author_when)\ngroup by 1",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "duration"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "google_fit_sessions",
          "timeColumn": "start_time",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Patch Deployment Lead Time (Monthly)",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "transparent": true,
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "$$hashKey": "object:397",
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "$$hashKey": "object:398",
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_ASKGIT}",
      "description": "Based on the time between vendoring and deploying a package. If multiple versions updates have been vendored before deployment, the time to the oldest is taken",
      "fieldConfig": {
        "defaults": {},
        "overrides": []
      },
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 9,
        "w": 8,
        "x": 13,
        "y": 0
      },
      "hiddenSeries": false,
      "id": 2,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 0,
      "nullPointMode": "null",
      "options": {
        "alertThreshold": true
      },
      "percentage": false,
      "pluginVersion": "7.5.4",
      "pointradius": 5,
      "points": true,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "format": "time_series",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "queryType": "randomWalk",
          "rawQuery": true,
          "rawSql": "SELECT \n  deploy_commit_author_when AS \"time\",\n  max(days_between_vendor_and_deploy),\n  deploy_commit_package\nFROM package_commit_pair_cause_to_deploy\nWHERE\n  $__timeFilter(deploy_commit_author_when)\n  and cause_commit_author_when is not null\nGROUP BY 1,3\nORDER BY 1",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "days_between_vendor_and_deploy"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "package_deploy_and_cause_pair",
          "timeColumn": "deploy_commit_author_when",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Time Taken to Deploy Each Package Update",
      "tooltip": {
        "shared": false,
        "sort": 0,
        "value_type": "individual"
      },
      "transparent": true,
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "$$hashKey": "object:340",
          "format": "short",
          "label": "days",
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "$$hashKey": "object:341",
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "cacheTimeout": null,
      "datasource": "${DS_PROMETHEUS}",
      "fieldConfig": {
        "defaults": {
          "mappings": [
            {
              "$$hashKey": "object:178",
              "id": 0,
              "op": "=",
              "text": "N/A",
              "type": 1,
              "value": "null"
            }
          ],
          "max": 2,
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "dark-red",
                "value": null
              }
            ]
          },
          "unit": "none"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 3,
        "x": 21,
        "y": 0
      },
      "id": 20,
      "links": [],
      "options": {
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "first"
          ],
          "fields": "",
          "values": false
        },
        "showThresholdLabels": false,
        "showThresholdMarkers": false,
        "text": {}
      },
      "pluginVersion": "7.5.4",
      "targets": [
        {
          "dateTimeType": "DATETIME",
          "exemplar": true,
          "expr": "max_over_time(count(sum(trivy_vulnerabilities{severity=\"CRITICAL\"}) by (image))[$__range:$__interval])",
          "format": "table",
          "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t",
          "group": [
            {
              "params": [
                "$__interval",
                "none"
              ],
              "type": "time"
            }
          ],
          "hide": false,
          "instant": true,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "",
          "metricColumn": "none",
          "query": "SELECT\n    $timeSeries as t,\n    count()\nFROM $table\nWHERE $timeFilter\nGROUP BY t\nORDER BY t",
          "rawQuery": true,
          "rawSql": "SELECT\n  count(id) AS \"id\"\nFROM vulnerability\nWHERE\n  severity = 'critical'",
          "refId": "A",
          "round": "0s",
          "select": [
            [
              {
                "params": [
                  "id"
                ],
                "type": "column"
              },
              {
                "params": [
                  "count"
                ],
                "type": "aggregate"
              },
              {
                "params": [
                  "id"
                ],
                "type": "alias"
              }
            ]
          ],
          "table": "vulnerability",
          "timeColumn": "create_date",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            },
            {
              "datatype": "int4",
              "name": "",
              "params": [
                "host_id",
                "!=",
                "None"
              ],
              "type": "expression"
            }
          ]
        }
      ],
      "timeFrom": null,
      "title": "Critically Vulnerable Images (trivy-exporter)",
      "type": "gauge"
    },
    {
      "datasource": "${DS_ASKGIT}",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 6,
        "x": 0,
        "y": 9
      },
      "id": 29,
      "interval": "28d",
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "text": {
          "valueSize": 100
        },
        "textMode": "value_and_name"
      },
      "pluginVersion": "7.5.4",
      "targets": [
        {
          "format": "table",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "queryType": "randomWalk",
          "rawQuery": true,
          "rawSql": "select \n    count(distinct (deploy_commit_id || deploy_commit_package))/3 as \"last 3 months\"\nfrom package_commit_pair_cause_to_deploy\nWHERE deploy_commit_parent_folder='prod'\nand deploy_commit_author_when > now() - interval '3 months'",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "days_between_vendor_and_deploy"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "package_deploy_and_cause_pair",
          "timeColumn": "deploy_commit_author_when",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        },
        {
          "format": "table",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "select \n    count(distinct (deploy_commit_id || deploy_commit_package))*(30/extract(day from now())) as \"current month\"\nfrom package_commit_pair_cause_to_deploy\nWHERE deploy_commit_parent_folder='prod'\nand date_trunc('month',deploy_commit_author_when)=date_trunc('month', now())",
          "refId": "B",
          "select": [
            [
              {
                "params": [
                  "days_between_vendor_and_deploy"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "package_deploy_and_cause_pair",
          "timeColumn": "deploy_commit_author_when",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Deployment Frequency (deploys per month)",
      "type": "stat"
    },
    {
      "aliasColors": {},
      "bars": true,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_ASKGIT}",
      "description": "",
      "fieldConfig": {
        "defaults": {},
        "overrides": []
      },
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 9,
        "w": 8,
        "x": 6,
        "y": 9
      },
      "hiddenSeries": false,
      "id": 27,
      "interval": "28d",
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": false,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "alertThreshold": true
      },
      "percentage": false,
      "pluginVersion": "7.5.4",
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [
        {
          "$$hashKey": "object:251",
          "alias": "total",
          "bars": false,
          "fill": 0,
          "lines": true,
          "pointradius": 5,
          "points": true,
          "stack": false
        }
      ],
      "spaceLength": 10,
      "stack": true,
      "steppedLine": false,
      "targets": [
        {
          "format": "time_series",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "queryType": "randomWalk",
          "rawQuery": true,
          "rawSql": "select \n    date_trunc('month',deploy_commit_author_when) as \"time\",\n    deploy_commit_package,\n    count(distinct (deploy_commit_id || deploy_commit_package)) as \"deploy package patch events\"\nfrom package_commit_pair_cause_to_deploy\nWHERE\n  $__timeFilter(deploy_commit_author_when) \n  and deploy_commit_parent_folder='prod'\ngroup by 1,2\norder by 1,2",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "duration"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "google_fit_sessions",
          "timeColumn": "start_time",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        },
        {
          "format": "time_series",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "select \n    date_trunc('month',deploy_commit_author_when) as \"time\",\n    count(distinct (deploy_commit_id || deploy_commit_package)) as \"total\"\nfrom package_commit_pair_cause_to_deploy\nWHERE\n  $__timeFilter(deploy_commit_author_when) \n  and deploy_commit_parent_folder='prod'\ngroup by 1\norder by 1",
          "refId": "B",
          "select": [
            [
              {
                "params": [
                  "avg_days_between_vendor_and_deploy"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "packages_summary_deploy_and_cause_timing_decile",
          "timeColumn": "deploy_month",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [
        {
          "$$hashKey": "object:275",
          "colorMode": "gray",
          "fill": true,
          "fillColor": "rgba(234, 112, 112, 0.12)",
          "from": "00:00",
          "fromDayOfWeek": 1,
          "line": true,
          "lineColor": "rgba(237, 46, 24, 0.60)",
          "op": "time",
          "toDayOfWeek": 7
        }
      ],
      "timeShift": null,
      "title": "Num Patches Deployed (Monthly)",
      "tooltip": {
        "shared": false,
        "sort": 1,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "$$hashKey": "object:397",
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "$$hashKey": "object:398",
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "datasource": "${DS_ASKGIT}",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 2,
        "x": 14,
        "y": 9
      },
      "id": 7,
      "interval": "4w",
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "text": {},
        "textMode": "value_and_name"
      },
      "pluginVersion": "7.5.4",
      "targets": [
        {
          "format": "table",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "queryType": "randomWalk",
          "rawQuery": true,
          "rawSql": "select \n    count(distinct (id || package))/3 as \"last 3 months\"\nfrom package_folder_commits\nWHERE parent_folder='automated-vendoring'\nand author_when > now() - interval '3 months'\n",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "duration"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "google_fit_sessions",
          "timeColumn": "start_time",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        },
        {
          "format": "table",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "select \n    count(distinct (id || package))*(30/extract(day from now())) as \"current month\"\nfrom package_folder_commits\nWHERE parent_folder='automated-vendoring'\nand date_trunc('month',author_when)=date_trunc('month', now())",
          "refId": "B",
          "select": [
            [
              {
                "params": [
                  "avg_days_between_vendor_and_deploy"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "packages_summary_deploy_and_cause_timing_decile",
          "timeColumn": "deploy_month",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Vendor Frequency (packages vendored / month)",
      "type": "stat"
    },
    {
      "aliasColors": {},
      "bars": true,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_ASKGIT}",
      "description": "",
      "fieldConfig": {
        "defaults": {},
        "overrides": []
      },
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 9,
        "w": 8,
        "x": 16,
        "y": 9
      },
      "hiddenSeries": false,
      "id": 28,
      "interval": "4w",
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": false,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "alertThreshold": true
      },
      "percentage": false,
      "pluginVersion": "7.5.4",
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [
        {
          "$$hashKey": "object:188",
          "alias": "total",
          "bars": false,
          "fill": 0,
          "lines": true,
          "pointradius": 5,
          "points": true,
          "stack": false
        }
      ],
      "spaceLength": 10,
      "stack": true,
      "steppedLine": false,
      "targets": [
        {
          "format": "time_series",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "queryType": "randomWalk",
          "rawQuery": true,
          "rawSql": "select \n    date_trunc('month',author_when) as \"time\",\n    package,\n    count(distinct (id || package)) as \"vendored package events\"\nfrom package_folder_commits\nWHERE\n  $__timeFilter(author_when) \n  and parent_folder='automated-vendoring'\ngroup by 1,2\norder by 1,2",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "duration"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "google_fit_sessions",
          "timeColumn": "start_time",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        },
        {
          "format": "time_series",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "select \n    date_trunc('month',author_when) as \"time\",\n    count(distinct (id || package)) as \"total\"\nfrom package_folder_commits\nWHERE\n  $__timeFilter(author_when) \n  and parent_folder='automated-vendoring'\ngroup by 1\norder by 1",
          "refId": "B",
          "select": [
            [
              {
                "params": [
                  "avg_days_between_vendor_and_deploy"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "packages_summary_deploy_and_cause_timing_decile",
          "timeColumn": "deploy_month",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [
        {
          "$$hashKey": "object:517",
          "colorMode": "gray",
          "fill": true,
          "fillColor": "rgba(234, 112, 112, 0.12)",
          "from": "00:00",
          "fromDayOfWeek": 1,
          "line": true,
          "lineColor": "rgba(237, 46, 24, 0.60)",
          "op": "time",
          "toDayOfWeek": 7
        }
      ],
      "timeShift": null,
      "title": "Num Patches Vendored (Monthly)",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "$$hashKey": "object:397",
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "$$hashKey": "object:398",
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "datasource": "${DS_ASKGIT}",
      "description": "Time taken to deploy a vendored patch for last month, split out by decile",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 14
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 11,
        "w": 6,
        "x": 0,
        "y": 18
      },
      "id": 11,
      "options": {
        "displayMode": "lcd",
        "orientation": "vertical",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "/^decile$/",
          "values": true
        },
        "showUnfilled": true,
        "text": {}
      },
      "pluginVersion": "7.5.4",
      "targets": [
        {
          "format": "table",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "queryType": "randomWalk",
          "rawQuery": true,
          "rawSql": "select\n  avg(avg_days_between_vendor_and_deploy) as  \"decile\",\n  decile as \"group\"\nfrom packages_summary_deploy_and_cause_timing_decile\nWHERE\n  deploy_month = date_trunc('month', now() - interval '2 month')\nGroup BY 2\nORDER BY 2",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "duration"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "google_fit_sessions",
          "timeColumn": "start_time",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "timeFrom": null,
      "title": "Variability of Patch Deployment Lead Time (-2 Months)",
      "transparent": true,
      "type": "bargauge"
    },
    {
      "datasource": "${DS_ASKGIT}",
      "description": "Time taken to deploy a vendored patch for last month, split out by decile",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 14
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 11,
        "w": 6,
        "x": 6,
        "y": 18
      },
      "id": 10,
      "options": {
        "displayMode": "lcd",
        "orientation": "vertical",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "/^decile$/",
          "values": true
        },
        "showUnfilled": true,
        "text": {}
      },
      "pluginVersion": "7.5.4",
      "repeat": null,
      "targets": [
        {
          "format": "table",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "queryType": "randomWalk",
          "rawQuery": true,
          "rawSql": "select\n  avg(avg_days_between_vendor_and_deploy) as  \"decile\",\n  decile as \"group\"\nfrom packages_summary_deploy_and_cause_timing_decile\nWHERE\n  deploy_month = date_trunc('month', now() - interval '1 month')\nGroup BY 2\nORDER BY 2",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "duration"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "google_fit_sessions",
          "timeColumn": "start_time",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "timeFrom": null,
      "title": "Variability of Patch Deployment Lead Time (Last Month)",
      "transparent": true,
      "type": "bargauge"
    },
    {
      "datasource": "${DS_ASKGIT}",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 11,
        "w": 6,
        "x": 12,
        "y": 18
      },
      "id": 14,
      "options": {
        "displayLabels": [
          "value",
          "percent"
        ],
        "legend": {
          "displayMode": "table",
          "placement": "bottom",
          "values": [
            "value"
          ]
        },
        "pieType": "pie",
        "reduceOptions": {
          "calcs": [
            "sum"
          ],
          "fields": "",
          "values": false
        },
        "text": {}
      },
      "pluginVersion": "7.5.4",
      "targets": [
        {
          "format": "time_series",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "queryType": "randomWalk",
          "rawQuery": true,
          "rawSql": "select \n    $__timeGroupAlias(author_when,$__interval),\n    package AS metric,\n    count(distinct (id || package)) as \"package vendoring events\"\nfrom package_folder_commits\nWHERE\n  $__timeFilter(author_when) \n  and parent_folder='automated-vendoring'\ngroup by 1,2\norder by 2",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "avg_days_between_vendor_and_deploy"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "packages_summary_deploy_and_cause_timing_decile",
          "timeColumn": "deploy_month",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "Updates Vendored Per-Package (All Time)",
      "transparent": true,
      "type": "piechart"
    },
    {
      "datasource": "${DS_ASKGIT}",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 11,
        "w": 6,
        "x": 18,
        "y": 18
      },
      "id": 15,
      "options": {
        "displayLabels": [
          "value",
          "percent"
        ],
        "legend": {
          "displayMode": "table",
          "placement": "bottom",
          "values": [
            "value"
          ]
        },
        "pieType": "pie",
        "reduceOptions": {
          "calcs": [
            "sum"
          ],
          "fields": "",
          "values": false
        },
        "text": {}
      },
      "pluginVersion": "7.5.4",
      "targets": [
        {
          "format": "time_series",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "queryType": "randomWalk",
          "rawQuery": true,
          "rawSql": "select \n    $__timeGroupAlias(deploy_commit_author_when,$__interval),\n    deploy_commit_package AS metric,\n    count(distinct (deploy_commit_id || deploy_commit_package)) as \"package deployment events\"\nfrom package_commit_pair_cause_to_deploy\nWHERE\n  $__timeFilter(deploy_commit_author_when) \n  and deploy_commit_parent_folder='prod'\n  and cause_commit_parent_folder='automated-vendoring'\ngroup by 1,2\norder by 2",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "avg_days_between_vendor_and_deploy"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "packages_summary_deploy_and_cause_timing_decile",
          "timeColumn": "deploy_month",
          "timeColumnType": "timestamp",
          "where": [
            {
              "name": "$__timeFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "Updates Deployed Per-Package  (All Time)",
      "transparent": true,
      "type": "piechart"
    }
  ],
  "refresh": false,
  "schemaVersion": 27,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": []
  },
  "time": {
    "from": "now-180d",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "K8S Packages Update Cadence",
  "uid": "C1cb0Ai7k",
  "version": 21,
  "description": "Uses git history of a gitops repo to show update cadence in terms of deployment frequency and lead time. "
}