Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Dockerfile.grafana
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM grafana/grafana:latest

ENV GF_AUTH_ANONYMOUS_ENABLED=true
ENV GF_AUTH_ANONYMOUS_ORG_ROLE=Admin

EXPOSE 3000

ADD grafana-data/provisioning /etc/grafana/provisioning
ADD grafana-data/dashboards /var/lib/grafana/dashboards


CMD [ "grafana-reporter" ]
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,37 @@ For a more detail view on how to customize your images, see:
- [Producer](https://github.com/stefanDeveloper/heiDPI/blob/main/README.producer.md)
- [Consumer](https://github.com/stefanDeveloper/heiDPI/blob/main/README.consumer.md)

## Dashboarding

Das Dashboard-Modul bietet eine visuelle Oberfläche zur Analyse und Überwachung von Netzwerk-Flow-Events, die durch `heiDPI` generiert und mittels `Loki` in `Grafana` bereitgestellt werden.

### Dashboard

Das Dashboard gliedert sich in zwei Hauptbereiche:

1. **Übersichtspanels**:
- *Count Flows by Breed Type*: Balkendiagramm zur Darstellung der Anzahl von Flow-Events nach Klassifizierung (`ndpi_breed`).
- *Flow Events Time Plot*: Zeitreihenvisualisierung der Flow-Rate zur Erkennung zeitlicher Trends.
- *Unsafe & Tracking Flows*: Tabelle mit Flows klassifiziert als `Unsafe` oder `Tracker/Ads`.
- *Potentially Dangerous & Dangerous Flows*: Flows mit erhöhtem Sicherheitsrisiko.
- *Unrated Flows*: Flows ohne Bewertung zur weiteren Untersuchung.

2. **Detailansicht pro Flow-ID**:
- Selektierbare Variable `Flow ID` erlaubt das gezielte Anzeigen und Analysieren einzelner Flows in dedizierten Panels.

### Alerts

Das System beinhaltet eine Alert-Regel zur Erkennung gefährlicher Flows:

- **Dangerous Flow Events Alert**: Überwacht Flows mit `ndpi_breed="Dangerous"` und löst eine Warnung bei erkennung aus. Die Benachrichtigung verweist auf das Dashboard zur detaillierten Analyse.

> Hinweis: Die URL des Webhooks muss vor dem produktiven Einsatz in der Datei `./grafana-data/provisioning/alerting/contact-points.yml` angepasst werden.

### Provisionierung

Die Dashboard Funktionalität wird über `docker compose` gesteuert und startet zusammen mit heiDPI.
Grafana ist unter `localhost:3000` erreichbar.

## License

This project is licensed under the GPL-3.0 license - see the [LICENSE.md](https://github.com/stefanDeveloper/heiDPI/blob/main/LICENSE) file for details.
30 changes: 30 additions & 0 deletions config-files/config.alloy
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
loki.write "local_loki" {
endpoint {
url = "http://loki:3100/loki/api/v1/push"
}
}

local.file_match "testing_logging" {
path_targets = [{"__path__" = "/tmp/heidpi-logs/*.json"}]
sync_period = "5s"
}

loki.source.file "local_files2" {
targets = local.file_match.testing_logging.targets
//forward_to = [loki.write.local_loki.receiver]
forward_to = [loki.process.add_labels.receiver]
}

loki.process "add_labels" {
stage.json {
expressions = {flow_id = "flow_id"}
}

stage.labels {
values = {
flow_id = "flow_id",
}
}

forward_to = [loki.write.local_loki.receiver]
}
52 changes: 52 additions & 0 deletions config-files/loki-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
auth_enabled: false

server:
http_listen_port: 3100

distributor:
ring:
kvstore:
store: inmemory

ingester:
wal:
dir: /loki/wal # <-- Add this line to specify the WAL directory
lifecycler:
ring:
kvstore:
store: inmemory
replication_factor: 1
chunk_idle_period: 3m
chunk_retain_period: 1m
max_chunk_age: 1h
chunk_target_size: 1048576

schema_config:
configs:
- from: 2023-01-01
store: boltdb-shipper
object_store: filesystem
schema: v11
index:
prefix: index_
period: 24h

storage_config:
boltdb_shipper:
active_index_directory: /loki/index
shared_store: filesystem
cache_location: /loki/cache
filesystem:
directory: /loki/chunks

limits_config:
enforce_metric_name: false
reject_old_samples: true
reject_old_samples_max_age: 168h
ingestion_rate_mb: 8
ingestion_burst_size_mb: 16

compactor:
working_directory: /loki/compactor
shared_store: filesystem

2 changes: 1 addition & 1 deletion config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ flow_event:
- detection-update
filename: flow_event
geoip2_city:
enabled: True
enabled: False
filepath: /tmp/city.mmdb
keys:
- country.names.en
Expand Down
69 changes: 57 additions & 12 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
version: "3.9"

networks:
loki:

volumes:
grafana-data:

services:
producer:
image: stefan96/heidpi-producer:latest
container_name: heidpi_producer
network_mode: host
security_opt:
- no-new-privileges
pids_limit: 8192
# pids_limit: 8192
restart: on-failure:5
deploy:
resources:
limits:
cpus: '5'
memory: 32G
# deploy:
# resources:
# limits:
# cpus: '5'
# memory: 32G
environment:
- HOSTNAME=test
- TUNE_PARAM=max-reader-threads=4,max-flows-per-thread=65536,max-idle-flows-per-thread=2048,daemon-status-interval=15000000,flow-scan-interval=15000000,generic-max-idle-time=15000001,icmp-max-idle-time=15000001,udp-max-idle-time=15000001,tcp-max-idle-time=15000001,tcp-max-post-end-flow-time=5000000
Expand All @@ -30,14 +36,53 @@ services:
network_mode: host
security_opt:
- no-new-privileges
pids_limit: 8192
# pids_limit: 8192
restart: on-failure:5
deploy:
resources:
limits:
cpus: '1'
memory: 2G
# deploy:
# resources:
# limits:
# cpus: '1'
# memory: 2G
depends_on:
- producer
environment:
- SHOW_DAEMON_EVENTS=1

loki:
image: grafana/loki:2.9.2
ports:
- "3100:3100"
volumes:
- ./config-files/loki-config.yaml:/etc/loki/local-config.yaml # Correct relative path
- ./loki/rules:/loki/rules:rw # Correct relative path
- ./loki/index:/loki/index:rw # Added volume for index directory
- ./loki/cache:/loki/cache:rw # Added volume for cache directory
- ./loki/chunks:/loki/chunks:rw # Added volume for chunks directory
- ./loki/compactor:/loki/compactor:rw # Added volume for compactor directory
- ./loki/wal:/loki/wal:rw
command: -config.file=/etc/loki/local-config.yaml
networks:
- loki

alloy:
image: grafana/alloy:latest
ports:
- "12345:12345"
volumes:
- ./config-files/config.alloy:/etc/alloy/config.alloy
- ./heidpi-logs:/tmp/heidpi-logs
command: run --server.http.listen-addr=0.0.0.0:12345 --storage.path=/var/lib/alloy/data /etc/alloy/config.alloy --stability.level experimental
networks:
- loki
depends_on:
- loki

grafana:
build:
dockerfile: ./Dockerfile.grafana
volumes:
- grafana-data:/var/lib/grafana
ports:
- "3000:3000"
networks:
- loki
Loading