Convert git fetch/clone dashboard to grafonnet
Change-Id: I735f94599199ae2d0f304030fa023c55359e9a47
diff --git a/dashboards/gerrit-fetch-clone.json b/dashboards/gerrit-fetch-clone.json
deleted file mode 100644
index 509897a..0000000
--- a/dashboards/gerrit-fetch-clone.json
+++ /dev/null
@@ -1,521 +0,0 @@
-{
- "__inputs": [
- {
- "name": "DS_PROMETHEUS",
- "label": "Prometheus",
- "description": "",
- "type": "datasource",
- "pluginId": "prometheus",
- "pluginName": "Prometheus"
- }
- ],
- "__requires": [
- {
- "type": "grafana",
- "id": "grafana",
- "name": "Grafana",
- "version": "7.1.5"
- },
- {
- "type": "panel",
- "id": "graph",
- "name": "Graph",
- "version": ""
- },
- {
- "type": "datasource",
- "id": "prometheus",
- "name": "Prometheus",
- "version": "1.0.0"
- }
- ],
- "annotations": {
- "list": [
- {
- "builtIn": 1,
- "datasource": "-- Grafana --",
- "enable": true,
- "hide": true,
- "iconColor": "rgba(0, 211, 255, 1)",
- "name": "Annotations & Alerts",
- "type": "dashboard"
- }
- ]
- },
- "editable": true,
- "gnetId": null,
- "graphTooltip": 0,
- "links": [],
- "panels": [
- {
- "aliasColors": {},
- "bars": false,
- "dashLength": 10,
- "dashes": false,
- "datasource": "${DS_PROMETHEUS}",
- "description": "upload-pack requests",
- "fill": 1,
- "fillGradient": 0,
- "gridPos": {
- "h": 8,
- "w": 12,
- "x": 0,
- "y": 0
- },
- "hiddenSeries": false,
- "id": 4,
- "interval": "2m",
- "legend": {
- "avg": false,
- "current": false,
- "max": false,
- "min": false,
- "show": false,
- "total": false,
- "values": false
- },
- "lines": true,
- "linewidth": 1,
- "nullPointMode": "null",
- "options": {
- "dataLinks": []
- },
- "percentage": false,
- "pointradius": 2,
- "points": false,
- "renderer": "flot",
- "seriesOverrides": [],
- "spaceLength": 10,
- "stack": false,
- "steppedLine": false,
- "targets": [
- {
- "expr": "increase(git_upload_pack_request_count_CLONE_total{instance=\"$instance\",replica=\"$replica\"}[2m])/2",
- "legendFormat": "clone",
- "refId": "A"
- }
- ],
- "thresholds": [],
- "timeFrom": null,
- "timeRegions": [],
- "timeShift": null,
- "title": "CLONE count",
- "tooltip": {
- "shared": true,
- "sort": 0,
- "value_type": "individual"
- },
- "type": "graph",
- "xaxis": {
- "buckets": null,
- "mode": "time",
- "name": null,
- "show": true,
- "values": []
- },
- "yaxes": [
- {
- "format": "opm",
- "label": null,
- "logBase": 1,
- "max": null,
- "min": null,
- "show": true
- },
- {
- "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_PROMETHEUS}",
- "description": "upload-pack requests for fetches",
- "fill": 1,
- "fillGradient": 0,
- "gridPos": {
- "h": 8,
- "w": 12,
- "x": 12,
- "y": 0
- },
- "hiddenSeries": false,
- "id": 8,
- "interval": "",
- "legend": {
- "avg": false,
- "current": false,
- "max": false,
- "min": false,
- "show": false,
- "total": false,
- "values": false
- },
- "lines": true,
- "linewidth": 1,
- "nullPointMode": "null",
- "options": {
- "dataLinks": []
- },
- "percentage": false,
- "pointradius": 2,
- "points": false,
- "renderer": "flot",
- "seriesOverrides": [],
- "spaceLength": 10,
- "stack": false,
- "steppedLine": false,
- "targets": [
- {
- "expr": "increase(git_upload_pack_request_count_FETCH_total{instance=\"$instance\",replica=\"$replica\"}[2m])/2",
- "legendFormat": "fetch",
- "refId": "A"
- }
- ],
- "thresholds": [],
- "timeFrom": null,
- "timeRegions": [],
- "timeShift": null,
- "title": "FETCH count",
- "tooltip": {
- "shared": true,
- "sort": 0,
- "value_type": "individual"
- },
- "type": "graph",
- "xaxis": {
- "buckets": null,
- "mode": "time",
- "name": null,
- "show": true,
- "values": []
- },
- "yaxes": [
- {
- "format": "opm",
- "label": null,
- "logBase": 1,
- "max": null,
- "min": null,
- "show": true
- },
- {
- "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_PROMETHEUS}",
- "fill": 0,
- "fillGradient": 0,
- "gridPos": {
- "h": 13,
- "w": 12,
- "x": 0,
- "y": 8
- },
- "hiddenSeries": false,
- "id": 2,
- "legend": {
- "avg": false,
- "current": false,
- "max": false,
- "min": false,
- "show": true,
- "total": false,
- "values": false
- },
- "lines": true,
- "linewidth": 1,
- "nullPointMode": "null",
- "options": {
- "dataLinks": []
- },
- "percentage": false,
- "pointradius": 2,
- "points": false,
- "renderer": "flot",
- "seriesOverrides": [
- {
- "alias": "quantile: 0.75",
- "hiddenSeries": true
- },
- {
- "alias": "quantile: 0.95",
- "hiddenSeries": true
- },
- {
- "alias": "quantile: 0.98",
- "hiddenSeries": true
- },
- {
- "alias": "quantile: 0.99",
- "hiddenSeries": true
- }
- ],
- "spaceLength": 10,
- "stack": false,
- "steppedLine": false,
- "targets": [
- {
- "expr": "git_upload_pack_pack_bytes_CLONE{instance=\"$instance\",replica=\"$replica\"}",
- "format": "time_series",
- "intervalFactor": 1,
- "legendFormat": "quantile: {{quantile}}",
- "refId": "A"
- }
- ],
- "thresholds": [],
- "timeFrom": null,
- "timeRegions": [],
- "timeShift": null,
- "title": "upload-pack pack bytes CLONE",
- "tooltip": {
- "shared": true,
- "sort": 0,
- "value_type": "individual"
- },
- "type": "graph",
- "xaxis": {
- "buckets": null,
- "mode": "time",
- "name": null,
- "show": true,
- "values": []
- },
- "yaxes": [
- {
- "decimals": null,
- "format": "decbytes",
- "label": "",
- "logBase": 10,
- "max": "10000000000",
- "min": "1000",
- "show": true
- },
- {
- "format": "short",
- "label": "",
- "logBase": 1,
- "max": null,
- "min": null,
- "show": true
- }
- ],
- "yaxis": {
- "align": false,
- "alignLevel": null
- }
- },
- {
- "aliasColors": {},
- "bars": false,
- "dashLength": 10,
- "dashes": false,
- "datasource": "${DS_PROMETHEUS}",
- "fill": 0,
- "fillGradient": 0,
- "gridPos": {
- "h": 13,
- "w": 12,
- "x": 12,
- "y": 8
- },
- "hiddenSeries": false,
- "id": 6,
- "legend": {
- "avg": false,
- "current": false,
- "max": false,
- "min": false,
- "show": true,
- "total": false,
- "values": false
- },
- "lines": true,
- "linewidth": 1,
- "nullPointMode": "null",
- "options": {
- "dataLinks": []
- },
- "percentage": false,
- "pointradius": 2,
- "points": false,
- "renderer": "flot",
- "seriesOverrides": [
- {
- "alias": "quantile: 0.75",
- "hiddenSeries": true
- },
- {
- "alias": "quantile: 0.95",
- "hiddenSeries": true
- },
- {
- "alias": "quantile: 0.98",
- "hiddenSeries": true
- },
- {
- "alias": "quantile: 0.99",
- "hiddenSeries": true
- }
- ],
- "spaceLength": 10,
- "stack": false,
- "steppedLine": false,
- "targets": [
- {
- "expr": "git_upload_pack_pack_bytes_FETCH{instance=\"$instance\",replica=\"$replica\"}",
- "legendFormat": "quantile: {{quantile}}",
- "refId": "A"
- }
- ],
- "thresholds": [],
- "timeFrom": null,
- "timeRegions": [],
- "timeShift": null,
- "title": "upload-pack pack bytes FETCH",
- "tooltip": {
- "shared": true,
- "sort": 0,
- "value_type": "individual"
- },
- "type": "graph",
- "xaxis": {
- "buckets": null,
- "mode": "time",
- "name": null,
- "show": true,
- "values": []
- },
- "yaxes": [
- {
- "decimals": null,
- "format": "decbytes",
- "label": null,
- "logBase": 10,
- "max": "10000000000",
- "min": "1000",
- "show": true
- },
- {
- "format": "short",
- "label": null,
- "logBase": 1,
- "max": null,
- "min": null,
- "show": true
- }
- ],
- "yaxis": {
- "align": false,
- "alignLevel": null
- }
- }
- ],
- "refresh": "1m",
- "schemaVersion": 21,
- "style": "dark",
- "tags": [],
- "templating": {
- "list": [
- {
- "allValue": null,
- "current": {
- "text": "",
- "value": ""
- },
- "datasource": "${DS_PROMETHEUS}",
- "definition": "label_values(git_upload_pack_phase_writing_total, instance)",
- "hide": 0,
- "includeAll": false,
- "label": "Gerrit Instance",
- "multi": false,
- "name": "instance",
- "options": [],
- "query": "label_values(git_upload_pack_phase_writing_total, instance)",
- "refresh": 1,
- "regex": "",
- "skipUrlSync": false,
- "sort": 0,
- "tagValuesQuery": "",
- "tags": [],
- "tagsQuery": "",
- "type": "query",
- "useTags": false
- },
- {
- "allValue": null,
- "current": {
- "text": "",
- "value": ""
- },
- "datasource": "${DS_PROMETHEUS}",
- "definition": "label_values(git_upload_pack_phase_writing_total{instance=\"$instance\"}, replica)",
- "hide": 0,
- "includeAll": false,
- "label": "Replica",
- "multi": false,
- "name": "replica",
- "options": [],
- "query": "label_values(git_upload_pack_phase_writing_total{instance=\"$instance\"}, replica)",
- "refresh": 2,
- "regex": "",
- "skipUrlSync": false,
- "sort": 0,
- "tagValuesQuery": "",
- "tags": [],
- "tagsQuery": "",
- "type": "query",
- "useTags": false
- }
- ]
- },
- "time": {
- "from": "now-24h",
- "to": "now"
- },
- "timepicker": {
- "refresh_intervals": [
- "5s",
- "10s",
- "30s",
- "1m",
- "5m",
- "15m",
- "30m",
- "1h",
- "2h",
- "1d"
- ]
- },
- "timezone": "",
- "title": "Git fetch / clone",
- "uid": "EV4ZCjEWz",
- "version": 3
-}
diff --git a/dashboards/gerrit/fetch-clone/gerrit-fetch-clone.jsonnet b/dashboards/gerrit/fetch-clone/gerrit-fetch-clone.jsonnet
new file mode 100644
index 0000000..8273f06
--- /dev/null
+++ b/dashboards/gerrit/fetch-clone/gerrit-fetch-clone.jsonnet
@@ -0,0 +1,43 @@
+local grafana = import '../../../vendor/grafonnet/grafana.libsonnet';
+local dashboard = grafana.dashboard;
+local template = grafana.template;
+local graphPanel = grafana.graphPanel;
+local prometheus = grafana.prometheus;
+
+local defaults = import '../../globals/defaults.libsonnet';
+local gridPos = import '../../globals/grid_pos.libsonnet';
+local publishVariables = import '../../globals/publish.libsonnet';
+local variables = import '../globals/variables.libsonnet';
+
+local count_panel = import './panels/count.libsonnet';
+local bytes_panel = import './panels/bytes.libsonnet';
+
+dashboard.new(
+ 'Gerrit - Git Fetch & Clone',
+ tags=['gerrit'],
+ schemaVersion=defaults.dashboards.schemaVersion,
+ editable=defaults.dashboards.editable,
+ time_from=defaults.dashboards.timeFrom,
+ time_to=defaults.dashboards.timeTo,
+ refresh=defaults.dashboards.refresh,
+ graphTooltip='shared_tooltip',
+)
+.addTemplate(variables.instance)
+.addTemplate(variables.replica)
+.addPanel(
+ count_panel.new('CLONE'),
+ gridPos=gridPos.new(0, 0)
+)
+.addPanel(
+ count_panel.new('FETCH'),
+ gridPos=gridPos.new(0, 1)
+)
+.addPanel(
+ bytes_panel.new('CLONE'),
+ gridPos=gridPos.new(1, 0)
+)
+.addPanel(
+ bytes_panel.new('FETCH'),
+ gridPos=gridPos.new(1, 1)
+)
++ if std.extVar('publish') then publishVariables else {}
diff --git a/dashboards/gerrit/fetch-clone/panels/bytes.libsonnet b/dashboards/gerrit/fetch-clone/panels/bytes.libsonnet
new file mode 100644
index 0000000..0acbdf1
--- /dev/null
+++ b/dashboards/gerrit/fetch-clone/panels/bytes.libsonnet
@@ -0,0 +1,47 @@
+local grafana = import '../../../../vendor/grafonnet/grafana.libsonnet';
+local prometheus = grafana.prometheus;
+
+local lineGraph = import '../../../globals/line-graph.libsonnet';
+local yAxis = import '../../../globals/yaxis.libsonnet';
+{
+ new(type):: lineGraph.new(
+ title=std.format('upload-pack pack bytes %s', type),
+ yAxis1=yAxis.new(
+ format='decbytes',
+ logBase=10,
+ ),
+ min=1000,
+ max=10000000000,
+ fill=0,
+ )
+ .addTarget(
+ prometheus.target(
+ std.format('git_upload_pack_pack_bytes_%s{instance="$instance",replica="$replica"}', type),
+ legendFormat='quantile: {{quantile}}',
+ )
+ )
+ .addSeriesOverride(
+ {
+ alias: 'quantile: 0.99',
+ hiddenSeries: true,
+ }
+ )
+ .addSeriesOverride(
+ {
+ alias: 'quantile: 0.98',
+ hiddenSeries: true,
+ }
+ )
+ .addSeriesOverride(
+ {
+ alias: 'quantile: 0.95',
+ hiddenSeries: true,
+ }
+ )
+ .addSeriesOverride(
+ {
+ alias: 'quantile: 0.75',
+ hiddenSeries: true,
+ }
+ )
+}
diff --git a/dashboards/gerrit/fetch-clone/panels/count.libsonnet b/dashboards/gerrit/fetch-clone/panels/count.libsonnet
new file mode 100644
index 0000000..827a25f
--- /dev/null
+++ b/dashboards/gerrit/fetch-clone/panels/count.libsonnet
@@ -0,0 +1,20 @@
+local grafana = import '../../../../vendor/grafonnet/grafana.libsonnet';
+local prometheus = grafana.prometheus;
+
+local lineGraph = import '../../../globals/line-graph.libsonnet';
+local yAxis = import '../../../globals/yaxis.libsonnet';
+
+{
+ new(type):: lineGraph.new(
+ title=std.format('%s count', type),
+ yAxis1=yAxis.new(
+ format='opm',
+ )
+ )
+ .addTarget(
+ prometheus.target(
+ std.format('increase(git_upload_pack_request_count_%s_total{instance="$instance",replica="$replica"}[2m])/2', type),
+ legendFormat=type,
+ )
+ )
+}