~xenrox/public-inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH ntfy-alertmanager] implement priority for resolved alerts

Details
Message ID
<20230927131646.25201-3-jackson@jacksonchen666.com>
DKIM signature
pass
Download raw message
Patch: +13 -0
---
It somehow worked first try! (after many retries on setting up the testing
infra)
From https://lists.xenrox.net/~xenrox/public-inbox/%3C41e61f25-23fc-9c1f-5ea6-14b0c0484ae3@jacksonchen666.com%3E#%3C2fj5whlejku5nmvtsl76vxetnqidrxqztpc74c2czme6veo6xx@bwsbpzjc4pnx%3E
Did not account for https://todo.xenrox.net/~xenrox/ntfy-alertmanager/9

 config.scfg           | 1 +
 config/config.go      | 8 ++++++++
 config/config_test.go | 2 ++
 main.go               | 2 ++
 4 files changed, 13 insertions(+)

diff --git a/config.scfg b/config.scfg
index e1aa5f8..22d9b89 100644
--- a/config.scfg
+++ b/config.scfg
@@ -40,6 +40,7 @@ labels {
resolved {
    tags "resolved,partying_face"
    icon "https://foo.com/resolved.png"
    priority 1
}

ntfy {
diff --git a/config/config.go b/config/config.go
index f7de2f0..3269a2e 100644
--- a/config/config.go
+++ b/config/config.go
@@ -79,6 +79,7 @@ type alertmanagerConfig struct {
type resolvedConfig struct {
	Tags []string
	Icon string
	Priority string
}

// ReadConfig reads an scfg formatted file and returns the configuration struct.
@@ -415,6 +416,13 @@ func ReadConfig(path string) (*Config, error) {
				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
diff --git a/config/config_test.go b/config/config_test.go
index 9d75a47..be0c7b6 100644
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -41,6 +41,7 @@ labels {
resolved {
    tags "resolved,partying_face"
    icon "https://foo.com/resolved.png"
    resolved 1
}

ntfy {
@@ -106,6 +107,7 @@ cache {
		Resolved: resolvedConfig{
			Tags: []string{"resolved", "partying_face"},
			Icon: "https://foo.com/resolved.png",
			Priority: "1",
		},
	}

diff --git a/main.go b/main.go
index aec085f..e2e2c2c 100644
--- a/main.go
+++ b/main.go
@@ -117,6 +117,7 @@ func (br *bridge) singleAlertNotifications(p *payload) []*notification {
		if alert.Status == "resolved" {
			tags = append(tags, br.cfg.Resolved.Tags...)
			n.icon = br.cfg.Resolved.Icon
			n.priority = br.cfg.Resolved.Priority
		}

		n.emailAddress = br.cfg.Ntfy.EmailAddress
@@ -226,6 +227,7 @@ func (br *bridge) multiAlertNotification(p *payload) *notification {
	if p.Status == "resolved" {
		tags = append(tags, br.cfg.Resolved.Tags...)
		n.icon = br.cfg.Resolved.Icon
		n.priority = br.cfg.Resolved.Priority
	}

	n.emailAddress = br.cfg.Ntfy.EmailAddress
-- 
2.42.0

[ntfy-alertmanager/patches/.build.yml] build failed

builds.xenrox.net <noreply@xenrox.net>
Details
Message ID
<CVTQ9F5IIFJH.3KJYMSM8H4ZC7@avalon.xenrox.net>
In-Reply-To
<20230927131646.25201-3-jackson@jacksonchen666.com> (view parent)
DKIM signature
missing
Download raw message
ntfy-alertmanager/patches/.build.yml: FAILED in 28s

[implement priority for resolved alerts][0] from [Jackson Chen][1]

[0]: https://lists.xenrox.net/~xenrox/public-inbox/patches/30
[1]: jackson@jacksonchen666.com

✗ #41 FAILED ntfy-alertmanager/patches/.build.yml https://builds.xenrox.net/~xenrox/job/41
Details
Message ID
<kblfx5f6ytk4y6newbwy35zcbr67wtc2pyz3spx6cp2iqrpv4c@h2of5quijxo2>
In-Reply-To
<20230927131646.25201-3-jackson@jacksonchen666.com> (view parent)
DKIM signature
missing
Download raw message
On Wed, Sep 27, 2023 at 03:15:32PM +0200, Jackson Chen wrote:
> @@ -41,6 +41,7 @@ labels {
>  resolved {
>      tags "resolved,partying_face"
>      icon "https://foo.com/resolved.png"
> +    resolved 1
>  }

You have one small typo here, should be "priority" instead of
"resolved". I fixed this in a follow-up commit.

Thanks a lot for your contribution!
Reply to thread Export thread (mbox)