diff --git a/.gitignore b/.gitignore index b07b78b..7fa7488 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ /.env +/dashboards/jsonnetfile.lock.json +/dashboards/vendor/ /transmission-exporter *.o diff --git a/Makefile b/Makefile index 03a4d6a..a2d5916 100644 --- a/Makefile +++ b/Makefile @@ -30,3 +30,8 @@ lint: $(GO) get -u github.com/golang/lint/golint; \ fi for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done; + +.PHONY: dashboards +dashboards: + jsonnet fmt -i dashboards/transmission.jsonnet + jsonnet -J dashboards/vendor -m dashboards -e "(import 'dashboards/transmission.jsonnet').grafanaDashboards" diff --git a/dashboards/jsonnetfile.json b/dashboards/jsonnetfile.json new file mode 100644 index 0000000..b5d0ad3 --- /dev/null +++ b/dashboards/jsonnetfile.json @@ -0,0 +1,14 @@ +{ + "dependencies": [ + { + "name": "grafana-builder", + "source": { + "git": { + "remote": "https://github.com/grafana/jsonnet-libs", + "subdir": "grafana-builder" + } + }, + "version": "master" + } + ] +} diff --git a/dashboards/transmission.json b/dashboards/transmission.json new file mode 100644 index 0000000..d563096 --- /dev/null +++ b/dashboards/transmission.json @@ -0,0 +1,459 @@ +{ + "annotations": { + "list": [ ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "hideControls": false, + "links": [ ], + "refresh": "10s", + "rows": [ + { + "collapse": false, + "height": "250px", + "panels": [ + { + "aliasColors": { }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 10, + "id": 0, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 0, + "links": [ ], + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ ], + "spaceLength": 10, + "span": 12, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "max(transmission_torrent_download_bytes{name=~\"$torrent\"}) by (name) > 0", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{name}}", + "legendLink": null, + "step": 10 + } + ], + "thresholds": [ ], + "timeFrom": null, + "timeShift": null, + "title": "Downloads (bytes/second)", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [ ] + }, + "yaxes": [ + { + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": 0, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ] + } + ], + "repeat": null, + "repeatIteration": null, + "repeatRowId": null, + "showTitle": true, + "title": "Downloads", + "titleSize": "h6" + }, + { + "collapse": false, + "height": "250px", + "panels": [ + { + "aliasColors": { }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 10, + "id": 1, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 0, + "links": [ ], + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ ], + "spaceLength": 10, + "span": 12, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "max(transmission_torrent_upload_bytes{name=~\"$torrent\"}) by (name) > 0", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{name}}", + "legendLink": null, + "step": 10 + } + ], + "thresholds": [ ], + "timeFrom": null, + "timeShift": null, + "title": "Uploads (bytes/second)", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [ ] + }, + "yaxes": [ + { + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": 0, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ] + } + ], + "repeat": null, + "repeatIteration": null, + "repeatRowId": null, + "showTitle": true, + "title": "Upload", + "titleSize": "h6" + }, + { + "collapse": false, + "height": "250px", + "panels": [ + { + "aliasColors": { }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "id": 2, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [ ], + "nullPointMode": "null as zero", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ ], + "spaceLength": 10, + "span": 12, + "stack": false, + "steppedLine": false, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "Progress", + "colorMode": null, + "colors": [ ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": false, + "linkTooltip": "Drill down", + "linkUrl": "", + "pattern": "Value #A", + "thresholds": [ ], + "type": "number", + "unit": "percentunit" + }, + { + "alias": "Ratio", + "colorMode": null, + "colors": [ ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": false, + "linkTooltip": "Drill down", + "linkUrl": "", + "pattern": "Value #B", + "thresholds": [ ], + "type": "number", + "unit": "short" + }, + { + "alias": "Leechers", + "colorMode": null, + "colors": [ ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": false, + "linkTooltip": "Drill down", + "linkUrl": "", + "pattern": "Value #C", + "thresholds": [ ], + "type": "number", + "unit": "short" + }, + { + "alias": "Seeders", + "colorMode": null, + "colors": [ ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": false, + "linkTooltip": "Drill down", + "linkUrl": "", + "pattern": "Value #D", + "thresholds": [ ], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "pattern": "/.*/", + "thresholds": [ ], + "type": "string", + "unit": "short" + } + ], + "targets": [ + { + "expr": "max(transmission_torrent_done{name=~\"$torrent\"}) by (name)", + "format": "table", + "instant": true, + "intervalFactor": 2, + "legendFormat": "", + "refId": "A", + "step": 10 + }, + { + "expr": "max(transmission_torrent_ratio{name=~\"$torrent\"}) by (name)", + "format": "table", + "instant": true, + "intervalFactor": 2, + "legendFormat": "", + "refId": "B", + "step": 10 + }, + { + "expr": "max(transmission_torrent_leechers{name=~\"$torrent\"}) by (name)", + "format": "table", + "instant": true, + "intervalFactor": 2, + "legendFormat": "", + "refId": "C", + "step": 10 + }, + { + "expr": "max(transmission_torrent_seeders{name=~\"$torrent\"}) by (name)", + "format": "table", + "instant": true, + "intervalFactor": 2, + "legendFormat": "", + "refId": "D", + "step": 10 + } + ], + "thresholds": [ ], + "timeFrom": null, + "timeShift": null, + "title": "Overview", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "transform": "table", + "type": "table", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [ ] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": 0, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ] + } + ], + "repeat": null, + "repeatIteration": null, + "repeatRowId": null, + "showTitle": true, + "title": "Torrents", + "titleSize": "h6" + } + ], + "schemaVersion": 14, + "style": "dark", + "tags": [ ], + "templating": { + "list": [ + { + "current": { + "text": "Prometheus", + "value": "Prometheus" + }, + "hide": 0, + "label": null, + "name": "datasource", + "options": [ ], + "query": "prometheus", + "refresh": 1, + "regex": "", + "type": "datasource" + }, + { + "allValue": null, + "current": { + "selected": true, + "text": "All", + "value": "$__all" + }, + "datasource": "$datasource", + "hide": 0, + "includeAll": true, + "label": "torrent", + "multi": true, + "name": "torrent", + "options": [ ], + "query": "label_values(transmission_torrent_added, name)", + "refresh": 1, + "regex": "", + "sort": 2, + "tagValuesQuery": "", + "tags": [ ], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-1h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "utc", + "title": "Transmission", + "uid": "", + "version": 0 +} diff --git a/dashboards/transmission.jsonnet b/dashboards/transmission.jsonnet new file mode 100644 index 0000000..dfc50ea --- /dev/null +++ b/dashboards/transmission.jsonnet @@ -0,0 +1,46 @@ +local g = import 'grafana-builder/grafana.libsonnet'; + +{ + grafanaDashboards+:: { + 'transmission.json': + g.dashboard( + 'Transmission', + ) + .addMultiTemplate('torrent', 'transmission_torrent_added', 'name') + .addRow( + g.row('Downloads') + .addPanel( + g.panel('Downloads (bytes/second)') + + g.queryPanel('max(transmission_torrent_download_bytes{name=~"$torrent"}) by (name) > 0', '{{name}}') + + g.stack + + { yaxes: g.yaxes('bytes') }, + ) + ) + .addRow( + g.row('Upload') + .addPanel( + g.panel('Uploads (bytes/second)') + + g.queryPanel('max(transmission_torrent_upload_bytes{name=~"$torrent"}) by (name) > 0', '{{name}}') + + g.stack + + { yaxes: g.yaxes('bytes') }, + ) + ) + .addRow( + g.row('Torrents') + .addPanel( + g.panel('Overview') + + g.tablePanel([ + 'max(transmission_torrent_done{name=~"$torrent"}) by (name)', + 'max(transmission_torrent_ratio{name=~"$torrent"}) by (name)', + 'max(transmission_torrent_leechers{name=~"$torrent"}) by (name)', + 'max(transmission_torrent_seeders{name=~"$torrent"}) by (name)', + ], { + 'Value #A': { alias: 'Progress', unit: 'percentunit' }, + 'Value #B': { alias: 'Ratio' }, + 'Value #C': { alias: 'Leechers' }, + 'Value #D': { alias: 'Seeders' }, + }) + ) + ), + }, +}