-
Notifications
You must be signed in to change notification settings - Fork 35
PROM-0097: PromQL Metadata querying / promotion. #97
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
Closed
roidelapluie
wants to merge
3
commits into
prometheus:main
from
roidelapluie:roidelapluie/promql-metadata
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"}` | ||
|
|
||
| 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. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
resourcenamespace? What else?There was a problem hiding this comment.
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...
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.