@@ -507,27 +507,11 @@ func getAlertBody(stream string, targetId string) string {
507507 {
508508 "severity": "medium",
509509 "title": "AlertTitle",
510- "stream ": "%s ",
510+ "query ": "select count(level) from %s where level = 'info' ",
511511 "alertType": "threshold",
512- "aggregates": {
513- "operator": null,
514- "aggregateConfig": [
515- {
516- "aggregateFunction": "count",
517- "conditions": {
518- "conditionConfig": [
519- {
520- "column": "level",
521- "operator": "=",
522- "value": "info"
523- }
524- ]
525- },
526- "column": "level",
527- "operator": "=",
528- "value": 100
529- }
530- ]
512+ "thresholdConfig": {
513+ "operator": "=",
514+ "value": 100
531515 },
532516 "evalConfig": {
533517 "rollingWindow": {
@@ -544,15 +528,15 @@ func getAlertBody(stream string, targetId string) string {
544528
545529func getIdStateFromAlertResponse (body io.Reader ) (string , string ) {
546530 type AlertConfig struct {
547- Severity string `json:"severity"`
548- Title string `json:"title"`
549- Id string `json:"id"`
550- State string `json:"state"`
551- Stream string `json:"stream "`
552- AlertType string `json:"alertType"`
553- Aggregates string `json:"aggregates "`
554- EvalConfig string `json:"evalConfig"`
555- Targets string `json:"targets"`
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"`
556540 }
557541
558542 var response []AlertConfig
@@ -567,44 +551,26 @@ func getIdStateFromAlertResponse(body io.Reader) (string, string) {
567551func createAlertResponse (id string , state string , stream string , targetId string ) string {
568552 return fmt .Sprintf (`
569553 [{
570- "version": "v1",
571- "id": "%s",
572- "state": "%s",
573- "severity": "medium",
574- "title": "AlertTitle",
575- "stream": "%s",
576- "alertType": "threshold",
577- "aggregates": {
578- "operator": null,
579- "aggregateConfig": [
580- {
581- "aggregateFunction": "count",
582- "conditions": {
583- "operator": null,
584- "conditionConfig": [
585- {
586- "column": "level",
587- "operator": "=",
588- "value": "info"
589- }
590- ]
591- },
592- "groupBy": null,
593- "column": "level",
594- "operator": "=",
595- "value": 100
554+ "version": "v2",
555+ "id": "%s",
556+ "severity": "medium",
557+ "title": "AlertTitle",
558+ "query": "select count(level) from %s where level = 'info'",
559+ "alertType": "threshold",
560+ "thresholdConfig": {
561+ "operator": "=",
562+ "value": 100.0
563+ },
564+ "evalConfig": {
565+ "rollingWindow": {
566+ "evalStart": "5m",
567+ "evalEnd": "now",
568+ "evalFrequency": 1
596569 }
597- ]
598- },
599- "evalConfig": {
600- "rollingWindow": {
601- "evalStart": "5m",
602- "evalEnd": "now",
603- "evalFrequency": 1
604- }
605- },
606- "targets": [
607- "%s"
608- ]
609- }]` , id , state , stream , targetId )
570+ },
571+ "targets": [
572+ "%s"
573+ ],
574+ "state": "%s"
575+ }]` , id , stream , targetId , state )
610576}
0 commit comments