Skip to content

Proposal: PromQL arithmetic with default value, or outer join #13625

@bboreham

Description

@bboreham

Proposal

If I have data in foo and data in bar, then foo + bar will add them up.
If there are some gaps in foo or bar then foo + bar will have gaps in all of those places.
I would like to add them and have PromQL treat a missing value as zero, so I don't get gaps.

I am aware of some work-arounds available today:

  • I can write sum ( {__name__=~"foo|bar"} ), but that is ugly, and runs into "duplicate labels" problems if I call a function like rate.
  • Probably I can use or vector(0), with some trickery to get the right labels.

I want to be able to do it without an ugly workaround and without trickery.

What would the syntax look like? Maybe foo + default(0) bar ?
One possibility, if I only want addition, would to have sum take multiple selectors as inputs, i.e. sum(foo, bar).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions