prometheus-pve-exporter icon indicating copy to clipboard operation
prometheus-pve-exporter copied to clipboard

[Question] What does module=default do?

Open MaoMaoCake opened this issue 2 years ago • 3 comments

hi Ive setup the exporter with

default:
    user: prometheus@pve
    token_name: "prometheus"
    token_value: "token"
    verify_ssl: false

and the promethus job with

- job_name: 'pve'
    static_configs:
      - targets: 
        - 1.2.3.4 # Proxmox VE node.
    metrics_path: /pve
    params:
      module: [default]
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 127.0.0.1:9221

when I curl with module in the url http://127.0.0.1:9221/pve?module=default&target=1.2.3.4 it fails with 500 when i curl without module http://127.0.0.1:9221/pve?target=1.2.3.4 I get the metrics

MaoMaoCake avatar Mar 19 '22 14:03 MaoMaoCake

Thank you for taking the time to file this issue. The module= parameter is supposed to select one section from the config file (same mechanism as in blackbox_exporter and snmp_exporter btw.)

when I curl with module in the url http://127.0.0.1:9221/pve?module=default&target=1.2.3.4 it fails with 500 when i curl without module http://127.0.0.1:9221/pve?target=1.2.3.4 I get the metrics

This is unexpected. Could you please post the stack trace of prometheus-pve-exporter which is produced in the logs when the error occures? You find the logs either directly on the console (if you start pve exporter manually) or using journalctl -u prometheus-pve-exporter.service if you did setup a systemd unit.

znerol avatar Mar 19 '22 15:03 znerol

Exception thrown while rendering view
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/usr/lib/python3.9/site-packages/urllib3/util/connection.py", line 96, in create_connection
    raise err
  File "/usr/lib/python3.9/site-packages/urllib3/util/connection.py", line 86, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3.9/site-packages/urllib3/connectionpool.py", line 382, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python3.9/site-packages/urllib3/connectionpool.py", line 1010, in _validate_conn
    conn.connect()
  File "/usr/lib/python3.9/site-packages/urllib3/connection.py", line 358, in connect
    conn = self._new_conn()
  File "/usr/lib/python3.9/site-packages/urllib3/connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f5628eaba30>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/lib/python3.9/site-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3.9/site-packages/urllib3/util/retry.py", line 574, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='localhost', port=8006): Max retries exceeded with url: /api2/json/cluster/status (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f5628eaba30>: Failed to establish a new connection: [Errno 111] Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/pve_exporter/http.py", line 96, in view
    return view_registry[endpoint](**params)
  File "/usr/lib/python3.9/site-packages/pve_exporter/http.py", line 38, in on_pve
    output = collect_pve(self._config[module], target, self._collectors)
  File "/usr/lib/python3.9/site-packages/pve_exporter/collector.py", line 332, in collect_pve
    return generate_latest(registry)
  File "/usr/lib/python3.9/site-packages/prometheus_client/exposition.py", line 176, in generate_latest
    for metric in registry.collect():
  File "/usr/lib/python3.9/site-packages/prometheus_client/registry.py", line 83, in collect
    for metric in collector.collect():
  File "/usr/lib/python3.9/site-packages/pve_exporter/collector.py", line 45, in collect
    for entry in self._pve.cluster.status.get():
  File "/usr/lib/python3.9/site-packages/proxmoxer/core.py", line 123, in get
    return self(args)._request("GET", params=params)
  File "/usr/lib/python3.9/site-packages/proxmoxer/core.py", line 100, in _request
    resp = self._store["session"].request(method, url, data=data or None, params=params)
  File "/usr/lib/python3.9/site-packages/proxmoxer/backends/https.py", line 213, in request
    return super(ProxmoxHttpSession, self).request(method, url, params, data, headers, cookies, files, auth,
  File "/usr/lib/python3.9/site-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3.9/site-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3.9/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='localhost', port=8006): Max retries exceeded with url: /api2/json/cluster/status (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f5628eaba30>: Failed to establish a new connection: [Errno 111] Connection refused'))
172.17.0.1 - - [20/Mar/2022 04:19:26] "GET /pve?module=default HTTP/1.1" 500 -

Looks like there is some issue With the authentication. Im using PVE 7.1-10 with the token given PVEAuditor permission to /

Currently its working fine with the "module" removed thus the yml is

- job_name: 'pve'
    static_configs:
      - targets:
        - 1.2.3.4  # Proxmox VE node.
    metrics_path: /pve
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 127.0.0.1:9221

MaoMaoCake avatar Mar 20 '22 04:03 MaoMaoCake

The relevant line is near the top:

ConnectionRefusedError: [Errno 111] Connection refused

This indicates, that the there is no proxmox api listening on the target host. Also note the very last line:

172.17.0.1 - - [20/Mar/2022 04:19:26] "GET /pve?module=default HTTP/1.1" 500 -

Note that the target parameter is missing. Since there is no target specified, prometheus-proxmox-exporter tries to connect to localhost.

znerol avatar Mar 20 '22 10:03 znerol