Пример #1
0
func (opsgenie *OpsGenieNotifier) Send(alertCli *ogcli.OpsGenieAlertClient, message string, content string) (*alerts.CreateAlertResponse, error) {
	req := alerts.CreateAlertRequest{
		Message:     message,
		Description: content,
		Source:      "consul",
		Entity:      opsgenie.ClusterName,
	}
	return alertCli.Create(req)
}
Пример #2
0
func (opsgenie *OpsGenieNotifier) createAlert(alertCli *ogcli.OpsGenieAlertClient, message string, content string, alias string) bool {
	log.Debug(fmt.Sprintf("OpsGenieAlertClient.CreateAlert alias: %s", alias))

	req := alerts.CreateAlertRequest{
		Message:     message,
		Description: content,
		Alias:       alias,
		Source:      "consul",
		Entity:      opsgenie.ClusterName,
	}
	response, alertErr := alertCli.Create(req)

	if alertErr != nil {
		if response == nil {
			log.Warn("Opsgenie notification trouble. ", alertErr)
		} else {
			log.Warn("Opsgenie notification trouble. ", response.Status)
		}
		return false
	}

	log.Println("Opsgenie notification sent.")
	return true
}