smilebasti / npmGrafStats

This project exports NginxProxyManager Logs to InfluxDB for displaying them in a Grafana Dashboard.
GNU General Public License v3.0
149 stars 10 forks source link

Requests not logging into Influx/Visible in Grafana. #35

Closed bengeek2 closed 10 months ago

bengeek2 commented 10 months ago

Hello, I installed using docker compose following the guide in the wiki, but the Grafana dashboard is not showing data, and I cannot find the data in the influx db instance.

Things I have checked: I have entered the shell for the npmgraf container and verified it could ping all other containers with their listed hostnames. Tokens being correct The successful download of both .mmdb for geolite

When attached to the containers, this is what is shown when viewing my site (I have hidden to location and IP info):

nginx-home-npmgraf-1      | **************** start *********************
nginx-home-npmgraf-1      | Measurement-name: ReverseProxyConnections
nginx-home-npmgraf-1      | United States
nginx-home-npmgraf-1      | Texas
nginx-home-npmgraf-1      | x.x.x.x 
nginx-home-npmgraf-1      | x.x.x.x
nginx-home-npmgraf-1      | x.x.x.x
nginx-home-npmgraf-1      | x.x.x.x
nginx-home-npmgraf-1      | US
nginx-home-npmgraf-1      | x.x.x.x-TEXAS
nginx-home-npmgraf-1      | Outside IP:  x.x.x.x
nginx-home-npmgraf-1      | Target IP:  x.x.x.x
nginx-home-npmgraf-1      | Domain:  x.x.x.x.org
nginx-home-npmgraf-1      | Measurement Time:  2023-12-21T20:36:33+00:00
nginx-home-npmgraf-1      | Traceback (most recent call last):
nginx-home-npmgraf-1      |   File "/root/.config/NPMGRAF/Getipinfo.py", line 137, in <module>
nginx-home-npmgraf-1      |     write_api.write(bucket=ifbucket, org=iforg, record=point)
nginx-home-npmgraf-1      |   File "/usr/local/lib/python3.12/site-packages/influxdb_client/client/write_api.py", line 378, in write
nginx-home-npmgraf-1      |     results = list(map(write_payload, payloads.items()))
nginx-home-npmgraf-1      |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
nginx-home-npmgraf-1      |   File "/usr/local/lib/python3.12/site-packages/influxdb_client/client/write_api.py", line 376, in write_payload
nginx-home-npmgraf-1      |     return self._post_write(_async_req, bucket, org, final_string, payload[0])
nginx-home-npmgraf-1      |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
nginx-home-npmgraf-1      |   File "/usr/local/lib/python3.12/site-packages/influxdb_client/client/write_api.py", line 509, in _post_write
nginx-home-npmgraf-1      |     return self._write_service.post_write(org=org, bucket=bucket, body=body, precision=precision,
nginx-home-npmgraf-1      |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
nginx-home-npmgraf-1      |   File "/usr/local/lib/python3.12/site-packages/influxdb_client/service/write_service.py", line 60, in post_write
nginx-home-npmgraf-1      |     (data) = self.post_write_with_http_info(org, bucket, body, **kwargs)  # noqa: E501
nginx-home-npmgraf-1      |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
nginx-home-npmgraf-1      |   File "/usr/local/lib/python3.12/site-packages/influxdb_client/service/write_service.py", line 90, in post_write_with_http_info
nginx-home-npmgraf-1      |     return self.api_client.call_api(
nginx-home-npmgraf-1      |            ^^^^^^^^^^^^^^^^^^^^^^^^^
nginx-home-npmgraf-1      |   File "/usr/local/lib/python3.12/site-packages/influxdb_client/_sync/api_client.py", line 343, in call_api
nginx-home-npmgraf-1      |     return self.__call_api(resource_path, method,
nginx-home-npmgraf-1      |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
nginx-home-npmgraf-1      |   File "/usr/local/lib/python3.12/site-packages/influxdb_client/_sync/api_client.py", line 173, in __call_api
nginx-home-npmgraf-1      |     response_data = self.request(
nginx-home-npmgraf-1      |                     ^^^^^^^^^^^^^
nginx-home-npmgraf-1      |   File "/usr/local/lib/python3.12/site-packages/influxdb_client/_sync/api_client.py", line 388, in request
nginx-home-npmgraf-1      |     return self.rest_client.POST(url,
nginx-home-npmgraf-1      |            ^^^^^^^^^^^^^^^^^^^^^^^^^^
nginx-home-npmgraf-1      |   File "/usr/local/lib/python3.12/site-packages/influxdb_client/_sync/rest.py", line 311, in POST
nginx-home-npmgraf-1      |     return self.request("POST", url,
nginx-home-npmgraf-1      |            ^^^^^^^^^^^^^^^^^^^^^^^^^
nginx-home-npmgraf-1      |   File "/usr/local/lib/python3.12/site-packages/influxdb_client/_sync/rest.py", line 220, in request
nginx-home-npmgraf-1      |     r = self.pool_manager.request(
nginx-home-npmgraf-1      |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
nginx-home-npmgraf-1      |   File "/usr/local/lib/python3.12/site-packages/urllib3/_request_methods.py", line 118, in request
nginx-home-npmgraf-1      |     return self.request_encode_body(
nginx-home-npmgraf-1      |            ^^^^^^^^^^^^^^^^^^^^^^^^^
nginx-home-npmgraf-1      |   File "/usr/local/lib/python3.12/site-packages/urllib3/_request_methods.py", line 217, in request_encode_body
nginx-home-npmgraf-1      |     return self.urlopen(method, url, **extra_kw)
nginx-home-npmgraf-1      |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
nginx-home-npmgraf-1      |   File "/usr/local/lib/python3.12/site-packages/urllib3/poolmanager.py", line 433, in urlopen
nginx-home-npmgraf-1      |     conn = self.connection_from_host(u.host, port=u.port, scheme=u.scheme)
nginx-home-npmgraf-1      |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
nginx-home-npmgraf-1      |   File "/usr/local/lib/python3.12/site-packages/urllib3/poolmanager.py", line 295, in connection_from_host
nginx-home-npmgraf-1      |     raise LocationValueError("No host specified.")
nginx-home-npmgraf-1      | urllib3.exceptions.LocationValueError: No host specified.

And this is my dockerfile

version: '3.8'
services:
  npm:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: always
    ports:
      # These ports are in format <host-port>:<container-port>
      - '80:80' # Public HTTP Port
      - '443:443' # Public HTTPS Port
      - '81:81' # Admin Web Port
      # Add any other Stream port you want to expose
      # - '21:21' # FTP
    environment:
      # Mysql/Maria connection parameters:
      DB_MYSQL_HOST: "db"
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "npm"
      DB_MYSQL_PASSWORD: "npm"
      DB_MYSQL_NAME: "npm"
      # Uncomment this if IPv6 is not enabled on your host
      DISABLE_IPV6: 'true'
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    depends_on:
      - db

  db:
    image: 'jc21/mariadb-aria:latest'
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: 'npm'
      MYSQL_DATABASE: 'npm'
      MYSQL_USER: 'npm'
      MYSQL_PASSWORD: 'npm'
    volumes:
      - ./mysql:/var/lib/mysql

  npmgraf:
    image: smilebasti/npmgrafstats:latest # change to ghcr.io/smilebasti/npmgrafstats if you prefer Github Container Registry
    restart: always
    environment:
      REDIRECTION_LOGS: 'TRUE' # TRUE or FALSE or ONLY
      INTERNAL_LOGS: 'TRUE' # see Github wiki for more information
      MONITORING_LOGS: 'TRUE' # see Github wiki for more information
      INFLUX_HOST: 'influxdb:8086' # use host IP
      INFLUX_BUCKET: 'npmgrafstats'
      INFLUX_ORG: 'npmgrafstats'
      INFLUX_TOKEN: 'SECRET' # insert after first run and manual token creation
    volumes:
      - ./data/logs:/logs
      - ./geolite:/geolite
    depends_on:
      - geoipupdate
      - npm

  influxdb:
    image: influxdb:2.7-alpine
    restart: always
    environment:
      DOCKER_INFLUXDB_INIT_MODE: 'setup'
      DOCKER_INFLUXDB_INIT_USERNAME: 'SECRET'
      DOCKER_INFLUXDB_INIT_PASSWORD: 'SECRET' # atleast 8 characters
      DOCKER_INFLUXDB_INIT_ORG: 'npmgrafstats'
      DOCKER_INFLUXDB_INIT_BUCKET: 'npmgrafstats'
    volumes:
      # Mount for influxdb data directory and configuration
      - ./influxdbv2:/var/lib/influxdb2
    ports:
      - '8086:8086'

  geoipupdate:
    image: maxmindinc/geoipupdate
    restart: always
    environment:
      GEOIPUPDATE_ACCOUNT_ID: 'SECRET'
      GEOIPUPDATE_LICENSE_KEY: 'SECRET'
      GEOIPUPDATE_EDITION_IDS: 'GeoLite2-City  GeoLite2-ASN'  #GeoLite2-ASN is optional
      GEOIPUPDATE_FREQUENCY: 24
    volumes:
      - ./geolite:/usr/share/GeoIP
bengeek2 commented 10 months ago

Seems this is related to the issue in #29 I have resolved this by formatting my

INFLUX_HOST: 'influxdb:8086' # use host IP

as

INFLUX_HOST: 'http://influxdb:8086' # use host IP

I'm sure also using the ip address would have worked as the issue seems to be resolving the host name of the database.