// Alert instantiates a new OpsGenieAlertClient.
// Deprecated: Please use AlertV2() method
968904
func (cli *OpsGenieClient) Alert() (*OpsGenieAlertClient, error) {
	cli.makeHTTPTransportSettings()

	alertClient := new(OpsGenieAlertClient)
	alertClient.SetOpsGenieClient(*cli)

	if cli.opsGenieAPIURL == "" {
		alertClient.SetOpsGenieAPIUrl(endpointURL)
	}

	return alertClient, nil
}
1225253
func (entry *Entry) Warn(args ...interface{}) {
	if entry.lgEntry.Logger.Level >= lg.WarnLevel {
		entry.lgEntry.WithFields(entry.fields).Warn(args...)
	}
}
1270693
func Alertm(attrs map[string]interface{}, format string, va ...interface{}) error {
	return logDefaultMsg(attrs, LEVEL_ALERT, format, va...)
}
917381
func (c *Client) Notify(ctx context.Context, method string, args ...interface{}) error {
	op := new(requestOp)
	msg, err := c.newMessage(method, args...)
	if err != nil {
		return err
	}
	msg.ID = nil

	if c.isHTTP {
		return c.sendHTTP(ctx, op, msg)
	} else {
		return c.send(ctx, op, msg)
	}
}
35344
func (ui *StdIOUI) notify(serviceMethod string, args interface{}) error {
	ctx := context.Background()
	err := ui.client.Notify(ctx, serviceMethod, args)
	if err != nil {
		log.Info("Error", "exc", err.Error())
	}
	return err
}
1019297
func (p *Payload) AlertBody(body string) *Payload {
	p.aps().alert().Body = body
	return p
}
396156
func (cli *OpsGenieClient) Contact() (*OpsGenieContactClient, error) {
	cli.makeHTTPTransportSettings()

	contactClient := new(OpsGenieContactClient)
	contactClient.SetOpsGenieClient(*cli)

	if cli.opsGenieAPIURL == "" {
		contactClient.SetOpsGenieAPIUrl(endpointURL)
	}

	return contactClient, nil
}
575570
func (a *AlertsService) Update(alertID uint, alert *Alert) (*http.Response, error) {
	u := fmt.Sprintf("alerts/%d", alertID)
	req, err := a.client.NewRequest("PUT", u, alert)
	if err != nil {
		return nil, err
	}

	return a.client.Do(req, nil)
}
345749
func (cli *OpsGenieClient) NotificationV2() (*OpsGenieNotificationV2Client, error) {
	cli.makeHTTPTransportSettings()

	notificationClient := new(OpsGenieNotificationV2Client)
	notificationClient.SetOpsGenieClient(*cli)

	if cli.opsGenieAPIURL == "" {
		notificationClient.SetOpsGenieAPIUrl(endpointURL)
	}

	return notificationClient, nil
}
1364191
func DefaultAlertConfig() *ConsulAlertConfig {

	checks := &ChecksConfig{
		Enabled:         true,
		ChangeThreshold: 60,
	}

	events := &EventsConfig{
		Enabled:  true,
		Handlers: []string{},
	}

	email := &notifier.EmailNotifier{
		ClusterName: "Consul-Alerts",
		Enabled:     false,
		SenderAlias: "Consul Alerts",
		Receivers:   []string{},
	}

	log := &notifier.LogNotifier{
		Enabled: true,
		Path:    "/tmp/consul-notifications.log",
	}

	influxdb := &notifier.InfluxdbNotifier{
		Enabled:    false,
		SeriesName: "consul-alerts",
	}

	slack := &notifier.SlackNotifier{
		Enabled:     false,
		ClusterName: "Consul-Alerts",
	}

	mattermost := &notifier.MattermostNotifier{
		Enabled:     false,
		ClusterName: "Consul-Alerts",
	}

	mattermostWebhook := &notifier.MattermostWebhookNotifier{
		Enabled:     false,
		ClusterName: "Consul-Alerts",
	}

	pagerduty := &notifier.PagerDutyNotifier{
		Enabled: false,
	}

	hipchat := &notifier.HipChatNotifier{
		Enabled:     false,
		ClusterName: "Consul-Alerts",
	}

	opsgenie := &notifier.OpsGenieNotifier{
		Enabled:     false,
		ClusterName: "Consul-Alerts",
	}

	awsSns := &notifier.AwsSnsNotifier{
		Enabled:     false,
		ClusterName: "Consul-Alerts",
	}

	victorOps := &notifier.VictorOpsNotifier{
		Enabled: false,
	}

	ilert := &notifier.ILertNotifier{
		Enabled:             false,
		IncidentKeyTemplate: "{{.Node}}:{{.Service}}:{{.Check}}",
	}

	notifiers := &notifier.Notifiers{
		Email:             email,
		Log:               log,
		Influxdb:          influxdb,
		Slack:             slack,
		Mattermost:        mattermost,
		MattermostWebhook: mattermostWebhook,
		PagerDuty:         pagerduty,
		HipChat:           hipchat,
		OpsGenie:          opsgenie,
		AwsSns:            awsSns,
		VictorOps:         victorOps,
		ILert:             ilert,
		Custom:            []string{},
	}

	return &ConsulAlertConfig{
		Checks:    checks,
		Events:    events,
		Notifiers: notifiers,
	}
}
382185
func Alert(config cfg.Config, message string) {
	log.Error("<!> ALERT <!>\n" + message)
	now := time.Now().Unix()
	if now-lastAlertUnix > int64(config.GetInt("alert_min_interval")) {
		message = fmt.Sprintf("%v:%v", config.GetString("chain_id"), message)
		if alertCountSince > 0 {
			message = fmt.Sprintf("%v (+%v more since)", message, alertCountSince)
			alertCountSince = 0
		}
		if len(config.GetString("alert_twilio_sid")) > 0 {
			go sendTwilio(config, message)
		}
		if len(config.GetString("alert_email_recipients")) > 0 {
			go sendEmail(config, message)
		}
	} else {
		alertCountSince++
	}
}
853440
func (c *Client) CreateAlert(projectName string, alertRequest AlertRequest) (result ResultModel, err error) {
	postObjContent, _ := json.Marshal(alertRequest)
	postJson := string(postObjContent)

	requestUrl := c.GetUrl(entity, projectName, "")
	requestPath := GetRequestPath(entity, projectName, "")

	responseResult, err := c.GetResponseJson("POST", requestUrl, requestPath, postJson)

	if err != nil {
		return result, err
	}

	err = json.Unmarshal([]byte(responseResult), &result)

	return result, err
}
595158
func (p *Project) Notify(eventType events.EventType, serviceName string, data map[string]string) {
	if eventType == events.NoEvent {
		return
	}

	event := events.Event{
		EventType:   eventType,
		ServiceName: serviceName,
		Data:        data,
	}

	for _, l := range p.listeners {
		l <- event
	}
}
781569
func (s *SubscriptionProvider) Notify(event interface{}) {
	s.RLock()
	defer s.RUnlock()
	for _, sub := range s.subscriptions {
		if err := sub.notify(event); err != nil {
			Log.Warnf("Failed notifying subscription (%s): %s", sub.id, err)
		}
	}
}
576253
func (kva *KvAlert) Raise(a *api.Alert) error {
	var subscriptions []api.Alert
	kv := kva.GetKvdbInstance()
	if _, err := kv.GetVal(getSubscriptionsKey(a.AlertType), &subscriptions); err != nil {
		if err != kvdb.ErrNotFound {
			return err
		}
	} else {
		for _, alert := range subscriptions {
			if err := kva.Raise(&alert); err != nil {
				return ErrSubscribedRaise
			}
		}
	}
	return kva.raise(a)
}
629850
func (a *AlertsService) Create(alert *Alert) (*Alert, *http.Response, error) {
	req, err := a.client.NewRequest("POST", "alerts", alert)
	if err != nil {
		return nil, nil, err
	}

	al := new(Alert)
	resp, err := a.client.Do(req, al)
	if err != nil {
		return nil, resp, err
	}

	return al, resp, err
}
648895
func MarshalAlertRule(r *ScopedAlert) ([]byte, error) {
	j, err := json.Marshal(r.AlertRule)
	if err != nil {
		return nil, err
	}
	return proto.Marshal(&AlertRule{
		ID:     r.ID,
		SrcID:  int64(r.SrcID),
		KapaID: int64(r.KapaID),
		JSON:   string(j),
	})
}