Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Skip ConstLabels and namespace prefixes for "up" & internal metrics #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

odeke-em
Copy link

@odeke-em odeke-em commented Apr 13, 2021

Internal metrics consumed by Prometheus such as "up" indicate
a status of the target, as either "up" with 1.0 or "down" with 0.0.
This change ensures that no ConstLabels, nor namespace prefixes will
be added to such metrics. This ensures that when one exports with
the special name "up", that it passes through up to the Prometheus
exporter, so:

# HELP up up
# TYPE up counter
up{instance="localhost:9999"} 1

instead of:

# HELP tests_up tests/up
# TYPE tests_up counter
tests_up{instance="localhost:9999",service="spanner"} 1

A further assertion can be added to ensure that "up" is a gauge,
but I am not sure that it might be necessary, just in case some
user wants to expose it as a counter.

Updates open-telemetry/wg-prometheus#8

Internal metrics consumed by Prometheus such as "up" indicate
a status of the target, as either "up" with 1.0 or "down" with 0.0.
This change ensures that no ConstLabels, nor namespace prefixes will
be added to such metrics. This ensures that when one exports with
the special name "up", that it passes through up to the Prometheus
exporter, so:

    # HELP up up
    # TYPE up counter
    up{instance="localhost:9999"} 1

instead of:

    # HELP tests_up tests/up
    # TYPE tests_up counter
    tests_up{instance="localhost:9999",service="spanner"} 1

A further assertion can be added to ensure that "up" is a gauge,
but I am not sure that it might be necessary, just in case some
user wants to expose it as a counter.

Updates open-telemetry/wg-prometheus#8
@odeke-em odeke-em force-pushed the do-not-add-constLabels-nor-change-internal-metrics branch from d000bdd to 3f51e17 Compare April 13, 2021 02:17
@odeke-em
Copy link
Author

Kindly cc-ing @Aneurysm9 @bogdandrutu @rakyll @alolita, what do y'all think? I am still thinking about how Prometheus itself will treat an incoming "up", and for that I am going to debug more after dinner and test it out with Prometheus on my Macbook instead of office Linux machine without it, but for now, your thoughts kindly.

odeke-em added a commit to orijtech/opentelemetry-collector that referenced this pull request Apr 13, 2021
Make a receiver specific view that'll be registered
and used to record the "up" status either "0.0" or "1.0"
when an instance can't be scraped from or can be, respectively.

This ensures that the collector can act as a passthrough
for statuses and it currently outputs:

    # HELP up Whether the endpoint is alive or not
    # TYPE up gauge
    up{instance="0.0.0.0:8888"} 1
    up{instance="localhost:9999"} 0

Fixes open-telemetry/wg-prometheus#8
Requires census-ecosystem/opencensus-go-exporter-prometheus#24
odeke-em added a commit to orijtech/opentelemetry-collector that referenced this pull request Apr 13, 2021
Make a receiver specific view that'll be registered
and used to record the "up" status either "0.0" or "1.0"
when an instance can't be scraped from or can be, respectively.

This ensures that the collector can act as a passthrough
for statuses and it currently outputs:

    # HELP up Whether the endpoint is alive or not
    # TYPE up gauge
    up{instance="0.0.0.0:8888"} 1
    up{instance="localhost:9999"} 0

I did not take the approach of plainly sending up suffixed metric names.
to recommend instead using relabelling inside the exporter itself like:

    - source_labels: [__name__]
        regex: "(.+)_up"
        target_label: "__name__"
        replacement: "up"

because:
* it'd apply ConstLabels on every *_up metric, only want "instance=$INSTANCE"
* other exporters wouldn't be able to use the "up" metric as is if we
inject rewrites

Regardless of if we used a label rewrite, the end result would be the
following:

    up{instance="localhost:8888",job="otlc"}
    up{exported_instance="0.0.0.0:9999",instance="localhost:8888",job="otlc"}
    up{exported_instance="0.0.0.0:1234",instance="localhost:8888",job="otlc"}

which this change accomplishes without having to inject any label
rewrites, but just by the new imports and upgrade of the prometheus
exporter.

Fixes open-telemetry/wg-prometheus#8
Requires census-ecosystem/opencensus-go-exporter-prometheus#24
odeke-em added a commit to orijtech/opentelemetry-collector that referenced this pull request Apr 13, 2021
Make a receiver specific view that'll be registered
and used to record the "up" status either "0.0" or "1.0"
when an instance can't be scraped from or can be, respectively.

This ensures that the collector can act as a passthrough
for statuses and it currently outputs:

    # HELP up Whether the endpoint is alive or not
    # TYPE up gauge
    up{instance="0.0.0.0:8888"} 1
    up{instance="localhost:9999"} 0

I did not take the approach of plainly sending up suffixed metric names.
to recommend instead using relabelling inside the exporter itself like:

    - source_labels: [__name__]
        regex: "(.+)_up"
        target_label: "__name__"
        replacement: "up"

because:
* it'd apply ConstLabels on every *_up metric, only want "instance=$INSTANCE"
* other exporters wouldn't be able to use the "up" metric as is if we
inject rewrites

Regardless of if we used a label rewrite, the end result would be the
following:

    up{instance="localhost:8888",job="otlc"}
    up{exported_instance="0.0.0.0:9999",instance="localhost:8888",job="otlc"}
    up{exported_instance="0.0.0.0:1234",instance="localhost:8888",job="otlc"}

which this change accomplishes without having to inject any label
rewrites, but just by the new imports and upgrade of the prometheus
exporter.

Fixes open-telemetry/wg-prometheus#8
Requires census-ecosystem/opencensus-go-exporter-prometheus#24
odeke-em added a commit to orijtech/opentelemetry-collector that referenced this pull request Apr 13, 2021
Make a receiver specific view that'll be registered
and used to record the "up" status either "0.0" or "1.0"
when an instance can't be scraped from or can be, respectively.

This ensures that the collector can act as a passthrough
for statuses and it currently outputs:

    # HELP up Whether the endpoint is alive or not
    # TYPE up gauge
    up{instance="0.0.0.0:8888"} 1
    up{instance="localhost:9999"} 0

I did not take the approach of plainly sending up suffixed metric names.
to recommend instead using relabelling inside the exporter itself like:

    - source_labels: [__name__]
        regex: "(.+)_up"
        target_label: "__name__"
        replacement: "up"

because:
* it'd apply ConstLabels on every *_up metric, only want "instance=$INSTANCE"
* other exporters wouldn't be able to use the "up" metric as is if we
inject rewrites

Regardless of if we used a label rewrite, the end result would be the
following:

    up{instance="localhost:8888",job="otlc"}
    up{exported_instance="0.0.0.0:9999",instance="localhost:8888",job="otlc"}
    up{exported_instance="0.0.0.0:1234",instance="localhost:8888",job="otlc"}

which this change accomplishes without having to inject any label
rewrites, but just by the new imports and upgrade of the prometheus
exporter.

Fixes open-telemetry/wg-prometheus#8
Requires census-ecosystem/opencensus-go-exporter-prometheus#24
@odeke-em
Copy link
Author

We now have
Screen Shot 2021-04-13 at 12 14 17 AM

odeke-em added a commit to orijtech/opentelemetry-collector that referenced this pull request Apr 16, 2021
Make a receiver specific view that'll be registered
and used to record the "up" status either "0.0" or "1.0"
when an instance can't be scraped from or can be, respectively.

This ensures that the collector can act as a passthrough
for statuses and it currently outputs:

    # HELP up Whether the endpoint is alive or not
    # TYPE up gauge
    up{instance="0.0.0.0:8888"} 1
    up{instance="localhost:9999"} 0

I did not take the approach of plainly sending up suffixed metric names.
to recommend instead using relabelling inside the exporter itself like:

    - source_labels: [__name__]
        regex: "(.+)_up"
        target_label: "__name__"
        replacement: "up"

because:
* it'd apply ConstLabels on every *_up metric, only want "instance=$INSTANCE"
* other exporters wouldn't be able to use the "up" metric as is if we
inject rewrites

Regardless of if we used a label rewrite, the end result would be the
following:

    up{instance="localhost:8888",job="otlc"}
    up{exported_instance="0.0.0.0:9999",instance="localhost:8888",job="otlc"}
    up{exported_instance="0.0.0.0:1234",instance="localhost:8888",job="otlc"}

which this change accomplishes without having to inject any label
rewrites, but just by the new imports and upgrade of the prometheus
exporter.

Fixes open-telemetry/wg-prometheus#8
Requires census-ecosystem/opencensus-go-exporter-prometheus#24
@dashpole
Copy link
Contributor

Can you help me understand why we want to drop const_labels for this exporter? For prometheus federation, which seems to be the closest existing corollary to this exporter, the external_labels (which seems to be the same as const_labels in our exporter), exist specifically to be attached to exported metrics to ensure they are unique when the same metric could be scraped from multiple collectors.

I'm not a huge fan of the namespace option for the exporter. It seems to serve the same function as const_labels, which is to make metric streams unique when scraping from multiple collectors, but to do it in a way that is likely to be more confusing IMO. But since it serves the same purpose, we should treat it the same and also keep it here.

odeke-em added a commit to orijtech/opentelemetry-collector that referenced this pull request Apr 26, 2021
Make a receiver specific view that'll be registered
and used to record the "up" status either "0.0" or "1.0"
when an instance can't be scraped from or can be, respectively.

This ensures that the collector can act as a passthrough
for statuses and it currently outputs:

    # HELP up Whether the endpoint is alive or not
    # TYPE up gauge
    up{instance="0.0.0.0:8888"} 1
    up{instance="localhost:9999"} 0

I did not take the approach of plainly sending up suffixed metric names.
to recommend instead using relabelling inside the exporter itself like:

    - source_labels: [__name__]
        regex: "(.+)_up"
        target_label: "__name__"
        replacement: "up"

because:
* it'd apply ConstLabels on every *_up metric, only want "instance=$INSTANCE"
* other exporters wouldn't be able to use the "up" metric as is if we
inject rewrites

Regardless of if we used a label rewrite, the end result would be the
following:

    up{instance="localhost:8888",job="otlc"}
    up{exported_instance="0.0.0.0:9999",instance="localhost:8888",job="otlc"}
    up{exported_instance="0.0.0.0:1234",instance="localhost:8888",job="otlc"}

which this change accomplishes without having to inject any label
rewrites, but just by the new imports and upgrade of the prometheus
exporter.

Fixes open-telemetry/wg-prometheus#8
Requires census-ecosystem/opencensus-go-exporter-prometheus#24
odeke-em added a commit to orijtech/opentelemetry-collector that referenced this pull request May 2, 2021
Make a receiver specific view that'll be registered
and used to record the "up" status either "0.0" or "1.0"
when an instance can't be scraped from or can be, respectively.

This ensures that the collector can act as a passthrough
for statuses and it currently outputs:

    # HELP up Whether the endpoint is alive or not
    # TYPE up gauge
    up{instance="0.0.0.0:8888"} 1
    up{instance="localhost:9999"} 0

I did not take the approach of plainly sending up suffixed metric names.
to recommend instead using relabelling inside the exporter itself like:

    - source_labels: [__name__]
        regex: "(.+)_up"
        target_label: "__name__"
        replacement: "up"

because:
* it'd apply ConstLabels on every *_up metric, only want "instance=$INSTANCE"
* other exporters wouldn't be able to use the "up" metric as is if we
inject rewrites

Regardless of if we used a label rewrite, the end result would be the
following:

    up{instance="localhost:8888",job="otlc"}
    up{exported_instance="0.0.0.0:9999",instance="localhost:8888",job="otlc"}
    up{exported_instance="0.0.0.0:1234",instance="localhost:8888",job="otlc"}

which this change accomplishes without having to inject any label
rewrites, but just by the new imports and upgrade of the prometheus
exporter.

Fixes open-telemetry/wg-prometheus#8
Requires census-ecosystem/opencensus-go-exporter-prometheus#24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants