Hi,

I have send resolved set to true and I found an interesting option to show
the alert time in the alert:

duration: {{(.EndsAt.Sub .StartsAt).Truncate 1000000000}}

But when alerts fires i have something like this:

-2562047h47m16s

When resolved alert comes it looks gr8:

2m15s
How can i separate those two emails? Or maybe u have better query to show
duration between StartsAt and EndsAt?

Is there way to separate templates?
My actual config:

- name: alert-emailer-cpu-1h
  email_configs:
  - to: '[email protected]'
    send_resolved: true
    from:***
    smarthost: ***
    auth_username: ***
    auth_password: ***
    auth_secret:***
    auth_identity:***
    html: '{{ template "email" .}}'
    headers:
      subject: "[{{ .Status | toUpper }}][CUK] {{ .CommonLabels.severity }}
{{ .CommonLabels.instance }} {{ .CommonLabels.alertname }} | {{
.CommonAnnotations.description }}"


and template:
{{ define "email" }}
<html>
   <head>
      <style type="text/css">
         table {
         font-family: verdana,arial,sans-serif;
         font-size:14px;
         color:#333333;
         border-width: 1px;
         border-color: #999999;
         border-collapse: collapse;
         }
         table th {
         background-color:#ff6961;
         border-width: 1px;
         padding: 8px;
         border-style: solid;
         border-color: #F54C44;
         }
         table td {
         border-width: 1px;
         padding: 8px;
         border-style: solid;
         border-color: #F54C44;
         text-align: center;
         }
      </style>
   </head>
   <body>
      <table border=1>
         <thead>
           <tr>
        <th>Alert name</th>
        <th>Instance</th>
        <th>Summary</th>
        <th>Description</th>
           </tr>
         </thead>

         <tbody>
       {{ range .Alerts }}
            <tr>
         <td><b>{{ .Labels.alertname }}</td></b>
         <td>{{ .Labels.instance }}</td>
         <td>{{ .Annotations.summary }}</td>
         <td>{{ .Annotations.description }}</td>
         <td>{{ .StartsAt.Format "2006-01-02 15:04:05" }}</td>
         <td>{{(.EndsAt.Sub .StartsAt).Truncate 1000000000}}</td>

          </tr>
         </tbody>
{{end}}
      </table>
  </body>
</html>

{{end}}


Maybe there's way to see only duration between firing and resolved ? If i
can separate alerts (maybe with template) resolved and firing it would be
also gr8. But I don't know how :(

I'm not best in it so please be kind :D

Thanks for all replies!

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/CAFn4LSqxfWGMvR8d4obDgOgZ3EFQ5L5nDwWvaYhx6tpqys_xYg%40mail.gmail.com.

Reply via email to