Skip to content

Commit

Permalink
Merge pull request #98 from K-Phoen/improve-alert-decoding
Browse files Browse the repository at this point in the history
Improve alerts decoding from YAML
  • Loading branch information
K-Phoen authored Mar 27, 2021
2 parents 524d163 + f53de6a commit e5dfec3
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions decoder/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,12 @@ type GraphAlert struct {
EvaluateEvery string `yaml:"evaluate_every"`
For string
If []AlertCondition
Notify string
Notifications []string
Message string
OnNoData string `yaml:"on_no_data"`
OnExecutionError string `yaml:"on_execution_error"`
Tags map[string]string
Notify string `yaml:",omitempty"`
Notifications []string `yaml:",omitempty,flow"`
Message string `yaml:",omitempty"`
OnNoData string `yaml:"on_no_data"`
OnExecutionError string `yaml:"on_execution_error"`
Tags map[string]string `yaml:",omitempty"`
}

func (a GraphAlert) toOptions() ([]alert.Option, error) {
Expand Down Expand Up @@ -289,11 +289,11 @@ func (a GraphAlert) toOptions() ([]alert.Option, error) {
}

type AlertThreshold struct {
HasNoValue bool `yaml:"has_no_value"`
Above *float64
Below *float64
OutsideRange [2]float64 `yaml:"outside_range"`
WithinRange [2]float64 `yaml:"within_range"`
HasNoValue bool `yaml:"has_no_value,omitempty"`
Above *float64 `yaml:",omitempty"`
Below *float64 `yaml:",omitempty"`
OutsideRange [2]float64 `yaml:"outside_range,omitempty,flow"`
WithinRange [2]float64 `yaml:"within_range,omitempty,flow"`
}

func (threshold AlertThreshold) toOption() (alert.ConditionOption, error) {
Expand Down Expand Up @@ -354,7 +354,7 @@ func (v AlertValue) toOption() (alert.ConditionOption, error) {

type AlertCondition struct {
Operand string
Value AlertValue
Value AlertValue `yaml:",flow"`
Threshold AlertThreshold
}

Expand Down

0 comments on commit e5dfec3

Please sign in to comment.