Skip to content

Native Metadata support in PromQL - #99

Open
roidelapluie wants to merge 2 commits into
prometheus:mainfrom
roidelapluie:roidelapluie/native-metadata-2
Open

roidelapluie wants to merge 2 commits into
prometheus:mainfrom
roidelapluie:roidelapluie/native-metadata-2

Conversation

@roidelapluie

Copy link
Copy Markdown
Member

No description provided.

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>

Query results:

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe I missed something: is there a way to promote metadata without applying a matcher? (eg. let's say I want to get foo with the value of resource.power.status but don't want to filter based on resource.power.status)

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.

We could have foo{~resource.cpu.name} or foo{~resource.cpu.name as cpu_name}, WDYT?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Makes sense to me. If we support aliases in the selector like that, I don't think we need to support them elsewhere (eg. in binary operations like foo and on (~resource.power.status as power_status) bar).


6. Native metadata can be aliased with the `as` keyword.

`foo and on (~resource.power.status as power_status) bar`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

How would this look for aggregations? sum by (~resource.power.status as power_status) (foo) perhaps?

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.

Yes


`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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'm wondering about some edge cases:

How would this work if someone wanted to promote metadata from just the left or right side, but not both? eg. I want to promote resource.power.status from the left side as power_status, but not from the right.

Related: would it be possible to promote different metadata to the same label from different sides (eg. resource.power.status from left and resource.foo.bar from right, with both being aliased to power_status)?

What happens if the alias exists as a label on the series? (I'm assuming the aliased metadata takes precedence?)

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.

WDYT of foo{~resource.power.status as power_status} and on (power_status) bar?

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.

For aliases, I we can chose: warn or error. I think we could probably error to start with.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WDYT of foo{~resource.power.status as power_status} and on (power_status) bar?

I prefer this - if aliases are only possible in selectors, then we don't need to think about how to make them work in a bunch of other places like binops and aggregations.

Would we also support aliasing ordinary labels (eg. foo{env as region})? This would be nice from a consistency standpoint, and remove the need to use label_replace or label_join in some circumstances.

For aliases, I we can chose: warn or error. I think we could probably error to start with.

Sounds good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants