better docs and default dashboard

This commit is contained in:
Max Rydahl Andersen 2018-10-01 18:31:07 +02:00
parent 627d9f648a
commit 24cba1409a
6 changed files with 339 additions and 624 deletions

View file

@ -1,7 +1,6 @@
[![Build Status](https://travis-ci.org/vegasbrianc/github-monitoring.svg?branch=master)](https://travis-ci.org/vegasbrianc/github-monitoring)
# A Docker Stack which Monitors your GitHub Repos
Here's a quick start to stand-up a Docker [Prometheus](http://prometheus.io/) stack containing Prometheus, Grafana and [github-exporter](https://github.com/infinityworksltd/github-exporter) to collect and graph GitHub statistics.
# A Docker Stack which Monitors your home network
Here's a quick start to stand-up a Docker [Prometheus](http://prometheus.io/) stack containing Prometheus, Grafana with [blackbox-exporter](https://github.com/prometheus/blackbox_exporter) and [speedtest-exporter](https://github.com/stefanwalther/speedtest-exporter) to collect and graph home network connections and speed.
## Pre-requisites
Before we get started installing the Prometheus stack. Ensure you install the latest version of docker and [docker-compose](https://docs.docker.com/compose/install/) on your Docker host machine. This has also been tested with Docker for Mac and it works well.
@ -9,35 +8,18 @@ Before we get started installing the Prometheus stack. Ensure you install the la
## Installation
Clone the project to your Docker host.
If you would like to change which targets should be monitored or make configuration changes edit the [/prometheus/prometheus.yml](https://github.com/vegasbrianc/prometheus/blob/version-2/prometheus/prometheus.yml) file. The targets section is where you define what should be monitored by Prometheus. The names defined in this file are actually sourced from the service name in the docker-compose file. If you wish to change names of the services you can add the "container_name" parameter in the `docker-compose.yml` file.
If you would like to change which targets should be monitored or make configuration changes edit the [/prometheus/prometheus.yml](./prometheus/prometheus.yml) file. The targets section is where you define what should be monitored by Prometheus. The names defined in this file are actually sourced from the service name in the docker-compose file. If you wish to change names of the services you can add the "container_name" parameter in the `docker-compose.yml` file.
## Configuration
In order to pull GitHub stats consistently it is recommended you create a personal access token inside of GitHub. This token will allow you to query the GitHub API more frequently than a public user. [Create GitHub Token](https://github.com/settings/tokens). It is only necessary to give the repo scope to the token permission.
To change what hosts you ping you change the `targets` section under `blackbox` in [/prometheus/prometheus.yml](./prometheus/prometheus.yml) file.
<center><img src="https://github.com/vegasbrianc/github-monitoring/blob/master/images/github_token.png" width="600" heighth="500"></center>
Copy the GitHub Token you created and paste into the bottom of the [docker-compose.yml](https://github.com/vegasbrianc/github-monitoring/blob/master/docker-compose.yml) file under the metrics service section replacing the `GITHUB_TOKEN` with your newly created token.
The REPOS variable can also be updated to point to the Repos that you wish to monitor. In my example I monitor freeCodeCamp and Docker.
metrics:
tty: true
stdin_open: true
expose:
- 9171
image: infinityworks/github-exporter:latest
environment:
- REPOS=freeCodeCamp/freeCodeCamp, docker/docker
- GITHUB_TOKEN=<GitHub API Token see README>
networks:
- back-tier
For speedtest the only relevant configuration is how often you want the check to happen. It is at 5 minutes by default which might be too much if you have limit on downloads. This is changed by editing `scrape_interval` under `speedtest` in [/prometheus/prometheus.yml](./prometheus/prometheus.yml).
Once configurations are done let's start it up. From the /prometheus project directory run the following command:
$ docker-compose up -d
That's it. docker-compose builds the entire Grafana and Prometheus stack automagically.
The Grafana Dashboard is now accessible via: `http://<Host IP Address>:3000` for example http://192.168.10.1:3000
@ -47,7 +29,6 @@ password - foobar (Password is stored in the `config.monitoring` env file)
The DataSource and Dashboard for Grafana are automatically provisioned. You can still install the dashboard manually if you choose below.
<center><img src="https://github.com/vegasbrianc/github-monitoring/blob/master/images/Grafana_Add_Data_Source.png" width="400" heighth="400"></center>
## Manual Install Dashboard

View file

@ -0,0 +1,35 @@
modules:
http_2xx:
prober: http
http:
preferred_ip_protocol: "ip4"
http_post_2xx:
prober: http
http:
method: POST
tcp_connect:
prober: tcp
pop3s_banner:
prober: tcp
tcp:
query_response:
- expect: "^+OK"
tls: true
tls_config:
insecure_skip_verify: false
ssh_banner:
prober: tcp
tcp:
query_response:
- expect: "^SSH-2.0-"
irc_banner:
prober: tcp
tcp:
query_response:
- send: "NICK prober"
- send: "USER prober prober prober :prober"
- expect: "PING :([^ ]+)"
send: "PONG ${1}"
- expect: "^:[^ ]+ 001"
icmp:
prober: icmp

View file

@ -22,26 +22,27 @@ services:
ports:
- 9090:9090
links:
- metrics:metrics
- ping:ping
- speedtest:speedtest
networks:
- back-tier
grafana:
image: grafana/grafana
volumes:
- grafana_data:/var/lib/grafana
- ./grafana/provisioning/:/etc/grafana/provisioning/
depends_on:
- prometheus
ports:
- 3000:3000
volumes:
- grafana_data:/var/lib/grafana
- ./grafana/provisioning/:/etc/grafana/provisioning/
env_file:
- ./grafana/config.monitoring
networks:
- back-tier
- front-tier
metrics:
ping:
tty: true
stdin_open: true
expose:
@ -49,6 +50,10 @@ services:
ports:
- 9115:9115
image: prom/blackbox-exporter
volumes:
- ./blackbox/config:/config
command:
- '--config.file=/config/blackbox.yml'
networks:
- back-tier

View file

@ -1,593 +0,0 @@
{
"__inputs": [
{
"name": "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": "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": "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": "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": "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": "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": "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"
}

View file

@ -0,0 +1,287 @@
{
"__inputs": [
{
"name": "prometheus",
"label": "prometheus",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
],
"__requires": [
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"version": "5.2.4"
},
{
"type": "panel",
"id": "graph",
"name": "Graph",
"version": "5.0.0"
},
{
"type": "datasource",
"id": "prometheus",
"name": "Prometheus",
"version": "5.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,
"id": null,
"iteration": 1538410449101,
"links": [],
"panels": [
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "prometheus",
"fill": 1,
"gridPos": {
"h": 9,
"w": 12,
"x": 0,
"y": 0
},
"id": 6,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"repeat": null,
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "speedtest_bits_per_second{}",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "{{direction}}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "speedtest",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"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
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "prometheus",
"fill": 1,
"gridPos": {
"h": 9,
"w": 24,
"x": 0,
"y": 9
},
"id": 4,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"minSpan": 2,
"nullPointMode": "null",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"repeat": "host",
"repeatDirection": "h",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "probe_success{}",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "{{instance}}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "http reachable",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"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
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
}
],
"schemaVersion": 16,
"style": "dark",
"tags": [
"speedtest",
"ping"
],
"templating": {
"list": [
{
"allValue": null,
"current": {},
"datasource": "prometheus",
"hide": 0,
"includeAll": true,
"label": "",
"multi": true,
"name": "instance",
"options": [],
"query": "label_values(probe_success,instance)",
"refresh": 1,
"regex": "",
"sort": 0,
"tagValuesQuery": "",
"tags": [],
"tagsQuery": "",
"type": "query",
"useTags": false
}
]
},
"time": {
"from": "now-7d",
"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": "browser",
"title": "internet connection",
"version": 0
}

View file

@ -36,7 +36,7 @@ scrape_configs:
static_configs:
- targets: ['speedtest:9696']
- job_name: 'blackbox'
- job_name: 'ping'
metrics_path: /probe
scrape_interval: 5s
params:
@ -52,4 +52,4 @@ scrape_configs:
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: metrics:9115 # The blackbox exporter's real hostname:port.
replacement: ping:9115 # The blackbox exporter's real hostname:port.