Yuriy Zhilovets 5 жил өмнө
parent
commit
e8fb71f374
1 өөрчлөгдсөн 15 нэмэгдсэн , 2 устгасан
  1. 15 2
      telegram.pl

+ 15 - 2
telegram.pl

@@ -111,8 +111,21 @@ post "/alert" => sub
   
   for my $alert (@{$params->{alerts}})
   {
-    my $message = $alert->{status} eq "firing" ? "\x{1F534}" : "\x{1F197}";
-    $message .= "` [" . ($alert->{labels}->{server}||"") . "] " . $alert->{labels}->{alertname} . " " .$alert->{labels}->{instance} 
+    my $icon = "\x{2753}";
+    if ($alert->{status} eq "resolved")
+    {
+       $icon = "\x{1F197}";
+    }
+    elsif ($alert->{labels}->{severity} && $alert->{labels}->{severity} eq "critical")
+    {
+      $icon = "\x{1F534}";
+    }
+    elsif ($alert->{labels}->{severity} && $alert->{labels}->{severity} eq "warning")
+    {
+      $icon = "\x{26A0}";
+    }
+
+    my $message .= "$icon ` [" . ($alert->{labels}->{server}||"") . "] " . $alert->{labels}->{alertname} . " " .$alert->{labels}->{instance} 
                 . " " . $alert->{labels}->{job} . "`\n";
     $message .= $alert->{annotations}->{summary} . "\n" . "_" . $alert->{annotations}->{description} . "_";  
     notify($channel, $message, {});