prometheus-pve / prometheus-pve-exporter

Exposes information gathered from Proxmox VE cluster for use by the Prometheus monitoring system
Apache License 2.0
796 stars 94 forks source link

constantly warning about unverified HTTPS request #129

Closed nvollmar closed 1 year ago

nvollmar commented 1 year ago

Tried with verify_ssl: false but still get this warning on every scrape

 /usr/lib/python3/dist-packages/urllib3/connectionpool.py:1015: InsecureRequestWarning: Unverified HTTPS request is being made to host 'localhost'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
znerol commented 1 year ago

This warning is originating from python urllib3. Not something which can be fixed in prometheus-pve-exporter.

nvollmar commented 1 year ago

This would fix it though:

import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
nvollmar commented 1 year ago

@znerol I can't find where verify_ssl setting would have an effect: https://github.com/prometheus-pve/prometheus-pve-exporter/search?q=verify_ssl

znerol commented 1 year ago

verify_ssl is passed directly to proxmoxer/proxmoxer.

znerol commented 1 year ago

@nvollmar: Did you see proxmoxer/proxmoxer#128 ? Does upgrading proxmoxer to 2.0.1 fix the problem you are having?

nvollmar commented 1 year ago

Thanks for the hint, I'll look into that.

nvollmar commented 1 year ago

Tested proxmoxer 2.0.1, still the same issue. Downgraded to 1.3.1 (latest version before 2.0.0) which solved it.

aauren commented 1 year ago

This is a super crude way to fix this, but until proxmoxer updates their utilization of the requests library, it seems like this is the only way to do it without editing the library code:

I changed the service to set the environment variable: PYTHONWARNINGS=ignore

The service declaration of my systemd service now looks like:

$ systemctl cat prometheus-pve-exporter.service
# /etc/systemd/system/prometheus-pve-exporter.service
[Unit]
Description=Prometheus Proxmox VE Exporter
Documentation=https://github.com/prometheus-pve/prometheus-pve-exporter

[Service]
Environment=PYTHONWARNINGS=ignore
Restart=always
User=pve-exporter
ExecStart=/opt/prometheus-pve-exporter/bin/pve_exporter /etc/prometheus/pve.yml

[Install]
WantedBy=multi-user.target

After that, reload the systemd daemon: systemctl daemon-reload and restart the application: systemctl restart prometheus-pve-exporter.service

Note, that this will also squash other legitimate python warnings, but most people probably aren't looking at the service output anyway.

luisgabrielroldan commented 5 months ago

Just to complement the last answer, you can also do:

PYTHONWARNINGS=ignore:Unverified HTTPS request

https://docs.python.org/3/library/warnings.html