fix: honor alert forwarding business responses

This commit is contained in:
zxr
2026-07-18 08:51:58 +08:00
parent 601bfc58aa
commit d381360dfb
2 changed files with 33 additions and 26 deletions

View File

@@ -1,10 +1,8 @@
package ingest
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"strings"
"time"
@@ -118,25 +116,7 @@ func forwardRawEvent(body RawEventIngestBody) error {
if err != nil {
return err
}
url := cfg.BaseURL + "/Alert/v1/raw-events/ingest"
req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(raw))
if err != nil {
return err
}
req.Header.Set("Content-Type", "application/json")
if cfg.InternalKey != "" {
req.Header.Set("X-Internal-Key", cfg.InternalKey)
}
client := &http.Client{Timeout: 10 * time.Second}
resp, err := client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("alert returned HTTP %d", resp.StatusCode)
}
return nil
return postAlertPayload(cfg, "/Alert/v1/raw-events/ingest", raw)
}
func markOutboxRetry(row models.AlertOutbox, msg string) {