Skip to content

Commit

Permalink
More metrics and more (#3)
Browse files Browse the repository at this point in the history
* more metrics and optimizations

* add grafana dashboard and local stack

* simple renaming
  • Loading branch information
raylas committed Nov 27, 2022
1 parent be87bdb commit 37a2aa1
Show file tree
Hide file tree
Showing 38 changed files with 1,994 additions and 77 deletions.
File renamed without changes.
File renamed without changes.
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ A [Prometheus exporter](https://prometheus.io/docs/instrumenting/exporters/) for
- `METRICS_PATH` (default: `/metrics`)
- `NEXTDNS_PROFILE` (required: [docs](https://nextdns.github.io/api/#profile))
- `NEXTDNS_API_KEY` (required: [docs](https://nextdns.github.io/api/#authentication))
- `NEXTDNS_FILTER_FROM` (default: `-1d`)
- `NEXTDNS_RESULT_WINDOW` (default: `-5m`)
- `NEXTDNS_RESULT_LIMIT` (default: `50`)

For most accurate data, the scrape interval _should_ match the value set via `NEXTDNS_RESULT_WINDOW`.

Recommended timeout is `10` seconds.

## Usage

### Binary
Expand All @@ -36,3 +40,22 @@ docker run -d \
-e NEXTDNS_API_KEY=<api_key> \
ghcr.io/raylas/nextdns-exporter
```

### Compose

The following will create a local stack of the exporter, Prometheus, and Grafana:
```sh
NEXDTDNS_PROFILE=<profile_id> \
NEXTDNS_API_KEY=<api_key> \
docker-compose up -d
```

Access Grafana by navigating to [http://localhost:3000](http://localhost:3000).

**Note:** Data will take a few minutes to trickle in.

## Dashboard

A basic Grafana dashboard is found [here](/grafana/dashboards/nextdns.json).

![Grafana dashboard](/grafana/dashboards/nextdns.png)
28 changes: 28 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
services:
nextdns-exporter:
build:
context: .
restart: unless-stopped
ports:
- 9948:9948
environment:
NEXTDNS_PROFILE: ${NEXTDNS_PROFILE}
NEXTDNS_API_KEY: ${NEXTDNS_API_KEY}
NEXTDNS_RESULT_WINDOW: -1m

prometheus:
image: prom/prometheus:v2.40.3
restart: unless-stopped
ports:
- 9090:9090
volumes:
- ./grafana/prometheus.yaml:/etc/prometheus/prometheus.yml

grafana:
image: grafana/grafana-oss:9.2.6
restart: unless-stopped
ports:
- 3000:3000
volumes:
- ./grafana/grafana.ini:/etc/grafana/grafana.ini
- ./grafana:/etc/grafana/provisioning
36 changes: 36 additions & 0 deletions fixtures/destinations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"data": [
{
"code": "US",
"name": "United States of America",
"domains": [
"weather-data.apple.com",
"gateway.icloud.com",
"mobile.events.data.microsoft.com",
"ocsp2.apple.com"
],
"queries": 137
},
{
"code": "DE",
"name": "Germany",
"domains": [
"controlplane.tailscale.com"
],
"queries": 2
},
{
"code": "FR",
"name": "France",
"domains": [
"mobile.events.data.microsoft.com"
],
"queries": 1
}
],
"meta": {
"pagination": {
"cursor": null
}
}
}
23 changes: 23 additions & 0 deletions fixtures/devices.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"data": [
{
"id": "E8TTX",
"name": "Gaming PC",
"model": "linux",
"localIp": "192.168.1.100",
"queries": 12
},
{
"id": "85C3A",
"name": "iPhone",
"model": "Apple, Inc.",
"localIp": "192.168.1.105",
"queries": 83
}
],
"meta": {
"pagination": {
"cursor": null
}
}
}
17 changes: 17 additions & 0 deletions fixtures/dnssec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"data": [
{
"validated": false,
"queries": 183
},
{
"validated": true,
"queries": 4
}
],
"meta": {
"pagination": {
"cursor": null
}
}
}
17 changes: 17 additions & 0 deletions fixtures/encryption.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"data": [
{
"encrypted": true,
"queries": 48058
},
{
"encrypted": false,
"queries": 1629
}
],
"meta": {
"pagination": {
"cursor": null
}
}
}
17 changes: 17 additions & 0 deletions fixtures/ip_versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"data": [
{
"version": 4,
"queries": 392
},
{
"version": 6,
"queries": 10
}
],
"meta": {
"pagination": {
"cursor": null
}
}
}
17 changes: 17 additions & 0 deletions fixtures/protocols.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"data": [
{
"protocol": "DNS-over-HTTPS",
"queries": 17115
},
{
"protocol": "UDP",
"queries": 354
}
],
"meta": {
"pagination": {
"cursor": null
}
}
}
34 changes: 34 additions & 0 deletions fixtures/query_types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"data": [
{
"type": 1,
"name": "A",
"queries": 207
},
{
"type": 28,
"name": "AAAA",
"queries": 199
},
{
"type": 65,
"name": "HTTPS",
"queries": 87
},
{
"type": 12,
"name": "PTR",
"queries": 11
},
{
"type": 16,
"name": "TXT",
"queries": 5
}
],
"meta": {
"pagination": {
"cursor": null
}
}
}
11 changes: 11 additions & 0 deletions grafana/dashboards/local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: 1

providers:
- name: Local
orgId: 1
type: file
disableDeletion: false
updateIntervalSeconds: 10
allowUiUpdates: false
options:
path: /etc/grafana/provisioning/dashboards

0 comments on commit 37a2aa1

Please sign in to comment.