Created
April 12, 2020 08:05
-
-
Save Hades32/3fbcd3a16dc38614fa9d03fe766fb69b to your computer and use it in GitHub Desktop.
Grafana+Prometheus for home network monitoring
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
docker network create mynet | |
useradd --system container-user | |
mkdir -p /data/prom/config/ /data/prom/data/ /data/grafana/data/ /data/meshping/redis/ | |
chown -R container-user /data/prom/config/ /data/prom/data/ /data/grafana/data/ /data/meshping/redis/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
docker kill grafana | |
docker rm grafana | |
docker run \ | |
-d --name grafana \ | |
--restart always \ | |
--user $(id -u container-user) \ | |
-v "/data/grafana/data/:/var/lib/grafana/" \ | |
--net mynet \ | |
-p 3000:3000 \ | |
grafana/grafana:6.7.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sudo apt install docker-compose -y | |
# docker-compose up --detach | |
version: '2' | |
services: | |
meshping: | |
# for x86_64 and amd64: | |
# image: "svedrin/meshping:latest" | |
# for raspberry Pi 3 or other ARMv7-based things (see `uname -m`): | |
image: "svedrin/meshping:latest-armv7l" | |
network_mode: "host" | |
restart: always | |
labels: | |
"com.centurylinklabs.watchtower.enable": "true" | |
# If you want to add other Meshping instances to peer with, uncomment this: | |
#environment: | |
# MESHPING_PEERS: 10.10.10.1:9922,10.10.20.1:9922 | |
redis: | |
image: "redis:alpine" | |
network_mode: "host" | |
restart: always | |
volumes: | |
- "/data/meshping/redis/:/data/" | |
watchtower: | |
image: "containrrr/watchtower:latest" | |
command: "--label-enable --cleanup --debug --interval 60" | |
restart: always | |
volumes: | |
- "/var/run/docker.sock:/var/run/docker.sock" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
image=hades32/prometheus-speedtest:latest | |
container=prometheus-speedtest | |
docker pull $image | |
docker kill $container | |
docker rm $container | |
docker run -d --net mynet \ | |
--restart always \ | |
--name $container \ | |
$image --server=1338 --port=9516 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# place at /data/prom/config/prometheus.yml | |
global: | |
scrape_interval: 10s | |
scrape_timeout: 9s | |
scrape_configs: | |
- job_name: meshping | |
static_configs: | |
- targets: | |
- 192.168.178.116:9922 | |
- job_name: speedtest | |
metrics_path: /probe | |
scrape_interval: 30m | |
scrape_timeout: 5m | |
static_configs: | |
- targets: | |
- prometheus-speedtest:9516 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
docker kill prometheus | |
docker rm prometheus | |
docker run \ | |
-d --name prometheus \ | |
--restart always \ | |
--net mynet \ | |
--user $(id -u container-user) \ | |
-p 9090:9090 \ | |
-v /data/prom/config/:/etc/prometheus/ \ | |
-v /data/prom/data/:/prometheus/ \ | |
prom/prometheus |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open grafana http://your-pi:3000 | |
add datasource | |
Type: Prometheus | |
Name: Prometheus | |
Url: http://prometheus:9090 | |
Import Dashboard, so 08 file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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": 4, | |
"links": [], | |
"panels": [ | |
{ | |
"aliasColors": {}, | |
"bars": false, | |
"dashLength": 10, | |
"dashes": false, | |
"datasource": null, | |
"fill": 0, | |
"fillGradient": 0, | |
"gridPos": { | |
"h": 10, | |
"w": 12, | |
"x": 0, | |
"y": 0 | |
}, | |
"hiddenSeries": false, | |
"id": 8, | |
"legend": { | |
"avg": false, | |
"current": false, | |
"max": false, | |
"min": false, | |
"show": true, | |
"total": false, | |
"values": false | |
}, | |
"lines": true, | |
"linewidth": 2, | |
"nullPointMode": "connected", | |
"options": { | |
"dataLinks": [] | |
}, | |
"percentage": false, | |
"pointradius": 2, | |
"points": false, | |
"renderer": "flot", | |
"seriesOverrides": [], | |
"spaceLength": 10, | |
"stack": false, | |
"steppedLine": false, | |
"targets": [ | |
{ | |
"expr": "download_speed_bps", | |
"interval": "", | |
"legendFormat": "down", | |
"refId": "A" | |
}, | |
{ | |
"expr": "upload_speed_bps", | |
"interval": "", | |
"legendFormat": "up", | |
"refId": "B" | |
} | |
], | |
"thresholds": [], | |
"timeFrom": null, | |
"timeRegions": [], | |
"timeShift": null, | |
"title": "Bandwidth", | |
"tooltip": { | |
"shared": true, | |
"sort": 0, | |
"value_type": "individual" | |
}, | |
"type": "graph", | |
"xaxis": { | |
"buckets": null, | |
"mode": "time", | |
"name": null, | |
"show": true, | |
"values": [] | |
}, | |
"yaxes": [ | |
{ | |
"decimals": null, | |
"format": "bps", | |
"label": null, | |
"logBase": 2, | |
"max": null, | |
"min": null, | |
"show": true | |
}, | |
{ | |
"format": "short", | |
"label": null, | |
"logBase": 1, | |
"max": null, | |
"min": null, | |
"show": true | |
} | |
], | |
"yaxis": { | |
"align": false, | |
"alignLevel": null | |
} | |
}, | |
{ | |
"cards": { | |
"cardPadding": null, | |
"cardRound": null | |
}, | |
"color": { | |
"cardColor": "#FF780A", | |
"colorScale": "linear", | |
"colorScheme": "interpolateOranges", | |
"exponent": 0.5, | |
"max": null, | |
"min": 0, | |
"mode": "opacity" | |
}, | |
"dataFormat": "tsbuckets", | |
"datasource": null, | |
"gridPos": { | |
"h": 10, | |
"w": 12, | |
"x": 12, | |
"y": 0 | |
}, | |
"heatmap": {}, | |
"hideZeroBuckets": true, | |
"highlightCards": true, | |
"id": 2, | |
"legend": { | |
"show": true | |
}, | |
"reverseYBuckets": false, | |
"targets": [ | |
{ | |
"expr": "rate(meshping_pings_bucket{target=\"1.1.1.1\"}[10m])", | |
"format": "heatmap", | |
"hide": false, | |
"interval": "10m", | |
"intervalFactor": 1, | |
"legendFormat": "{{le}}", | |
"refId": "A" | |
} | |
], | |
"timeFrom": null, | |
"timeShift": null, | |
"title": "Ping Heatmap Cloudflare", | |
"tooltip": { | |
"show": true, | |
"showHistogram": false | |
}, | |
"type": "heatmap", | |
"xAxis": { | |
"show": true | |
}, | |
"xBucketNumber": null, | |
"xBucketSize": null, | |
"yAxis": { | |
"decimals": 0, | |
"format": "ms", | |
"logBase": 1, | |
"max": null, | |
"min": null, | |
"show": true, | |
"splitFactor": null | |
}, | |
"yBucketBound": "auto", | |
"yBucketNumber": null, | |
"yBucketSize": null | |
}, | |
{ | |
"aliasColors": {}, | |
"bars": true, | |
"dashLength": 10, | |
"dashes": false, | |
"datasource": null, | |
"fill": 10, | |
"fillGradient": 0, | |
"gridPos": { | |
"h": 11, | |
"w": 12, | |
"x": 0, | |
"y": 10 | |
}, | |
"hiddenSeries": false, | |
"id": 6, | |
"legend": { | |
"avg": false, | |
"current": false, | |
"max": false, | |
"min": false, | |
"show": true, | |
"total": false, | |
"values": false | |
}, | |
"lines": false, | |
"linewidth": 0, | |
"nullPointMode": "null", | |
"options": { | |
"dataLinks": [] | |
}, | |
"percentage": false, | |
"pointradius": 2, | |
"points": false, | |
"renderer": "flot", | |
"seriesOverrides": [], | |
"spaceLength": 10, | |
"stack": false, | |
"steppedLine": true, | |
"targets": [ | |
{ | |
"expr": "avg(rate(meshping_lost[5m]) / rate(meshping_sent[5m]) * 100)", | |
"interval": "", | |
"legendFormat": "overall", | |
"refId": "A" | |
}, | |
{ | |
"expr": "rate(meshping_lost[5m]) / rate(meshping_sent[5m]) * 100", | |
"hide": true, | |
"interval": "", | |
"legendFormat": "{{name}}", | |
"refId": "B" | |
} | |
], | |
"thresholds": [], | |
"timeFrom": null, | |
"timeRegions": [], | |
"timeShift": null, | |
"title": "Loss Rate %", | |
"tooltip": { | |
"shared": true, | |
"sort": 0, | |
"value_type": "individual" | |
}, | |
"type": "graph", | |
"xaxis": { | |
"buckets": null, | |
"mode": "time", | |
"name": null, | |
"show": true, | |
"values": [] | |
}, | |
"yaxes": [ | |
{ | |
"decimals": null, | |
"format": "percent", | |
"label": null, | |
"logBase": 10, | |
"max": "100", | |
"min": "0", | |
"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": null, | |
"fill": 0, | |
"fillGradient": 0, | |
"gridPos": { | |
"h": 11, | |
"w": 12, | |
"x": 12, | |
"y": 10 | |
}, | |
"hiddenSeries": false, | |
"id": 4, | |
"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": "overall", | |
"linewidth": 2, | |
"zindex": 2 | |
} | |
], | |
"spaceLength": 10, | |
"stack": false, | |
"steppedLine": false, | |
"targets": [ | |
{ | |
"expr": "avg(rate(meshping_pings_sum[5m]) / rate(meshping_pings_count[5m]))", | |
"interval": "", | |
"legendFormat": "overall", | |
"refId": "A" | |
}, | |
{ | |
"expr": " rate(meshping_pings_sum[5m]) / rate(meshping_pings_count[5m])", | |
"hide": true, | |
"interval": "", | |
"legendFormat": "{{name}}", | |
"refId": "B" | |
} | |
], | |
"thresholds": [], | |
"timeFrom": null, | |
"timeRegions": [], | |
"timeShift": null, | |
"title": "Avg Ping", | |
"tooltip": { | |
"shared": true, | |
"sort": 0, | |
"value_type": "individual" | |
}, | |
"type": "graph", | |
"xaxis": { | |
"buckets": null, | |
"mode": "time", | |
"name": null, | |
"show": true, | |
"values": [] | |
}, | |
"yaxes": [ | |
{ | |
"decimals": null, | |
"format": "ms", | |
"label": null, | |
"logBase": 10, | |
"max": "200", | |
"min": "12", | |
"show": true | |
}, | |
{ | |
"format": "short", | |
"label": null, | |
"logBase": 1, | |
"max": null, | |
"min": null, | |
"show": true | |
} | |
], | |
"yaxis": { | |
"align": false, | |
"alignLevel": null | |
} | |
} | |
], | |
"refresh": "1m", | |
"schemaVersion": 22, | |
"style": "dark", | |
"tags": [], | |
"templating": { | |
"list": [] | |
}, | |
"time": { | |
"from": "now-24h", | |
"to": "now" | |
}, | |
"timepicker": { | |
"refresh_intervals": [ | |
"5s", | |
"10s", | |
"30s", | |
"1m", | |
"5m", | |
"15m", | |
"30m", | |
"1h", | |
"2h", | |
"1d" | |
] | |
}, | |
"timezone": "", | |
"title": "Ping", | |
"uid": "QeUIjM9Zz", | |
"variables": { | |
"list": [] | |
}, | |
"version": 24 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment