dadevel / prometheus-nftables-exporter

Prometheus Exporter for Linux Nftables Firewall Stats
MIT License
6 stars 4 forks source link

GEODB Crashed #2

Open DoM1niC opened 3 years ago

DoM1niC commented 3 years ago

Python 3.9 without Docker without Database all works so far for me

INFO:nftables-exporter:listing on :9630
INFO:nftables-exporter:geoip lookup enabled
INFO:nftables-exporter:maxmind database stored at data/GeoLite2-Country_20211026/GeoLite2-Country.mmdb
INFO:nftables-exporter:startup complete
Traceback (most recent call last):
  File "/opt/prometheus-nftables-exporter/./main.py", line 294, in <module>
    main()
  File "/opt/prometheus-nftables-exporter/./main.py", line 42, in main
    collect_metrics(*metrics, geoip_db=database)
  File "/opt/prometheus-nftables-exporter/./main.py", line 108, in collect_metrics
    for labels, value in annotate_elements_with_country(item, geoip_db):
  File "/opt/prometheus-nftables-exporter/./main.py", line 152, in annotate_elements_with_country
    raise TypeError(f'got element of unexpected type {element.__class__.__name__}')
TypeError: got element of unexpected type list
dadevel commented 3 years ago

I can't reproduce the issue, so please provide the following info to aid in debugging:

DoM1niC commented 3 years ago
PRETTY_NAME="Debian GNU/Linux bookworm/sid"
NAME="Debian GNU/Linux"
ID=debian
Python 3.9.7
nftables v1.0.0 (Fearless Fosdick #2)

yep latest git Commits

root@firewall:/opt/prometheus-nftables-exporter# git pull
Already up to date.

added in the End of my NFT Config

# Monitoring
tcp dport { 80, 443 } meter http-limit { ip saddr limit rate over 100/second} counter name http-denied drop
tcp dport { 80, 443 } meter http6-limit { ip6 saddr limit rate over 100/second } counter name http-denied drop
tcp dport { 80, 443 } counter name http-allowed accept

Bash Log

root@firewall:/opt/prometheus-nftables-exporter# NFTABLES_EXPORTER_LOG_LEVEL=DEBUG MAXMIND_LICENSE_KEY=<maxindkey> NFTABLES_EXPORTER_UPDATE_PERIOD=0 python3 ./main.py
INFO:nftables-exporter:listing on :9630
INFO:nftables-exporter:geoip lookup enabled
DEBUG:nftables-exporter:database checksum 6f28a480539a2f6a46a824127b2006c118acfc1e09eeb6b2d32d08e31ad74f00
INFO:nftables-exporter:maxmind database stored at data/GeoLite2-Country_20211026/GeoLite2-Country.mmdb
INFO:nftables-exporter:startup complete
DEBUG:nftables-exporter:collecting metrics
DEBUG:nftables-exporter:fetching nftables ruleset
DEBUG:nftables-exporter:fetching nftables ruleset
DEBUG:nftables-exporter:fetching nftables counters
DEBUG:nftables-exporter:fetching nftables maps
Traceback (most recent call last):
  File "/opt/prometheus-nftables-exporter/./main.py", line 294, in <module>
    main()
  File "/opt/prometheus-nftables-exporter/./main.py", line 42, in main
    collect_metrics(*metrics, geoip_db=database)
  File "/opt/prometheus-nftables-exporter/./main.py", line 108, in collect_metrics
    for labels, value in annotate_elements_with_country(item, geoip_db):
  File "/opt/prometheus-nftables-exporter/./main.py", line 152, in annotate_elements_with_country
    raise TypeError(f'got element of unexpected type {element.__class__.__name__}')
TypeError: got element of unexpected type list
dadevel commented 2 years ago

Thanks, I'll have a detailed look later this week and report back.

dadevel commented 2 years ago

The bug is not really fixed, but at least it should not crash anymore. It would be nice if you could try the new version (v2.0.1) and post the debug log again.