Compare commits

...

26 Commits

Author SHA1 Message Date
Xavier Fontanet 9d566dfd5b improving explanation 2024-07-11 15:19:01 +02:00
xeviff 1fb521853d
update explanation to the fork version 2022-06-30 19:57:34 +02:00
xeviff b11a336ecd
update explanations 2022-06-30 19:45:57 +02:00
Xavier Fontanet 64a20f97c1 my own changes
Added my own ports checker docker
, let anonymous users to publicly access Grafana
, removed unused dashboards
, added my own tuned dashboard
2022-06-30 19:36:18 +02:00
xeviff 38993e14b6
Delete dashboard.png 2022-06-30 18:47:11 +02:00
Jeff Geerling bd9508de50 Issue #22: Add archival notice to README. 2021-06-24 16:10:22 -05:00
Jeff Geerling 80df586261 Prevent DDoS of my own website. 2021-06-23 22:34:40 -05:00
Jeff Geerling 8fc2032da4 Fixes #15: Fix speedtest connections on Starlink dashboard. 2021-06-11 14:18:57 -05:00
Jeff Geerling 42004b83cd
Merge pull request #7 from geerlingguy/6-starlink
Issue #6: Add Starlink monitoring.
2021-06-11 12:42:57 -05:00
Jeff Geerling 02226971ef Bump latency gauge to 50k data points too. 2021-06-11 12:36:05 -05:00
Jeff Geerling be4861a0bb Bump max data points for dashboard to 50k so it can display a month. 2021-06-11 12:25:08 -05:00
Jeff Geerling 9440bc6e67 Issue #6: Add plotly planel plugin. 2021-04-27 13:09:50 -05:00
Jeff Geerling fc4956544d Issue #6: Drop exemplars for now. 2021-04-27 13:07:41 -05:00
Jeff Geerling 4a76cae9b1 Fix datasource for starlink-overview dashboard. 2021-04-27 12:55:03 -05:00
Jeff Geerling 0f79553e05 Issue #6: Add Starlink Overview dashboard. 2021-04-27 12:50:42 -05:00
Jeff Geerling 6fe6257a56 Issue #6: Add Starlink monitoring. 2021-04-27 12:37:22 -05:00
Jeff Geerling dd23962805 Fixes #3: Gauge Panels return N/A if left running for long periods. 2021-04-26 17:31:43 -05:00
Jeff Geerling 9d2efe0277 Add Shelly Plug power-consumption dashboard and prometheus scraper. 2021-04-17 15:23:30 -05:00
Jeff Geerling 33dfa4f8a8 Updates for easier setup in README. 2021-04-13 13:19:37 -05:00
Jeff Geerling 59508d5d0c Use discrete instead of spectrum for uptime graph. 2021-04-10 16:42:23 -05:00
Jeff Geerling 2ef3c83972 Update dashboard for better upload and download graph. 2021-04-07 17:23:07 -05:00
Jeff Geerling b603ebea76 Use correct field data format for display. 2021-04-04 09:35:26 -05:00
Jeff Geerling da78cb61a3 Use time series for speedtest graph. 2021-04-04 09:33:37 -05:00
Jeff Geerling b96edae4b4 Update default speedtest interval to 30m to avoid suprise huge data usage. 2021-04-03 23:16:06 -05:00
Jeff Geerling 40c4542d91 Update docker-compose to always restart all the containers. 2021-03-23 19:13:02 -05:00
Jeff Geerling 52f7487ff1 Update ping dashboard with new defaults. 2021-03-23 19:07:13 -05:00
11 changed files with 1190 additions and 636 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.DS_Store

View File

@ -1,60 +1,28 @@
# A Docker Stack which Monitors your home network
# Internet Service Level Agreement Monitoring Docker Stack with Prometheus, Grafana and a small python ports checker.
> This repository is a fork from [maxandersen/internet-monitoring](https://github.com/maxandersen/internet-monitoring), tailored for use on a Raspberry Pi. It has only been tested on a Raspberry Pi 4 running Pi OS 64-bit beta.
> To learn more about the python ports checker use, please visit the related python project [here](https://github.com/xeviff/pyOpenPortsChecker4Prometheus)
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.
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/MiguelNdeCarvalho/speedtest-exporter) to collect and graph home Internet reliability and throughput.
## Pre-requisites
## This is a fork
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 been tested with Docker for Mac and Synology and it works.
Please, be aware this is an improvement based on an already existing project, so if you are interested on more details about its components, then I encourage you to take as first reference the original project [here](https://github.com/geerlingguy/internet-monitoring)
# Quick Start
## Configurations
```
git clone https://github.com/geerlingguy/internet-monitoring
cd internet-monitoring
docker-compose up
```
That's easy, check the both projects configuration steps :wink:
Another important thing is the threshold for the internet speed. In my case I should have 1GB symmetrical and if one day I'll have this real speed, the colors would get the green color (but I don't expect this will happen with fibracat.cat :triumph:). Anyway if you had 600 Mbps for example, you'd need to adjust the Grafana's dashboard thresholds to have the green color when the values reaches 600 instead of 1000.
But it's pretty easy, you (as grafana's administrator) edit the panels and change these values:
Goto [http://localhost:3030/d/o9mIe_Aik/internet-connection](http://localhost:3030/d/o9mIe_Aik/internet-connection) (change `localhost` to your docker host ip/name).
![image](https://user-images.githubusercontent.com/73612508/176744529-b2fd6d5a-c14e-4924-99b6-80959b964947.png)
## Configuration
To change what hosts you ping you change the `targets` section in [/prometheus/pinghosts.yaml](./prometheus/pinghosts.yaml) file.
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).
## Expected result
Once configurations are done let's start it up. From the /prometheus project directory run the following command:
This is how it looks like in my NAS:
$ docker-compose up -d
<center><img src="images/dashboard.jpeg" width="4600" heighth="500"></center>
That's it. docker-compose builds the entire Grafana and Prometheus stack automagically.
The Grafana Dashboard is now accessible via: `http://<Host IP Address>:3030` for example http://localhost:3030
username - admin
password - wonka (Password is stored in the `config.monitoring` env file)
The DataSource and Dashboard for Grafana are automatically provisioned.
If all works it should be available at http://localhost:3030/d/o9mIe_Aik/internet-connection - if no data shows up try change the timeduration to something smaller.
<center><img src="images/dashboard.png" width="4600" heighth="500"></center>
## Interesting urls
Note: replace `localhost` with your docker host ip/name if not running this locally.
http://localhost:9090/targets shows status of monitored targets as seen from prometheus - in this case which hosts being pinged and speedtest. note: speedtest will take a while before it shows as UP as it takes about 30s to respond.
http://localhost:9090/graph?g0.expr=probe_http_status_code&g0.tab=1 shows prometheus value for `probe_http_status_code` for each host. You can edit/play with additional values. Useful to check everything is okey in prometheus (in case Grafana is not showing the data you expect).
http://localhost:9115 blackbox exporter endpoint. Lets you see what have failed/succeded.
http://localhost:9798/metrics speedtest exporter endpoint. Does take about 30 seconds to show its result as it runs an actual speedtest when requested.
## Thanks and a disclaimer
Thanks to @vegasbrianc work on making a [super easy docker](https://github.com/vegasbrianc/github-monitoring) stack for running prometheus and grafana.
I also want to disclaim that Prometheus aren't really (currently) intended for this kind of blackbox/external monitoring and this setup is not in anyway secured. Thus only use this for inspiration and do not blame me if someone hacks this and figure out what your real internet speed is :)
<br>
The interesting thing is you can adjust the time visibility and get its average, for example the last 24h or even last week stats, etc.

View File

@ -11,6 +11,7 @@ networks:
services:
prometheus:
image: prom/prometheus:v2.25.2
restart: always
volumes:
- ./prometheus/:/etc/prometheus/
- prometheus_data:/prometheus
@ -24,11 +25,13 @@ services:
links:
- ping:ping
- speedtest:speedtest
- portschecker:portschecker
networks:
- back-tier
grafana:
image: grafana/grafana
restart: always
volumes:
- grafana_data:/var/lib/grafana
- ./grafana/provisioning/:/etc/grafana/provisioning/
@ -50,6 +53,7 @@ services:
ports:
- 9115:9115
image: prom/blackbox-exporter
restart: always
volumes:
- ./blackbox/config:/config
command:
@ -86,3 +90,19 @@ services:
- "^/(sys|proc|dev|host|etc|rootfs/var/lib/docker/containers|rootfs/var/lib/docker/overlay2|rootfs/run/docker/netns|rootfs/var/lib/docker/aufs)($$|/)"
networks:
- back-tier
portschecker:
tty: true
stdin_open: true
image: xeviff/python-prometheus-canyouseeme
volumes:
- ./pyPrometheusPortChecker/config:/config
depends_on:
- speedtest
expose:
- 9116
ports:
- 9116:9116
restart: always
networks:
- back-tier

View File

@ -1,3 +1,4 @@
GF_SECURITY_ADMIN_PASSWORD=wonka
GF_USERS_ALLOW_SIGN_UP=false
GF_INSTALL_PLUGINS=flant-statusmap-panel
GF_SECURITY_ADMIN_PASSWORD=grafana123
GF_USERS_ALLOW_SIGN_UP=true
GF_INSTALL_PLUGINS=flant-statusmap-panel,ae3e-plotly-panel
GF_AUTH_ANONYMOUS_ENABLED=true

File diff suppressed because it is too large Load Diff

View File

@ -1,568 +0,0 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"limit": 100,
"name": "Annotations & Alerts",
"showIn": 0,
"type": "dashboard"
}
]
},
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"links": [],
"panels": [
{
"cacheTimeout": null,
"datasource": "prometheus",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {},
"mappings": [
{
"id": 0,
"op": "=",
"text": "N/A",
"type": 1,
"value": "null"
}
],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "#299c46",
"value": null
},
{
"color": "blue",
"value": 100
}
]
},
"unit": "bps"
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 6,
"x": 0,
"y": 0
},
"id": 8,
"interval": null,
"links": [],
"maxDataPoints": 100,
"options": {
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
"mean"
],
"fields": "",
"values": false
},
"showThresholdLabels": false,
"showThresholdMarkers": true,
"text": {}
},
"pluginVersion": "7.4.5",
"targets": [
{
"expr": "speedtest_download_bits_per_second{}",
"format": "time_series",
"interval": "",
"intervalFactor": 1,
"legendFormat": "",
"refId": "A"
}
],
"title": "Download",
"type": "gauge"
},
{
"cacheTimeout": null,
"datasource": "prometheus",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {},
"mappings": [
{
"id": 0,
"op": "=",
"text": "N/A",
"type": 1,
"value": "null"
}
],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "blue",
"value": 20
}
]
},
"unit": "bps"
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 6,
"x": 6,
"y": 0
},
"id": 10,
"interval": null,
"links": [],
"maxDataPoints": 100,
"options": {
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
"mean"
],
"fields": "",
"values": false
},
"showThresholdLabels": false,
"showThresholdMarkers": true,
"text": {}
},
"pluginVersion": "7.4.5",
"targets": [
{
"expr": "speedtest_upload_bits_per_second{}",
"format": "time_series",
"interval": "",
"intervalFactor": 1,
"legendFormat": "",
"refId": "A"
}
],
"title": "Upload",
"type": "gauge"
},
{
"cacheTimeout": null,
"datasource": "prometheus",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {},
"decimals": 2,
"mappings": [
{
"id": 0,
"op": "=",
"text": "N/A",
"type": 1,
"value": "null"
}
],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "ms"
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 12,
"x": 12,
"y": 0
},
"id": 12,
"interval": null,
"links": [],
"maxDataPoints": 100,
"options": {
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
"mean"
],
"fields": "",
"values": false
},
"showThresholdLabels": false,
"showThresholdMarkers": true,
"text": {}
},
"pluginVersion": "7.4.5",
"targets": [
{
"expr": "speedtest_ping_latency_milliseconds",
"format": "time_series",
"instant": false,
"interval": "",
"intervalFactor": 1,
"legendFormat": "",
"refId": "A"
}
],
"title": "speedtest ping",
"type": "gauge"
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "prometheus",
"fieldConfig": {
"defaults": {
"custom": {},
"unit": "bps"
},
"overrides": []
},
"fill": 1,
"fillGradient": 0,
"gridPos": {
"h": 9,
"w": 12,
"x": 0,
"y": 9
},
"hiddenSeries": false,
"id": 6,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.4.5",
"pointradius": 5,
"points": false,
"renderer": "flot",
"repeat": null,
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "speedtest_download_bits_per_second{}",
"format": "time_series",
"interval": "",
"intervalFactor": 1,
"legendFormat": "",
"refId": "A"
},
{
"expr": "speedtest_upload_bits_per_second{}",
"hide": false,
"interval": "",
"legendFormat": "",
"refId": "B"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"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": "bps",
"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
}
},
{
"cards": {
"cardHSpacing": 2,
"cardMinWidth": 5,
"cardRound": null,
"cardVSpacing": 2
},
"color": {
"cardColor": "#b4ff00",
"colorScale": "sqrt",
"colorScheme": "interpolateGnYlRd",
"defaultColor": "#757575",
"exponent": 0.5,
"mode": "spectrum",
"thresholds": []
},
"datasource": "prometheus",
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 12,
"x": 12,
"y": 9
},
"highlightCards": true,
"id": 14,
"legend": {
"show": false
},
"links": [],
"nullPointMode": "as empty",
"pageSize": 15,
"seriesFilterIndex": -1,
"statusmap": {
"ConfigVersion": "v1"
},
"targets": [
{
"expr": "probe_success",
"format": "time_series",
"interval": "",
"intervalFactor": 1,
"legendFormat": "{{instance}}",
"refId": "A"
}
],
"title": "Panel Title",
"tooltip": {
"extraInfo": "",
"freezeOnClick": true,
"items": [],
"show": true,
"showExtraInfo": false,
"showItems": false
},
"type": "flant-statusmap-panel",
"useMax": true,
"usingPagination": false,
"xAxis": {
"show": true
},
"yAxis": {
"maxWidth": -1,
"minWidth": -1,
"show": true
},
"yAxisSort": "metrics",
"yLabel": {
"delimiter": "",
"labelTemplate": "",
"usingSplitLabel": false
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "prometheus",
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1,
"fillGradient": 0,
"gridPos": {
"h": 9,
"w": 24,
"x": 0,
"y": 18
},
"hiddenSeries": false,
"id": 4,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"maxPerRow": 12,
"nullPointMode": "null",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.4.5",
"pointradius": 5,
"points": false,
"renderer": "flot",
"repeat": "host",
"repeatDirection": "h",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "sum(probe_http_duration_seconds) by (instance)",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "{{instance}}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "http duration",
"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": 27,
"style": "dark",
"tags": [
"speedtest",
"ping"
],
"templating": {
"list": []
},
"time": {
"from": "now-30m",
"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",
"uid": "o9mIe_Aik",
"version": 1
}

BIN
images/dashboard.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 KiB

View File

@ -1,7 +1,8 @@
- targets: # url;humanname;routing;switch
- http://www.google.com/;google.com;external;internetbox
- https://github.com/;github.com;external;internetbox
- https://www.jeffgeerling.com;jeffgeerling.com;external;internetbox
#- https://github.com/;github.com;external;internetbox
- https://www.apple.com/;apple.com;external;internetbox
- https://www.fibracat.cat/;fibracat.cat;external;internetbox
# - http://192.168.1.1;internetbox;local;internetbox
# - http://192.168.1.42;blackdata;local;orbirouter-attic
# - http://192.168.1.101;orbirouter;local;orbirouter

View File

@ -1,43 +1,30 @@
# my global config
global:
scrape_interval: 15s # By default, scrape targets every 15 seconds.
evaluation_interval: 15s # By default, scrape targets every 15 seconds.
# scrape_timeout is set to the global default (10s).
# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
external_labels:
monitor: 'Alertmanager'
# Load and evaluate rules in this file every 'evaluation_interval' seconds.
rule_files:
- 'alert.rules'
# - "first.rules"
# - "second.rules"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
- job_name: 'prometheus'
# Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: 5s
scrape_interval: 60s
static_configs:
- targets: ['localhost:9090']
- job_name: 'speedtest'
metrics_path: /metrics
scrape_interval: 5m
scrape_interval: 30m
scrape_timeout: 60s # running speedtest needs time to complete
static_configs:
- targets: ['speedtest:9798']
- job_name: 'ping'
metrics_path: /probe
scrape_interval: 5s
scrape_interval: 60s
params:
module: [http_2xx] # Look for a HTTP 200 response.
file_sd_configs:
@ -68,3 +55,7 @@ scrape_configs:
- job_name: 'nodeexp'
static_configs:
- targets: ['nodeexp:9100']
- job_name: 'python-portschecker'
static_configs:
- targets: ['portschecker:9116']

View File

@ -0,0 +1,10 @@
service_port: 9116
scrape_frequency: 3600
host_to_check: yourdomain.is
ports_tocheck:
- 25
- 80
- 443
- 32400
- 22
- 51413