AnalogJ / scrutiny

Hard Drive S.M.A.R.T Monitoring, Historical Trends & Real World Failure Thresholds
MIT License
5.24k stars 166 forks source link

[BUG] INFLUXDB_HOST Variable is Ignored #386

Closed elzik closed 2 years ago

elzik commented 2 years ago

Describe the bug When trying to set the INFLUXDB_HOST environment variable, the value set is ignored and Scrutiny still tries to connect to localhost:8086. Perhaps I am using the wrong image (master-web)?

Expected behavior When the the INFLUXDB_HOST environment variable is set it should be honoured.

Docker Run This is used on Unraid, so please excuse the noise in the docker run command. However, you can see that INFLUXDB_HOST is set to http://192.168.0.12:8086

docker run -d --name='scrutiny-web' --net='bridge' --privileged=true -e TZ="Europe/London" -e HOST_OS="Unraid" -e HOST_HOSTNAME="Tower" -e HOST_CONTAINERNAME="scrutiny-web" -e 'INFLUXDB_ADMIN_TOKEN'='<redacted>' -e 'INFLUXDB_ORG_ID'='<redacted>' -e 'INFLUXDB_HOST'='http://192.168.0.12:8086' -e 'INFLUXDB_SCRUTINY_BUCKET_BASENAME'='scrutiny_metrics' -l net.unraid.docker.managed=dockerman -l net.unraid.docker.webui='http://[IP]:[PORT:8093]' -l net.unraid.docker.icon='https://raw.githubusercontent.com/selfhosters/unRAID-CA-templates/master/templates/img/scrutiny.png' -p '8093:8080/tcp' -v '/run/udev':'/run/udev':'ro' -v '/dev/disk':'/dev/disk':'ro' -v '/mnt/user/appdata/scrutiny-web/config':'/opt/scrutiny/config':'rw' 'ghcr.io/analogj/scrutiny:master-web'

Log

2022/10/29 09:28:07 No configuration file found at /opt/scrutiny/config/scrutiny.yaml. Using Defaults.
time="2022-10-29T09:28:07+01:00" level=info msg="Trying to connect to scrutiny sqlite db: /opt/scrutiny/config/scrutiny.db\n" type=web
time="2022-10-29T09:28:07+01:00" level=info msg="Successfully connected to scrutiny sqlite db: /opt/scrutiny/config/scrutiny.db\n" type=web
panic: failed to check influxdb setup status - Get "http://localhost:8086/api/v2/setup": dial tcp 127.0.0.1:8086: connect: connection refused

Docker Info

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  compose: Docker Compose (Docker Inc., v2.11.2)

Server:
 Containers: 37
  Running: 35
  Paused: 0
  Stopped: 2
 Images: 48
 Server Version: 20.10.14
 Storage Driver: btrfs
  Build Version: Btrfs v4.20.1
  Library Version: 102
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 3df54a852345ae127d1fa3092b95168e4a88e2f8
 runc version: v1.0.3-0-gf46b6ba2
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.15.46-Unraid
 Operating System: Slackware 15.0 x86_64
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 15.59GiB
 Name: Tower
 ID: VMRM:WC2D:RKXC:RR7R:BVXH:HTWT:2ADR:O5WD:CJ27:SZMN:YSIA:P7WG
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: erzulie
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Product License: Community Engine
AnalogJ commented 2 years ago

Hey @elzik Where did you see the INFLUXDB_HOST environmental variable referenced? I may have some old documentation I need to update

since the key for the influxdb host in the config file is web.influxdb.host, the associated environmental variable is SCRUTINY_WEB_INFLUXDB_HOST

If you set that variable, everything should work correctly. I'll close this issue for now, but please reopen/comment if this doesnt work for you.

elzik commented 2 years ago

@AnalogJ thanks for your reply.

Where did you see the INFLUXDB_HOST environmental variable referenced?

Here https://github.com/AnalogJ/scrutiny/blob/master/docs/TROUBLESHOOTING_INFLUXDB.md#setup-environmental-variables

the associated environmental variable is SCRUTINY_WEB_INFLUXDB_HOST

Thanks, that does get rid of the previous error I was seeing but I get another one now instead:

2022/10/30 13:34:53 No configuration file found at /opt/scrutiny/config/scrutiny.yaml. Using Defaults.
time="2022-10-30T13:34:53Z" level=info msg="Trying to connect to scrutiny sqlite db: /opt/scrutiny/config/scrutiny.db\n" type=web
time="2022-10-30T13:34:53Z" level=info msg="Successfully connected to scrutiny sqlite db: /opt/scrutiny/config/scrutiny.db\n" type=web
panic: failed to check influxdb setup status - Get "http://http/api/v2/setup": dial tcp: lookup http on 194.168.4.100:53: no such host

I find this even stranger given my docker run command. I haven't specified a host of http://http or an IP address of 194.168.4.100 anywhere. I wonder if some of my other environment variables are wrong - possibly just another docs issue? Would you like me to reopen this issue or create a new one?

martadinata666 commented 2 years ago

i assume that you are using -e 'INFLUXDB_HOST'='http://192.168.0.12:8086' then replace the env to -e 'SCRUTINY_WEB_INFLUXDB_HOST'='http://192.168.0.12:8086' ? It should be only the IP or container name like SCRUTINY_WEB_INFLUXDB_HOST=db or SCRUTINY_WEB_INFLUXDB_HOST=192.168.0.12

AnalogJ commented 2 years ago

@elzik ah. Those environmental variables are just for simplifying the scripts for configuring your influxDB manually. The webapp (running in docker) doesn't care about those environmental variables at all. only SCRUTINY_* env variables (and the config file) are considered.

As @martadinata666 mentioned, you need to remove the scheme component from your environmental variable. SCRUTINY_WEB_INFLUXDB_HOST expects an IP address or domain name (no http:///https:// prefix)