Glances docker export to influxdb2 / prometheus
Describe the bug When I use docker compose to export to influxdb2 and prometheus, it prompts error in log:
Cannot connect to InfluxDB server 'None://None:None' (can only concatenate str (not "NoneType") to str)
Exception ignored in: <function InfluxDBClient.__del__ at 0xffffb86395e0>
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/influxdb_client/client/influxdb_client.py", line 265, in __del__
if self.api_client:
To Reproduce The docker compose yaml is
version: '3.5'
services:
#rPI-monitoring
rPI-monitoring:
image: nicolargo/glances:glances:3.2.0-full
restart: always
pid: host
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /home/tony/docker/GLP/config/glances.conf:/etc/glances.conf
ports:
- "61208:61208"
- "9091:9091"
environment:
- "GLANCES_OPT=--export influxdb2"
The config of export part (not full):
##############################################################################
# Exports
##############################################################################
[prometheus]
host=10.10.50.93
port=9091
#prefix=glances
labels=src:glances
[influxdb2]
host=10.10.50.93
port=9086
protocol=http
org=test
bucket=glances
token=ROnT9X4tQuwP09XzsxiO9hGRlbPAJ87DggL4VsqndBKdtZ0at4K5IYfSaQQ2gR0ETdceCu2DOoJyxBgRyo-ycQ==
Regardless of changing to prometheus, it also prompts error of
Can not start Prometheus exporter on None:None (int() argument must be a string, a bytes-like object or a number, not 'NoneType')
Could you take a look?
Try this in your compose file:
GLANCES_OPT=--export influxdb2 -C /etc/glances.conf
Thanks for your replay, I get another error like:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.9/site-packages/glances/__main__.py", line 29, in <module>
glances.main()
File "/usr/local/lib/python3.9/site-packages/glances/__init__.py", line 149, in main
start(config=core.get_config(), args= core.get_args())
File "/usr/local/lib/python3.9/site-packages/glances/__init__.py", line 109, in start
mode = GlancesMode(config=config, args=args)
File "/usr/local/lib/python3.9/site-packages/glances/standalone.py", line 103, in __init__
self.screen = GlancesCursesStandalone(config=config, args=args)
File "/usr/local/lib/python3.9/site-packages/glances/outputs/glances_curses.py", line 139, in __init__
self.screen = curses.initscr()
File "/usr/local/lib/python3.9/curses/__init__.py", line 29, in initscr
setupterm(term=_os.environ.get("TERM", "unknown"),
_curses.error: setupterm: could not find terminal
GLANCES_OPT=--export influxdb2 -C /etc/glances.conf --quiet
no luck, get
No log line matching the '' filter
and no web access any more
@a13519 you said that you want to export to InfluxDB2 and Prometheus, but in your docker compose YAML file you only have the InfluxDB option (--export influxdb2).
First of all, Try:
GLANCES_OPT=--quiet --export prometheus -C /etc/glances.conf --quiet
Then:
GLANCES_OPT=--quiet --export influxdb2,prometheus -C /etc/glances.conf --quiet
Last think, you use a old version of Glances.
Replace:
image: nicolargo/glances:glances:3.2.0-full
by:
image: nicolargo/glances:glances:3.2.7-full
Thank you nicolargo!
I tried and my yaml is:
version: '3.5'
services:
#glances
glances:
image: nicolargo/glances:3.2.7-full
restart: always
pid: host
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /home/tony/glances.conf:/etc/glances.conf
ports:
- "61208:61208"
environment:
- "GLANCES_OPT=--export influxdb2 -C /etc/glances.conf --quiet"
But the log is showing
No log line matching the '' filter
no new log comes out ... it was halt...
The /etc/glances.conf is
[influxdb2]
# Configuration for the --export influxdb2 option
# https://influxdb.com/
host=101.101.50.93
port=9086
protocol=http
org=Xyz
bucket=glances
token=ROnT9X4tQuwP09XzsxiO9hGRlbPAJ87DggL4VsqndBKdtZ0at4K5IYfSaQQ2gR0ETdceCu2DOoJyxBgRyo-cqW==
I am not sure if I can directly send data to influxdb2 or have to set telegraf, it's kind of complication to manage multiple inputs and outputs by using telegraf.
I give up to watch Glances native dashboard :-)
It's not working for me either.
For me it works. Here my docker-compose.yaml. Maybe it helps. latest=3.4.0.3
version: "3"
services:
monitoring:
container_name: glance
image: nicolargo/glances:latest-full
pid: host
network_mode: host
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "/DATA/AppData/glances/config/glances.conf:/etc/glances.conf"
environment:
- TZ=Europe/Berlin
- GLANCES_OPT=--quiet --export influxdb2 -C /etc/glances.conf --quiet
glances.conf
[influxdb2]
host=192.168.1.2
port=8086
protocol=http
org=xxx
bucket=glances
token=xxx
# Set the interval between two exports (in seconds)
# If the interval is set to 0, the Glances refresh time is used (default behavor)
interval=10
# Prefix will be added for all measurement name
# Ex: prefix=foo
# => foo.cpu
# => foo.mem
# You can also use dynamic values
#prefix=foo
# Following tags will be added for all measurements
# You can also use dynamic values.
# Note: hostname is always added as a tag
#tags=foo:bar,spam:eggs,domain:`domainname`