From 912d8378b64975dd47b000710de3cdec01bd38dc Mon Sep 17 00:00:00 2001 From: Brian Christner Date: Thu, 8 Mar 2018 10:21:08 +0100 Subject: [PATCH] updated monitoring repo with latest Grafana provisioning tools for the datasource and dashboard Signed-off-by: Brian Christner --- README.md | 9 +- docker-compose.yml | 3 +- grafana/config.monitoring | 2 + grafana/provisioning/dashboards/dashboard.yml | 11 + .../dashboards/github-stats_rev2.json | 593 ++++++++++++++++++ .../provisioning/datasources/datasource.yml | 50 ++ 6 files changed, 661 insertions(+), 7 deletions(-) create mode 100644 grafana/config.monitoring create mode 100644 grafana/provisioning/dashboards/dashboard.yml create mode 100644 grafana/provisioning/dashboards/github-stats_rev2.json create mode 100644 grafana/provisioning/datasources/datasource.yml diff --git a/README.md b/README.md index 6a829fb..f83188b 100644 --- a/README.md +++ b/README.md @@ -45,15 +45,12 @@ The Grafana Dashboard is now accessible via: `http://:3000` for username - admin password - foobar (Password is stored in the `config.monitoring` env file) -## Post Configuration -Now we need to create the Prometheus Datasource in order to connect Grafana to Prometheues -* Click the `Grafana` Menu at the top left corner (looks like a fireball) -* Click `Data Sources` -* Click the green button `Add Data Source`. +The DataSource and Dashboard for Grafana are automatically provisioned. You can still install the dashboaed manually if you choose below. +
-## Install Dashboard +## Manual Install Dashboard I created a Dashboard template which is available on [GitHub Stats Dashboard](https://grafana.net/dashboards/1559). Simply download the dashboard and select from the Grafana menu -> Dashboards -> Import This dashboard is intended to help you get started with graphing your GitHub Repos. If you have any changes you would like to see in the Dashboard let me know so I can update Grafana site as well. diff --git a/docker-compose.yml b/docker-compose.yml index 5c02db2..d1084d7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -34,8 +34,9 @@ services: - 3000:3000 volumes: - grafana_data:/var/lib/grafana + - ./grafana/provisioning/:/etc/grafana/provisioning/ env_file: - - config.monitoring + - ./grafana/config.monitoring networks: - back-tier - front-tier diff --git a/grafana/config.monitoring b/grafana/config.monitoring new file mode 100644 index 0000000..f12466b --- /dev/null +++ b/grafana/config.monitoring @@ -0,0 +1,2 @@ +GF_SECURITY_ADMIN_PASSWORD=foobar +GF_USERS_ALLOW_SIGN_UP=false diff --git a/grafana/provisioning/dashboards/dashboard.yml b/grafana/provisioning/dashboards/dashboard.yml new file mode 100644 index 0000000..14716ee --- /dev/null +++ b/grafana/provisioning/dashboards/dashboard.yml @@ -0,0 +1,11 @@ +apiVersion: 1 + +providers: +- name: 'Prometheus' + orgId: 1 + folder: '' + type: file + disableDeletion: false + editable: true + options: + path: /etc/grafana/provisioning/dashboards diff --git a/grafana/provisioning/dashboards/github-stats_rev2.json b/grafana/provisioning/dashboards/github-stats_rev2.json new file mode 100644 index 0000000..62014a1 --- /dev/null +++ b/grafana/provisioning/dashboards/github-stats_rev2.json @@ -0,0 +1,593 @@ +{ + "__inputs": [ + { + "name": "DS_PROMETHEUS", + "label": "Prometheus", + "description": "Standard Prometheus datasource", + "type": "datasource", + "pluginId": "prometheus", + "pluginName": "Prometheus" + } + ], + "__requires": [ + { + "type": "panel", + "id": "graph", + "name": "Graph", + "version": "" + }, + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "4.0.2" + }, + { + "type": "datasource", + "id": "prometheus", + "name": "Prometheus", + "version": "1.0.0" + } + ], + "id": null, + "title": "GitHub Stats", + "tags": [], + "style": "dark", + "timezone": "browser", + "editable": true, + "sharedCrosshair": false, + "hideControls": false, + "time": { + "from": "now-3h", + "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" + ] + }, + "templating": { + "list": [] + }, + "annotations": { + "list": [] + }, + "schemaVersion": 13, + "version": 6, + "links": [], + "gnetId": 1559, + "rows": [ + { + "title": "Dashboard Row", + "panels": [ + { + "aliasColors": { + "stars": "#1F78C1" + }, + "bars": false, + "datasource": "${DS_PROMETHEUS}", + "editable": true, + "error": false, + "fill": 1, + "id": 1, + "legend": { + "avg": false, + "current": true, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": true, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "stars", + "yaxis": 1 + } + ], + "span": 4, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "github_repo_stars{repo=\"docker\"}", + "interval": "5m", + "intervalFactor": 2, + "legendFormat": "{{stars}}", + "metric": "github_repo_stars", + "refId": "A", + "step": 600 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Docker Stars", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "aliasColors": { + "Docker Open Issues": "#C15C17", + "Open Issues": "#C15C17" + }, + "bars": false, + "datasource": "${DS_PROMETHEUS}", + "editable": true, + "error": false, + "fill": 4, + "id": 2, + "legend": { + "avg": false, + "current": true, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": true, + "renderer": "flot", + "seriesOverrides": [], + "span": 4, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "github_repo_open_issues{repo=\"docker\"}", + "interval": "5m", + "intervalFactor": 2, + "legendFormat": "{{Open Issues}}", + "metric": "github_repo_open_issues", + "refId": "A", + "step": 600 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Docker Open Issues", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "decimals": null + }, + { + "aliasColors": { + "Forks": "#F9BA8F" + }, + "bars": false, + "datasource": "${DS_PROMETHEUS}", + "editable": true, + "error": false, + "fill": 1, + "id": 3, + "legend": { + "avg": false, + "current": true, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": true, + "renderer": "flot", + "seriesOverrides": [], + "span": 4, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "github_repo_forks{repo=\"docker\"}", + "interval": "5m", + "intervalFactor": 2, + "legendFormat": "{{Forks}}", + "metric": "github_repo_forks", + "refId": "A", + "step": 600 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Docker Forks", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "decimals": null + } + ], + "showTitle": false, + "titleSize": "h6", + "height": "250px", + "repeat": null, + "repeatRowId": null, + "repeatIteration": null, + "collapse": false + }, + { + "title": "Dashboard Row", + "panels": [ + { + "aliasColors": { + "stars": "#E5A8E2" + }, + "bars": false, + "datasource": "${DS_PROMETHEUS}", + "decimals": 3, + "editable": true, + "error": false, + "fill": 1, + "id": 4, + "legend": { + "avg": false, + "current": true, + "hideEmpty": false, + "hideZero": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": true, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "stars", + "yaxis": 1 + } + ], + "span": 4, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "github_repo_stars{repo=\"freeCodeCamp\"}", + "interval": "5m", + "intervalFactor": 2, + "legendFormat": "{{stars}}", + "metric": "github_repo_stars", + "refId": "A", + "step": 600 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "freeCodeCamp Stars", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + }, + { + "aliasColors": { + "Docker Open Issues": "#C15C17", + "Open Issues": "#BF1B00" + }, + "bars": false, + "datasource": "${DS_PROMETHEUS}", + "editable": true, + "error": false, + "fill": 3, + "id": 5, + "legend": { + "avg": false, + "current": true, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 3, + "points": true, + "renderer": "flot", + "seriesOverrides": [], + "span": 4, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "github_repo_open_issues{repo=\"freeCodeCamp\"}", + "interval": "5m", + "intervalFactor": 2, + "legendFormat": "{{Open Issues}}", + "metric": "github_repo_open_issues", + "refId": "A", + "step": 600 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "freeCodeCamp Open Issues", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "decimals": -1 + }, + { + "aliasColors": { + "Forks": "#F9BA8F" + }, + "bars": false, + "datasource": "${DS_PROMETHEUS}", + "decimals": 3, + "editable": true, + "error": false, + "fill": 1, + "id": 6, + "legend": { + "avg": false, + "current": true, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": true, + "renderer": "flot", + "seriesOverrides": [], + "span": 4, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "github_repo_forks{repo=\"freeCodeCamp\"}", + "interval": "5m", + "intervalFactor": 2, + "legendFormat": "{{Forks}}", + "metric": "github_repo_forks", + "refId": "A", + "step": 600 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "FreecodeCamp Forks", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ] + } + ], + "showTitle": false, + "titleSize": "h6", + "height": 250, + "repeat": null, + "repeatRowId": null, + "repeatIteration": null, + "collapse": false + } + ], + "description": "A docker stack which uses Grafana to collect GitHub statistics for selected Repositories" +} \ No newline at end of file diff --git a/grafana/provisioning/datasources/datasource.yml b/grafana/provisioning/datasources/datasource.yml new file mode 100644 index 0000000..2d4ab76 --- /dev/null +++ b/grafana/provisioning/datasources/datasource.yml @@ -0,0 +1,50 @@ +# config file version +apiVersion: 1 + +# list of datasources that should be deleted from the database +deleteDatasources: + - name: Prometheus + orgId: 1 + +# list of datasources to insert/update depending +# whats available in the database +datasources: + # name of the datasource. Required +- name: Prometheus + # datasource type. Required + type: prometheus + # access mode. direct or proxy. Required + access: proxy + # org id. will default to orgId 1 if not specified + orgId: 1 + # url + url: http://prometheus:9090 + # database password, if used + password: + # database user, if used + user: + # database name, if used + database: + # enable/disable basic auth + basicAuth: true + # basic auth username + basicAuthUser: admin + # basic auth password + basicAuthPassword: foobar + # enable/disable with credentials headers + withCredentials: + # mark as default datasource. Max one per org + isDefault: + # fields that will be converted to json and stored in json_data + jsonData: + graphiteVersion: "1.1" + tlsAuth: false + tlsAuthWithCACert: false + # json object of data that will be encrypted. + secureJsonData: + tlsCACert: "..." + tlsClientCert: "..." + tlsClientKey: "..." + version: 1 + # allow users to edit datasources from the UI. + editable: true