Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

push_to_gateway: handling of spaces in group key values #1064

Open
jtougas opened this issue Oct 15, 2024 · 0 comments
Open

push_to_gateway: handling of spaces in group key values #1064

jtougas opened this issue Oct 15, 2024 · 0 comments

Comments

@jtougas
Copy link

jtougas commented Oct 15, 2024

Spaces in a group key value, come back as "+":

reproduction:
(assumes docker interface at 172.17.0.1)

  1. Start PGW: docker run -it --rm -p 9091:9091 prom/pushgateway:v1.6.2
  2. Push metrics and read back
    docker run -it -e PIP_ROOT_USER_ACTION=ignore --rm python:3.10 bash -c "
    pip --disable-pip-version-check install -q prometheus-client && \
    python3 << 'EOF'
    from prometheus_client import push_to_gateway
    from prometheus_client.metrics_core import GaugeMetricFamily
    from prometheus_client.registry import Collector, CollectorRegistry   
    m1 = GaugeMetricFamily(name='spaces_in_group_key_values_status', documentation='N/A')   
    class _CustomCollector(Collector):
        def collect(self):
            yield m1   
    registry = CollectorRegistry()
    registry.register(_CustomCollector())   
    push_to_gateway('http://172.17.0.1:9091',job='job_name',grouping_key={'label': 'value with spaces'},registry=registry)
    EOF
    "; curl -s http://172.17.0.1:9091/metrics | grep spaces
    

expected output:

push_failure_time_seconds{instance="",job="job_name",label="value with spaces"} 0
push_time_seconds{instance="",job="job_name",label="value with spaces"} 1.7290223660476923e+09

actual output:

push_failure_time_seconds{instance="",job="job_name",label="value+with+spaces"} 0
push_time_seconds{instance="",job="job_name",label="value+with+spaces"} 1.7290223660476923e+09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant