common icon indicating copy to clipboard operation
common copied to clipboard

expfmt: Consider allowing empty MetricFamilies

Open beorn7 opened this issue 9 years ago • 4 comments

Currently, a MetricFamily with no Metrics is invalid (i.e. it will never be created by encoders, and it will yield an error upon decoding).

As it turns out, client libraries that are ignorant of the protobuf exchange format are making use of empty metric families as represented in the text format, i.e.

# HELP blah some help
# TYPE blah gauge
# HELP blub another metric
# ...

This has never caused any trouble because the only entry point of the text format into the Prometheus universe is the text-format parser, which kicks out those metric families here.

@brian-brazil thinks empty metric families is something we should allow in general. That would require to change all code encoding and decoding protobuf, including the text-format parser. (Ideally, all that code is only in expfmt but there might be legacy.) Also, consumers of decoded protobuf have to be checked to deal gracefully with empty MetricFamilies, as they were so far guaranteed to not appear.

beorn7 avatar Aug 02 '16 11:08 beorn7

Alternative is to keep disallowing empty MetricFamilies. But we should clearly document that requirement. metrics.proto does not (and cannot) specify the requirement.

beorn7 avatar Aug 02 '16 11:08 beorn7

👍 for officially allowing empty MetricFamilies. I find it very useful to see defined but not observed metrics.

grobie avatar Aug 03 '16 00:08 grobie

After ingestion, they will still not be visible (for as long as the Prometheus server doesn't handle meta data). But we can allow it in the exposition formats (and then, one day, the server might finally deal with meta data).

beorn7 avatar Aug 03 '16 07:08 beorn7

Filed https://github.com/prometheus/docs/issues/544 for the decision and documentation. Once that is settled, we change the implementation as required to resolve this issue.

beorn7 avatar Sep 09 '16 14:09 beorn7