func (a alertService) Send(alertName string, serviceName string, request string, status string, message string) error {
	startsAt := time.Now().UTC()
	alert := generateAlert(alertName, serviceName, request, status, message, startsAt, a.alertTimeout)
	alerts := []*model.Alert{alert}
	alertsJSON, _ := json.Marshal(alerts)
	r := bytes.NewReader(alertsJSON)
	endpoint := fmt.Sprintf("%s/api/v1/alerts", a.url)
	resp, err := http.Post(endpoint, "application/json", r)
	if err != nil {
		return errors.Wrap(err, "Failed to send alert to alertmanager")
	}
	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return errors.Wrap(err, "Unable to read body of alert response")
	}
	var resJSON alertmanagerAlertResponse
	err = json.Unmarshal(body, &resJSON)
	if err != nil {
		return errors.Wrap(err, "Unable to parse alert response")
	}
	if resJSON.Status != "success" {
		return fmt.Errorf("Send request to alertmanager failed")
	}
	return nil
}
Send sends alert to alert service
package service
import (
	"bytes"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
	"time"
	"github.com/pkg/errors"
	"github.com/prometheus/common/model"
)
type AlertServicer interface {
	Send(alertName string, serviceName string,
		request string, status string,
		message string) error
}
type silentAlertService struct{}
func (s silentAlertService) Send(alertName string,
	serviceName string, request string,
	status string, message string) error {
	return nil
}
func NewSilentAlertService() AlertServicer {
	return &silentAlertService{}
}
type alertService struct {
	url          string
	alertTimeout time.Duration
}
func NewAlertService(url string, alertTimeout time.Duration) AlertServicer {
	return &alertService{
		url:          url,
		alertTimeout: alertTimeout,
	}
}