@@ -522,21 +522,20 @@ func getAlertBody(stream string, targetId string) string {
522522 },
523523 "targets": [
524524 "%s"
525- ]
525+ ],
526+ "tags": ["quest-test"]
526527 }` , stream , targetId )
527528}
528529
529- func getIdStateFromAlertResponse (body io.Reader ) (string , string ) {
530+ func getMetadataFromAlertResponse (body io.Reader ) (string , string , string ) {
530531 type AlertConfig struct {
531- Severity string `json:"severity"`
532- Title string `json:"title"`
533- Id string `json:"id"`
534- State string `json:"state"`
535- Query string `json:"query"`
536- AlertType string `json:"alertType"`
537- ThresholdConfig string `json:"thresholdConfig"`
538- EvalConfig string `json:"evalConfig"`
539- Targets string `json:"targets"`
532+ Severity string `json:"severity"`
533+ Title string `json:"title"`
534+ Id string `json:"id"`
535+ State string `json:"state"`
536+ AlertType string `json:"alertType"`
537+ Tags []string `json:"tags"`
538+ Created string `json:"created"`
540539 }
541540
542541 var response []AlertConfig
@@ -545,32 +544,22 @@ func getIdStateFromAlertResponse(body io.Reader) (string, string) {
545544 }
546545
547546 alert := response [0 ]
548- return alert .Id , alert .State
547+ return alert .Id , alert .State , alert . Created
549548}
550549
551- func createAlertResponse (id string , state string , stream string , targetId string ) string {
550+ func createAlertResponse (id string , state string , created string ) string {
552551 return fmt .Sprintf (`
553- [{
554- "version": "v2",
555- "id": "%s",
556- "severity": "medium",
552+ [
553+ {
557554 "title": "AlertTitle",
558- "query ": "select count(level) from %s where level = 'info' ",
555+ "created ": "%s ",
559556 "alertType": "threshold",
560- "thresholdConfig": {
561- "operator": "=",
562- "value": 100.0
563- },
564- "evalConfig": {
565- "rollingWindow": {
566- "evalStart": "5m",
567- "evalEnd": "now",
568- "evalFrequency": 1
569- }
570- },
571- "targets": [
572- "%s"
573- ],
574- "state": "%s"
575- }]` , id , stream , targetId , state )
557+ "id": "%s",
558+ "severity": "Medium (P2)",
559+ "state": "%s",
560+ "tags": [
561+ "quest-test"
562+ ]
563+ }
564+ ]` , created , id , state )
576565}
0 commit comments