Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions proposals/0097-promoting-promql-metadata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
## Promoting Metric Metadata in PromQL

* **Owners:**
* Julien Pivotto <@roidelapluie>

* **Implementation Status:** `Not implemented`

* **Related Issues and PRs:**
* https://github.com/prometheus/proposals/pull/78
* https://github.com/prometheus/proposals/pull/94

* **Other docs or links:**
* `<Links…>`

> TL;DR: Native metadata are coming to Prometheus, but we need a way to query them that does not conflict with allowing unquoted dots and Unicode letters in metric and label names.
>
> This design document proposes mechanisms and keywords to query and promote such metadata.

## Why

We know that Prometheus will need a metadata database to attach resource or target metadata to metrics. The acquisition, storage, and definition of metadata are outside the scope of this proposal.

However, these metadata will need to be returned to users and used in PromQL queries. This proposal defines the syntax and mechanisms that can be used in the future.

### Pitfalls of the current solution

Currently, we have no way to store or query metadata. Prometheus drops many "target labels" during target relabeling. If stored, these labels could be queried by users to gain more insight into their data.

## Goals

Goals and use cases for the solution as proposed in [How](#how):

* Provide a non-conflicting way to query native metadata.
* Provide syntax that feels familiar to PromQL users.
* Be agnostic to the kind (namespace?) of metadata.

### Audience

PromQL users and OTLP users who push data to Prometheus.

## Non-Goals

* Native metadata retrieval, reception, and storage.

## How

Querying:

1. Native metadata are ignored by default.

Existing PromQL queries do not return native metadata unless they are explicitly promoted. Vector matching does not use metadata by default.

2. Native metadata have a namespace.

Native metadata have namespaces or scopes, such as resource or target.

3. Native metadata are referenced as `namespace[cpu.foo]` or `namespace["super+name"]` (quoting follows the rules for label and metric names).

4. Native metadata can optionally be promoted to labels with the `as` keyword.

`foo{resource[power.status] as power_status}` `foo{namespace["super+name"] as "supername"}`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what are the keywords allowed here? resource namespace? What else?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This proposal is agnostic of the keywords. The keywords are actual namespaces of metadata and should be defined in a broader metadata design doc like the ones that exist. I can think of resource for OTLP: resource, k8s, host, service...

@bwplotka bwplotka Sep 23, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I am missing an exact definition of "namespace" or "scope", especially how it would be reflected in Prometheus world. Also if we expect UTF-8 in those (:

Maybe it's out of scope, but then how we could understand limitations of <prefix>[<suffix>] syntax?

If we mean here OTel entity namespaces and let's take process.executable)

Then should I go for

cpu_info{process["executable.name"]="docker" as exec}
or
cpu_info{"process.executable"[name]="docker" as exec}

..and if this "namespacing" is required, why not cpu_info{["process.executable.name"]="docker" as exec}

Then can we guarentee some namespace is always there for metadata?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we can have better and will do a second proposal later.


In the first example, the `power.status` metadata in the `resource` namespace become the `power_status` label, which is used in vector matching, query outputs, etc.

5. Native metadata can be used to filter without promotion.

`foo{resource[power.status]="down"}`

`foo{resource[power.status]=~"down|stopped"}`

6. Native metadata can be used to filter with promotion.

`foo{resource[power.status]="down" as power.status}`

`foo{resource[power.status]=~"down|stopped" as power.status}`

7. Native metadata can be promoted with `group_right`, `group_left`, and other keywords that take labels.

`foo and on (resource[power.status] as power.status) bar`

In this case, the metadata will be promoted on the left, on the right, or on both sides.

Query results:

Metadata are only visible in query outputs once promoted, in which case they appear as labels.

Advantages: The query output format does not change, so tools that graph or display the results work without modification (provided they do not validate or need to understand the input syntax).

## Alternatives

The main alternative is to use dots, but that contradicts https://github.com/prometheus/proposals/pull/94.

## Action Plan

This task is depending on native metadata acquisition and storage.
Loading