prometheus / prometheus/prometheus

Allow for query execution within range vector

Open
#8,855 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

component/promql not-as-easy-as-it-looks
Dominant language
Go
Stars
66.1k
Forks
10.8k
Avg merge
2d 1h
Merged PRs (30d)
131

Description

Proposal

Use case. Why is this important?
When trying to query the amount of bandwidth that has gone over an interface over the past 30 days, one can simply run this query (quick draft, only calculating In, skipping Out):
increase(ifHCInOctets{instance="<ip>",ifDescr="<ifdescr>}[30d])

This works fine, however, when we want to alert when the amount of bandwidth has gone over X TB in the current month (1st day of the month 00:00:00 until now), one cannot use 30d but needs to enter the amount seconds since the start of the month.

For some reason, I cannot find any documentation nor do I succeed in replacing the range vector [30d] with a query that calculates the amount of seconds since this point in time. It seems that there is no room for executing a query within this range vector and only static values are allowed (Xs,Xm,Xh,Xd,...)

Using a recording rule that calculates the seconds_this_month, one would be in the possibility of using the vector [seconds_this_month].
When we implement this in the demo query, it would look like this:
increase(ifHCInOctets{instance="<ip>",ifDescr="<ifdescr>}[seconds_this_month])

Is there any chance this might be added in a future version or, if it really does exist, that this can be added to the documentation?
If there is no need for this method because there is another way of achieving this, please do let me know.

Thanks in advance!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files or tests. Start by reviewing PromQL range-vector syntax and the existing increase() use case described here, then determine how an expression could be evaluated in place of the static duration. Done would require an agreed syntax and semantics, implementation, tests, and documentation for querying from the start of the current month.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
observability-sre
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.