Skip to content

Double quotes in labels shouldn't result in malformed data #14

@quinox

Description

@quinox

Test script:

#!/usr/bin/env python2
from BaseHTTPServer import HTTPServer
from prometheus_client import Counter
from prometheus_client import MetricsHandler

counter = Counter('cronjobs_total', 'All cronjobs', ['server', 'username', 'command'])
counter.labels('someserver', 'someaccount', 'cd "/foo/bar/"').inc()

server_address = ('', 7700)
httpd = HTTPServer(server_address, MetricsHandler)
httpd.serve_forever()

When you add this as a Prometheus endpoint you will get a scraping error:

text format parsing error in line 3: unexpected end of label value %!q(*string=0xc20a6bc040)

The generated output when visiting port 7700 shows unespaced double quotes:

# HELP cronjobs_total All cronjobs
# TYPE cronjobs_total counter
cronjobs_total{username="someaccount",command="cd "/foo/bar/"",server="someserver"} 1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions