0

Bosun fails to send alert notification to mail configured with the below log.

error: notify.go:111: failed to send alert high.cpu{host=} to [*@gmail.com] EOF

This is my bosun.conf

tsdbHost = localhost:4242
stateFile = /data/bosun.state
ledisBindAddr = 0.0.0.0:9565
smtpHost = smtp.gmail.com:465
emailFrom = bosun-alert@noreply.com

notification email {
     email = ***@gmail.com
     next = email
     timeout = 5s
     print = true
}

template test {
        subject = {{.Last.Status}}: {{.Alert.Name}} on {{.Group.host}}
        body = `<p>Alert: {{.Alert.Name}} triggered on {{.Group.host}}
        <hr>
        <p><strong>Computation</strong>
        <table> 
                {{range .Computations}}
                        <tr><td><a href="{{$.Expr .Text}}">{{.Text}}</a></td><td>{{.Value}}</td></tr>
                {{end}}
        </table>
        <hr>
        {{ .Graph .Alert.Vars.metric }}
        <hr>
        <p><strong>Relevant Tags</strong>
        <table> 
                {{range $k, $v := .Group}}
                        <tr><td>{{$k}}</td><td>{{$v}}</td></tr>
                {{end}}
        </table>`
}

alert high.cpu {
        template = test
        $metric = q("sum:rate{counter,,1}:os.cpu{host=*}", "1h", "")
        $avgcpu = avg($metric)
        crit = $avgcpu > 3
        warn = $avgcpu > 2
        critNotification = email
        warnNotification = email
}

Please help me figure what I am doing wrong.

bala
  • 43
  • 1
  • 5

1 Answers1

1

Do you also have smtpUsername and smtpPassword in your bosun config? Without those you probably can't use Bosun email notifications. The email may also be rejected unless it matches your gmail address or has been validated in your gmail account. and I believe we use port 587 for smtp.gmail.com instead of 465.

Example:

smtpHost = smtp.gmail.com:587
emailFrom = youraccount@gmail.com 
smtpUsername= youraccount@gmail.com
smtpPassword= yourpassword
Graham
  • 7,431
  • 18
  • 59
  • 84
Greg Bray
  • 14,929
  • 12
  • 80
  • 104
  • Thanks Grey Bray for the reply. I added emailFrom, smtpUsername, smtpPassword. For smtpHost=smtp.gmail.com:587 I get "failed to send alert high.cpu{host=*} to [***@gmail.com] crypto/tls: use of closed connection". For smtpHost=smtp.gmail.com:465 I get the same old error. Could be there anything going wrong ? – bala Jul 02 '16 at 11:31
  • The option in https://github.com/bosun-monitor/bosun/blob/master/cmd/bosun/conf/notify.go#L155 doesn't mail me feel good :-/ – Kyle Brandt Jul 05 '16 at 03:09
  • Possible reference: http://stackoverflow.com/questions/34998580/golang-email-sending-through-jordan-wright-email-v1 – Kyle Brandt Jul 05 '16 at 03:13