-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5922 from SigNoz/release/v0.54.x
Release/v0.54.x
- Loading branch information
Showing
266 changed files
with
11,196 additions
and
2,204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package rules | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
baserules "go.signoz.io/signoz/pkg/query-service/rules" | ||
) | ||
|
||
func PrepareTaskFunc(opts baserules.PrepareTaskOptions) (baserules.Task, error) { | ||
|
||
rules := make([]baserules.Rule, 0) | ||
var task baserules.Task | ||
|
||
ruleId := baserules.RuleIdFromTaskName(opts.TaskName) | ||
if opts.Rule.RuleType == baserules.RuleTypeThreshold { | ||
// create a threshold rule | ||
tr, err := baserules.NewThresholdRule( | ||
ruleId, | ||
opts.Rule, | ||
opts.FF, | ||
opts.Reader, | ||
baserules.WithEvalDelay(opts.ManagerOpts.EvalDelay), | ||
) | ||
|
||
if err != nil { | ||
return task, err | ||
} | ||
|
||
rules = append(rules, tr) | ||
|
||
// create ch rule task for evalution | ||
task = newTask(baserules.TaskTypeCh, opts.TaskName, time.Duration(opts.Rule.Frequency), rules, opts.ManagerOpts, opts.NotifyFunc, opts.RuleDB) | ||
|
||
} else if opts.Rule.RuleType == baserules.RuleTypeProm { | ||
|
||
// create promql rule | ||
pr, err := baserules.NewPromRule( | ||
ruleId, | ||
opts.Rule, | ||
opts.Logger, | ||
opts.Reader, | ||
opts.ManagerOpts.PqlEngine, | ||
) | ||
|
||
if err != nil { | ||
return task, err | ||
} | ||
|
||
rules = append(rules, pr) | ||
|
||
// create promql rule task for evalution | ||
task = newTask(baserules.TaskTypeProm, opts.TaskName, time.Duration(opts.Rule.Frequency), rules, opts.ManagerOpts, opts.NotifyFunc, opts.RuleDB) | ||
|
||
} else { | ||
return nil, fmt.Errorf("unsupported rule type. Supported types: %s, %s", baserules.RuleTypeProm, baserules.RuleTypeThreshold) | ||
} | ||
|
||
return task, nil | ||
} | ||
|
||
// newTask returns an appropriate group for | ||
// rule type | ||
func newTask(taskType baserules.TaskType, name string, frequency time.Duration, rules []baserules.Rule, opts *baserules.ManagerOptions, notify baserules.NotifyFunc, ruleDB baserules.RuleDB) baserules.Task { | ||
if taskType == baserules.TaskTypeCh { | ||
return baserules.NewRuleTask(name, "", frequency, rules, opts, notify, ruleDB) | ||
} | ||
return baserules.NewPromRuleTask(name, "", frequency, rules, opts, notify, ruleDB) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.