Skip to content

Commit

Permalink
Added support for separating external hosts from "internal" hosts on …
Browse files Browse the repository at this point in the history
…the same network.
  • Loading branch information
dmuth committed Oct 30, 2022
1 parent 9af8db2 commit e9acee2
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@ data/prometheus
#
docker-compose.override.yml

#
# Don't include hosts.txt, since I expect that users will modify it.
#
hosts.txt

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This is a little project I put together that lets you spin up a Grafana ecosyste

<a href="./img/septa-regional-rail.png"><img src="./img/septa-regional-rail.png" align="right" width="300" /></a>

- `cp hosts.txt.sample hosts.txt` to set up your `hosts.txt` file
- Run `docker-compose up` to start up the environment.
- Go to http://localhost:3000/ and log into Grafana with login/pass of `admin/admin`.
- [Create an API with Admin access](http://localhost:3000/org/apikeys)
Expand All @@ -45,6 +46,7 @@ This is a little project I put together that lets you spin up a Grafana ecosyste
Look, just start with the ping dashboard, okay?

- [Ping Results](http://localhost:3000/d/WiThvuS7z/ping-results) - Shows ping time and packet loss for specified hosts. The hosts can be changed.
- Additionally, any hostname (as defined in `hosts.txt`) that starts with `internal-` will be excluded from the aggregate ping dashbaord. This makes tracking Internet outages easier.

Yeah, so you loaded the dashboard, and it's showing the results of pinging multiple hosts on the Internet (round-trip time and packet loss) on a dashboard that gets updated every 5 seconds! Neat, huh?

Expand Down
2 changes: 1 addition & 1 deletion config/dashboards.json

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions config/promtail-config-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ scrape_configs:
stages:
- regex:
expression: '(?P<timestamp>(\d+-\d+-\d+ \d+:\d+:\d+\.\d+))'
#- labels:
# test_timestamp: timestamp
- regex:
expression: 'target=(?P<target>([^ ]+)) '
- labels:
target: target
- timestamp:
source: timestamp
#
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.override.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:

ping:
#environment:
#HOSTS: "google.com amazon.com google-dns-4 google-dns-8 quad9 router-192-168-1-1 router-10-0-0-1"
#HOSTS: "google.com amazon.com google-dns-4 google-dns-8 quad9-dns internal-192-168-1-1 internal-10-0-0-1"
logging:
driver: loki
options:
Expand Down
7 changes: 5 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ services:
# Read logs from files and ingest into Loki.
#
promtail:
image: grafana/promtail:2.3.0
#image: grafana/promtail:2.3.0
image: grafana/promtail:latest
volumes:
- logs:/logs/
- ./config:/mnt/config
Expand All @@ -106,7 +107,9 @@ services:
# The Loki database for storing logs.
#
loki:
image: grafana/loki:2.3.0
#image: grafana/loki:2.3.0
#image: grafana/loki:2.6.1
image: grafana/loki:latest
volumes:
- ./config:/mnt/config
- ./data/loki-data:/tmp/loki
Expand Down
16 changes: 16 additions & 0 deletions hosts.txt.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# This file is copied to /etc/hosts in the ping container.
#
127.0.0.1 localhost
8.8.4.4 google-dns-4
8.8.8.8 google-dns-8
9.9.9.9 quad9-dns

#
# Any hostname that starts with "internal" will be treated differently--it will have
# a separate dashboard for packet loss, and it will not be included
# in the aggregate packet loss dashboard.
#
192.168.1.1 internal-192-168-1-1
10.0.0.1 internal-10-0-0-1

0 comments on commit e9acee2

Please sign in to comment.