Loki conntrack
conntrack
This dashboard uses Loki to display information about the network connections of a gateway.
In the gateway, the following systemd unit has been defined.
vcarceler@cirdan-2204:~$ cat /etc/systemd/system/conntrack-to-journal.service
[Unit]
Description=Send to journal DESTROY events for nat flows
After=network.target
[Service]
Type=simple
# Needs:
#
# echo 1 >/proc/sys/net/netfilter/nf_conntrack_acct
# echo 1 >/proc/sys/net/netfilter/nf_conntrack_timestamp
#
# Increased buffer-size
ExecStart=/bin/sh -c '/usr/sbin/conntrack -E -e DESTROY --buffer-size 21299200 | /usr/bin/sed "s/\[DESTROY\] /\[DESTROY\] prot=/;s/src=/srca=/;s/src=/srcb=/;s/dst=/dsta=/;s/dst=/dstb=/;s/sport=/sporta=/;s/sport=/sportb=/;s/dport=/dporta=/;s/dport=/dportb=/;s/packets=/packetsa=/;s/packets=/packetsb=/;s/bytes=/bytesa=/;s/bytes=/bytesb=/"'
TimeoutSec = 2
Restart = on-failure
RestartSec = 10
[Install]
WantedBy=multi-user.target
vcarceler@cirdan-2204:~$
This unit uses conntrack to log a line to the journal every time conntrack closes a connection. We use sed to rename the fields src, dst, sport, dport, … for both flows.
We enable accounting and timestamp in sysctl.conf.
net.netfilter.nf_conntrack_acct = 1
net.netfilter.nf_conntrack_timestamp = 1
Data source config
Collector config:
Upload an updated version of an exported dashboard.json file from Grafana
Revision | Description | Created | |
---|---|---|---|
Download |
Grafana Loki (self-hosted)
Easily monitor Grafana Loki (self-hosted), a horizontally scalable, highly available, multi-tenant log aggregation system inspired by Prometheus, with Grafana Cloud's out-of-the-box monitoring solution.
Learn more