Skip to content

Commit

Permalink
Merge pull request #412 from metrico/max_prometheus_samples
Browse files Browse the repository at this point in the history
feat: configure max prometheus samples per request
  • Loading branch information
akvlad authored Dec 15, 2023
2 parents 2fe921a + 7b13146 commit dad17e0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion wasm_parts/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"wasm_parts/types"
)

var maxSamples = 5000000

type ctx struct {
onDataLoad func(c *ctx)
request []byte
Expand Down Expand Up @@ -115,7 +117,7 @@ func getEng() *promql.Engine {
if eng == nil || engC > 5 {
eng = promql.NewEngine(promql.EngineOpts{
Logger: TestLogger{},
MaxSamples: 100000,
MaxSamples: maxSamples,
Timeout: time.Second * 30,
ActiveQueryTracker: nil,
LookbackDelta: 0,
Expand All @@ -129,6 +131,11 @@ func getEng() *promql.Engine {
return eng
}

//export setMaxSamples
func setMaxSamples(maxSpl int) {
maxSamples = maxSpl
}

//export stats
func stats() {
fmt.Printf("Allocated data: %d\n", len(data))
Expand Down
1 change: 1 addition & 0 deletions wasm_parts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const getWasm = (() => {
gunzipSync(fs.readFileSync(WASM_URL)), go.importObject)
go.run(_wasm.instance)
wasm = _wasm.instance
wasm.exports.setMaxSamples(process.env.ADVANCED_PROMETHEUS_MAX_SAMPLES || 5000000)
cnt = 0
run = false
}
Expand Down
Binary file modified wasm_parts/main.wasm.gz
Binary file not shown.

0 comments on commit dad17e0

Please sign in to comment.