linuxserver / docker-mods

Documentation and Examples of base container modifications
GNU General Public License v3.0
1.06k stars 279 forks source link

swag-geoip2influx doesn't work with influxdb2 #894

Closed sidneyelagib closed 5 months ago

sidneyelagib commented 5 months ago

Is there an existing issue for this?

Name of mod

linuxserver/mods:swag-geoip2influx

Name of base container

This is the container image used lscr.io/linuxserver/swag

Current Behavior

When I start the container with added DOCKER_MODS=linuxserver/mods:universal-docker|linuxserver/mods:swag-geoip2influx|linuxserver/mods:swag-maxmind I get the following errors in the logs:

swag | GEOIP2INFLUX 09/May/2024 17:30:41 :: DEBUG :: Found: /config/log/nginx/access.log swag | GEOIP2INFLUX 09/May/2024 17:30:41 :: DEBUG :: Found: /config/geoip2db/GeoLite2-City.mmdb swag | GEOIP2INFLUX 09/May/2024 17:30:41 :: DEBUG :: Testing InfluxDB connection swag | GEOIP2INFLUX 09/May/2024 17:30:41 :: DEBUG :: Starting new HTTP connection (1): influxdb2:8086 swag | GEOIP2INFLUX 09/May/2024 17:30:41 :: DEBUG :: http://influxdb2:8086 "GET /ping HTTP/1.1" 204 0 swag | GEOIP2INFLUX 09/May/2024 17:30:41 :: DEBUG :: Influxdb version: v2.7.6 swag | GEOIP2INFLUX 09/May/2024 17:30:41 :: DEBUG :: http://influxdb2:8086 "GET /query?q=SHOW+DATABASES&db=geoip2influx HTTP/1.1" 401 48 swag | GEOIP2INFLUX 09/May/2024 17:30:41 :: CRITICAL :: Error getting database list! Please check your InfluxDB configuration. swag | Error: 401: {"code":"unauthorized","message":"Unauthorized"}

Expected Behavior

The expectation is that the mod will connect to the influxdb and will write the necessary data in the influxdb. It looks like the script is working with influxdb v1 but not with influxdb v2. As per the InfluxDB2 documentation it looks like they've changed the API and it doesn't require username and password anymore, but a token.

client = influxdb_client.InfluxDBClient(
   url=url,
   token=token,
   org=org
)

Steps To Reproduce

  1. Install docker & docker desktop
  2. Create the required directories from the docker compose file
  3. Acquire maxmind license key
  4. Add the required variables in an .env file
  5. docker compose up
  6. create geoip2influx database in influxdb2
  7. docker compose logs swag -f

Environment

- OS: Windows (+ Ubuntu WSL2)
- How docker service was installed: Docker Desktop
---
- OS: Ubuntu 22.04
- How docker service was installed: apt

CPU architecture

x86-64

Docker creation

services:
  swag:
    image: lscr.io/linuxserver/swag:latest
    container_name: swag
    cap_add:
      - NET_ADMIN
    environment:
      - PUID
      - PGID
      - TZ
      - DOCKER_MODS=linuxserver/mods:universal-docker|linuxserver/mods:swag-geoip2influx|linuxserver/mods:swag-maxmind
      - URL=example.com
      - SUBDOMAINS=wildcard
      - VALIDATION=dns
      - DNSPLUGIN=cloudflare
      - EMAIL=$ACME_EMAIL
      - STAGING=false
      - MAXMINDDB_LICENSE_KEY=$SWAG_MAXMINDDB_LICENSE_KEY
      - INFLUX_HOST=influxdb2
      - INFLUX_USER=$INFLUXDB_ADMIN_USER
      - INFLUX_PASS=$INFLUXDB_ADMIN_PASS
    volumes:
      - "./data/swag:/config"
    ports:
      - 443:443
      - 80:80
    restart: unless-stopped
    depends_on:
      - influxdb2
  influxdb2:
    container_name: influxdb2
    image: influxdb:latest
    volumes:
      - "./data/influxdb/db:/var/lib/influxdb2"
      - "./data/influxdb/config:/etc/influxdb2"
    environment:
      - DOCKER_INFLUXDB_INIT_MODE=setup
      - DOCKER_INFLUXDB_INIT_USERNAME=$INFLUXDB_ADMIN_USER
      - DOCKER_INFLUXDB_INIT_PASSWORD=$INFLUXDB_ADMIN_PASS
      - DOCKER_INFLUXDB_INIT_ORG=myorg
      - DOCKER_INFLUXDB_INIT_BUCKET=test-bucket
      - DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=$INFLUXDB_ADMIN_TOKEN
      - PUID
      - PGID
      - TZ
    restart: unless-stopped

Container logs

swag  | GEOIP2INFLUX 09/May/2024 17:30:38 :: DEBUG :: Found: /config/log/nginx/access.log
swag  | GEOIP2INFLUX 09/May/2024 17:30:38 :: DEBUG :: Found: /config/geoip2db/GeoLite2-City.mmdb
swag  | GEOIP2INFLUX 09/May/2024 17:30:38 :: DEBUG :: Testing InfluxDB connection
swag  | GEOIP2INFLUX 09/May/2024 17:30:38 :: DEBUG :: Starting new HTTP connection (1): influxdb2:8086
swag  | GEOIP2INFLUX 09/May/2024 17:30:38 :: DEBUG :: http://influxdb2:8086 "GET /ping HTTP/1.1" 204 0
swag  | GEOIP2INFLUX 09/May/2024 17:30:38 :: DEBUG :: Influxdb version: v2.7.6
swag  | GEOIP2INFLUX 09/May/2024 17:30:38 :: DEBUG :: http://influxdb2:8086 "GET /query?q=SHOW+DATABASES&db=geoip2influx HTTP/1.1" 401 48
swag  | GEOIP2INFLUX 09/May/2024 17:30:38 :: CRITICAL :: Error getting database list! Please check your InfluxDB configuration.
swag  | Error: 401: {"code":"unauthorized","message":"Unauthorized"}
swag  | GEOIP2INFLUX 09/May/2024 17:30:39 :: INFO :: Starting geoip2influx..
swag  | GEOIP2INFLUX 09/May/2024 17:30:39 :: DEBUG :: Variables set:
swag  |  geoip_db_path             :: /config/geoip2db/GeoLite2-City.mmdb
swag  |  -e LOG_PATH               :: /config/log/nginx/access.log
swag  |  -e INFLUX_HOST            :: influxdb2
swag  |  -e INFLUX_HOST_PORT       :: 8086
swag  |  -e INFLUX_DATABASE        :: geoip2influx
swag  |  -e INFLUX_RETENTION       :: 7d
swag  |  -e INFLUX_SHARD           :: 1d
swag  |  -e INFLUX_USER            :: hidden
swag  |  -e INFLUX_PASS            :: hidden
swag  |  -e GEO_MEASUREMENT        :: geoip2influx
swag  |  -e LOG_MEASUREMENT        :: nginx_access_logs
swag  |  -e SEND_NGINX_LOGS        :: true
swag  |  -e GEOIP2INFLUX_LOG_LEVEL :: DEBUG
swag  | GEOIP2INFLUX 09/May/2024 17:30:39 :: DEBUG :: Found: /config/log/nginx/access.log
swag  | GEOIP2INFLUX 09/May/2024 17:30:39 :: DEBUG :: Found: /config/geoip2db/GeoLite2-City.mmdb
swag  | GEOIP2INFLUX 09/May/2024 17:30:39 :: DEBUG :: Testing InfluxDB connection
swag  | GEOIP2INFLUX 09/May/2024 17:30:39 :: DEBUG :: Starting new HTTP connection (1): influxdb2:8086
swag  | GEOIP2INFLUX 09/May/2024 17:30:39 :: DEBUG :: http://influxdb2:8086 "GET /ping HTTP/1.1" 204 0
swag  | GEOIP2INFLUX 09/May/2024 17:30:39 :: DEBUG :: Influxdb version: v2.7.6
swag  | GEOIP2INFLUX 09/May/2024 17:30:39 :: DEBUG :: http://influxdb2:8086 "GET /query?q=SHOW+DATABASES&db=geoip2influx HTTP/1.1" 401 48
swag  | GEOIP2INFLUX 09/May/2024 17:30:39 :: CRITICAL :: Error getting database list! Please check your InfluxDB configuration.
swag  | Error: 401: {"code":"unauthorized","message":"Unauthorized"}
4-FLOSS-Free-Libre-Open-Source-Software commented 5 months ago
GilbN commented 1 month ago

It does now. https://github.com/GilbN/geoip2influx?tab=readme-ov-file#influxdb_v2_token