Code Monkey home page Code Monkey logo

Comments (5)

ki4rbc avatar ki4rbc commented on June 6, 2024 1

Hello again @benjojo,
So I got this mod of main.go to work but I'm not entirely happy and it's not something I think I would suggest a fork for.

--- original/alertmanager-discord/main.go       2020-08-31 18:35:49.698522600 -0400
+++ alertmanager-discord/main.go        2020-08-31 22:28:46.702549100 -0400
@@ -121,7 +121,7 @@
                                }

                                RichEmbed.Fields = append(RichEmbed.Fields, discordEmbedField{
-                                       Name:  fmt.Sprintf("[%s]: %s on %s", strings.ToUpper(status), alert.Labels["alertname"], realname),
+                                       Name:  fmt.Sprintf("[%s]: %s on %s - %s", strings.ToUpper(status), alert.Labels["alertname"], realname, alert.Labels["locID"]),
                                        Value: alert.Annotations.Description,
                                })
                        }

from alertmanager-discord.

benjojo avatar benjojo commented on June 6, 2024

Cheers for the input json context,

Right now there is not a way for you to do this, The way I do this in my infra is to inline the interesting data bits into my alerts description

What would you want to do with the locID? Just display it?

from alertmanager-discord.

ki4rbc avatar ki4rbc commented on June 6, 2024

Thanks for responding so quickly,
The locID is how I know where the alert is coming from it comes from an os env which is then used as a yaml anchor which is later used to create the external_label.

The problem I am running into is that external_labels are not available for processing within alert rules; unless I am missing something.

And yes. I would like locID to show up anywhere in the alert in discord.

from alertmanager-discord.

benjojo avatar benjojo commented on June 6, 2024

from alertmanager-discord.

ki4rbc avatar ki4rbc commented on June 6, 2024

I found a work around to adding an alert origin identity, locationID in my case. By creating the alertmanager alerting rules is a config map template, I have access to environmental variables. It took a while to figure out I have to escape curly brackets. For example

          - alert: Deployments unavailable
            expr: 100 * (kube_deployment_status_replicas_available / kube_deployment_status_replicas) != 100
            for: 5m
            labels:
              severity: warn
            annotations:
              summary: 'Deployments unavailable at Location ID {{ .Values.locationID }}'
              description: '{{ "{{" }} $labels.deployment {{ "}}" }}.{{ "{{" }} $labels.namespace {{ "}}" }} at {{ "{{" }} $value | printf "%.2f" {{ "}}" }}% of intent'

I now can see where the alerts originate from.

I did see that on some alerts there is no label instance or exported_instance so we can still end up with alerts where realname is NULL.

I've created a fork and will work though a solution to propose.

from alertmanager-discord.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.