Skip to content

[doc] The demo of 'tls_auth_handler' is not work #874

@ethanschen

Description

@ethanschen

ENV

tls_auth_handler_demo.py --> code form README.md

from prometheus_client import CollectorRegistry, Gauge, push_to_gateway
from prometheus_client.exposition import tls_handler
def my_auth_handler(url, method, timeout, headers, data):
    certfile = 'client-crt.pem'
    keyfile = 'client-key.pem'
    return tls_auth_handler(url, method, timeout, headers, data, certfile, keyfile)
registry = CollectorRegistry()
g = Gauge('job_last_success_unixtime', 'Last time a batch job successfully finished', registry=registry)
g.set_to_current_time()
push_to_gateway('localhost:9091', job='batchA', registry=registry, handler=my_auth_handler)
python tls_auth_handle_demo.py

LOG

Traceback (most recent call last):
  File "/private/tmp/tls_auth_handler_demo.py", line 2, in <module>
    from prometheus_client.exposition import tls_handler
ImportError: cannot import name 'tls_handler' from 'prometheus_client.exposition' (/private/tmp/venv/lib/python3.9/site-packages/prometheus_client/exposition.py)

SHOULD BE

from prometheus_client.exposition import tls_handler

update to

from prometheus_client.exposition import tls_auth_handler

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions