utkarshcmu 8 lat temu
rodzic
commit
a562dc7c2b
1 zmienionych plików z 10 dodań i 10 usunięć
  1. 10 10
      pkg/services/alerting/notifiers/kafka.go

+ 10 - 10
pkg/services/alerting/notifiers/kafka.go

@@ -38,9 +38,9 @@ func NewKafkaNotifier(model *m.AlertNotification) (alerting.Notifier, error) {
 		return nil, alerting.ValidationError{Reason: "Could not find kafka rest proxy endpoint property in settings"}
 		return nil, alerting.ValidationError{Reason: "Could not find kafka rest proxy endpoint property in settings"}
 	}
 	}
 	topic := model.Settings.Get("kafkaTopic").MustString()
 	topic := model.Settings.Get("kafkaTopic").MustString()
-        if topic == "" {
-                return nil, alerting.ValidationError{Reason: "Could not find kafka topic property in settings"}
-        }
+	if topic == "" {
+		return nil, alerting.ValidationError{Reason: "Could not find kafka topic property in settings"}
+	}
 
 
 	return &KafkaNotifier{
 	return &KafkaNotifier{
 		NotifierBase: NewNotifierBase(model.Id, model.IsDefault, model.Name, model.Type, model.Settings),
 		NotifierBase: NewNotifierBase(model.Id, model.IsDefault, model.Name, model.Type, model.Settings),
@@ -52,9 +52,9 @@ func NewKafkaNotifier(model *m.AlertNotification) (alerting.Notifier, error) {
 
 
 type KafkaNotifier struct {
 type KafkaNotifier struct {
 	NotifierBase
 	NotifierBase
-	Endpoint    string
-	Topic       string
-	log         log.Logger
+	Endpoint string
+	Topic    string
+	log      log.Logger
 }
 }
 
 
 func (this *KafkaNotifier) Notify(evalContext *alerting.EvalContext) error {
 func (this *KafkaNotifier) Notify(evalContext *alerting.EvalContext) error {
@@ -99,16 +99,16 @@ func (this *KafkaNotifier) Notify(evalContext *alerting.EvalContext) error {
 	recordJSON.Set("records", records)
 	recordJSON.Set("records", records)
 	body, _ := recordJSON.MarshalJSON()
 	body, _ := recordJSON.MarshalJSON()
 
 
-	topicUrl := this.Endpoint+"/topics/"+this.Topic
+	topicUrl := this.Endpoint + "/topics/" + this.Topic
 
 
 	cmd := &m.SendWebhookSync{
 	cmd := &m.SendWebhookSync{
 		Url:        topicUrl,
 		Url:        topicUrl,
 		Body:       string(body),
 		Body:       string(body),
 		HttpMethod: "POST",
 		HttpMethod: "POST",
 		HttpHeader: map[string]string{
 		HttpHeader: map[string]string{
-                        "Content-Type":  "application/vnd.kafka.json.v2+json",
-                        "Accept": "application/vnd.kafka.v2+json",
-                },
+			"Content-Type": "application/vnd.kafka.json.v2+json",
+			"Accept":       "application/vnd.kafka.v2+json",
+		},
 	}
 	}
 
 
 	if err := bus.DispatchCtx(evalContext.Ctx, cmd); err != nil {
 	if err := bus.DispatchCtx(evalContext.Ctx, cmd); err != nil {