本文整理汇总了Golang中github.com/opsgenie/opsgenie-go-sdk/client.OpsGenieClient.SetApiKey方法的典型用法代码示例。如果您正苦于以下问题:Golang OpsGenieClient.SetApiKey方法的具体用法?Golang OpsGenieClient.SetApiKey怎么用?Golang OpsGenieClient.SetApiKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/opsgenie/opsgenie-go-sdk/client.OpsGenieClient
的用法示例。
在下文中一共展示了OpsGenieClient.SetApiKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Notify
func (opsgenie *OpsGenieNotifier) Notify(messages Messages) bool {
overallStatus, pass, warn, fail := messages.Summary()
client := new(ogcli.OpsGenieClient)
client.SetApiKey(opsgenie.ApiKey)
alertCli, cliErr := client.Alert()
if cliErr != nil {
log.Println("Opsgenie notification trouble with client")
return false
}
for _, message := range messages {
title := fmt.Sprintf("\n%s:%s:%s is %s.", message.Node, message.Service, message.Check, message.Status)
content := fmt.Sprintf(header, opsgenie.ClusterName, overallStatus, fail, warn, pass)
content += fmt.Sprintf("\n%s:%s:%s is %s.", message.Node, message.Service, message.Check, message.Status)
content += fmt.Sprintf("\n%s", message.Output)
// create the alert
response, alertErr := opsgenie.Send(alertCli, title, content)
if alertErr != nil {
log.Println("Opsgenie notification trouble.", response.Status)
return false
}
}
log.Println("Opsgenie notification send.")
return true
}