Skip to content
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

#138 : Added absent_over_time support function #261

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions engine/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,16 @@ func TestQueriesAgainstOldEngine(t *testing.T) {
http_requests_total{pod="nginx-2"} -5+2x18`,
query: "abs(http_requests_total)",
},
{
name: "absent_over_time",
load: `load 30s
http_requests_total{pod="nginx-1"} 1+1x15
http_requests_total{pod="nginx-2"} 1+2x18
http_requests_total{pod="nginx-2"} 1+2x18
http_requests_total{pod="nginx-2"} 1+2x18
http_requests_total{pod="nginx-2"} 1+2x18`,
query: "absent_over_time(http_requests_total[30s])",
},
{
name: "ceil",
load: `load 30s
Expand Down
7 changes: 7 additions & 0 deletions execution/function/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ var Funcs = map[string]FunctionCall{
"deg": simpleFunc(func(v float64) float64 {
return v * 180 / math.Pi
}),
"absent_over_time": simpleFunc(func(v float64) float64 {
Copy link
Contributor

Choose a reason for hiding this comment

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

i dont think the implementation works; this operator actually needs to be a source of new samples ( if there are no samples in the window ). only implemented as simpleFunc it can only transform preexisting samples. Can you take a look at my previous PR for the absent function? I had to introduce a new operator that actually produces new samples in that case. It might be possible to adapt this for the "_over_time" variant too, but it might be a bit harder because functions are pushed down into the matrix selector

Copy link
Author

Choose a reason for hiding this comment

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

Okey sure!

if v > 0 {
return 0
} else {
return 1
}
}),
"sgn": simpleFunc(func(v float64) float64 {
var sign float64
if v > 0 {
Expand Down