implement priority for resolved alerts
This commit is contained in:
parent
3baffc9bef
commit
9b4b135a39
4 changed files with 13 additions and 0 deletions
|
@ -40,6 +40,7 @@ labels {
|
||||||
resolved {
|
resolved {
|
||||||
tags "resolved,partying_face"
|
tags "resolved,partying_face"
|
||||||
icon "https://foo.com/resolved.png"
|
icon "https://foo.com/resolved.png"
|
||||||
|
priority 1
|
||||||
}
|
}
|
||||||
|
|
||||||
ntfy {
|
ntfy {
|
||||||
|
|
|
@ -79,6 +79,7 @@ type alertmanagerConfig struct {
|
||||||
type resolvedConfig struct {
|
type resolvedConfig struct {
|
||||||
Tags []string
|
Tags []string
|
||||||
Icon string
|
Icon string
|
||||||
|
Priority string
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadConfig reads an scfg formatted file and returns the configuration struct.
|
// ReadConfig reads an scfg formatted file and returns the configuration struct.
|
||||||
|
@ -415,6 +416,13 @@ func ReadConfig(path string) (*Config, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d = resolvedDir.Children.Get("priority")
|
||||||
|
if d != nil {
|
||||||
|
if err := d.ParseParams(&config.Resolved.Priority); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return config, nil
|
return config, nil
|
||||||
|
|
|
@ -41,6 +41,7 @@ labels {
|
||||||
resolved {
|
resolved {
|
||||||
tags "resolved,partying_face"
|
tags "resolved,partying_face"
|
||||||
icon "https://foo.com/resolved.png"
|
icon "https://foo.com/resolved.png"
|
||||||
|
resolved 1
|
||||||
}
|
}
|
||||||
|
|
||||||
ntfy {
|
ntfy {
|
||||||
|
@ -106,6 +107,7 @@ cache {
|
||||||
Resolved: resolvedConfig{
|
Resolved: resolvedConfig{
|
||||||
Tags: []string{"resolved", "partying_face"},
|
Tags: []string{"resolved", "partying_face"},
|
||||||
Icon: "https://foo.com/resolved.png",
|
Icon: "https://foo.com/resolved.png",
|
||||||
|
Priority: "1",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
main.go
2
main.go
|
@ -117,6 +117,7 @@ func (br *bridge) singleAlertNotifications(p *payload) []*notification {
|
||||||
if alert.Status == "resolved" {
|
if alert.Status == "resolved" {
|
||||||
tags = append(tags, br.cfg.Resolved.Tags...)
|
tags = append(tags, br.cfg.Resolved.Tags...)
|
||||||
n.icon = br.cfg.Resolved.Icon
|
n.icon = br.cfg.Resolved.Icon
|
||||||
|
n.priority = br.cfg.Resolved.Priority
|
||||||
}
|
}
|
||||||
|
|
||||||
n.emailAddress = br.cfg.Ntfy.EmailAddress
|
n.emailAddress = br.cfg.Ntfy.EmailAddress
|
||||||
|
@ -226,6 +227,7 @@ func (br *bridge) multiAlertNotification(p *payload) *notification {
|
||||||
if p.Status == "resolved" {
|
if p.Status == "resolved" {
|
||||||
tags = append(tags, br.cfg.Resolved.Tags...)
|
tags = append(tags, br.cfg.Resolved.Tags...)
|
||||||
n.icon = br.cfg.Resolved.Icon
|
n.icon = br.cfg.Resolved.Icon
|
||||||
|
n.priority = br.cfg.Resolved.Priority
|
||||||
}
|
}
|
||||||
|
|
||||||
n.emailAddress = br.cfg.Ntfy.EmailAddress
|
n.emailAddress = br.cfg.Ntfy.EmailAddress
|
||||||
|
|
Loading…
Reference in a new issue