Skip to content

Commit 9eb8d14

Browse files
authored
updates for alerts (#101)
1 parent 9c5ad6b commit 9eb8d14

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed

model.go

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -478,14 +478,15 @@ func getAlertBody(stream string) string {
478478
{
479479
"severity": "medium",
480480
"title": "AlertTitle",
481-
"query": "SELECT * FROM %s",
481+
"stream": "%s",
482482
"alertType": "threshold",
483-
"aggregateConfig": {
484-
"aggregateConditions": [
483+
"aggregates": {
484+
"operator": null,
485+
"aggregateConfig": [
485486
{
486-
"agg": "count",
487-
"conditionConfig": {
488-
"conditions": [
487+
"aggregateFunction": "count",
488+
"conditions": {
489+
"conditionConfig": [
489490
{
490491
"column": "status",
491492
"operator": ">=",
@@ -499,7 +500,7 @@ func getAlertBody(stream string) string {
499500
}
500501
]
501502
},
502-
"evalType": {
503+
"evalConfig": {
503504
"rollingWindow": {
504505
"evalStart": "5m",
505506
"evalEnd": "now",
@@ -511,7 +512,7 @@ func getAlertBody(stream string) string {
511512
"type": "webhook",
512513
"endpoint": "https://webhook.site/ec627445-d52b-44e9-948d-56671df3581e",
513514
"headers": {},
514-
"skip_tls_check": true,
515+
"skipTlsCheck": true,
515516
"repeat": {
516517
"interval": "1m",
517518
"times": 1
@@ -523,15 +524,15 @@ func getAlertBody(stream string) string {
523524

524525
func getIdStateFromAlertResponse(body io.Reader) (string, string) {
525526
type AlertConfig struct {
526-
Severity string `json:"severity"`
527-
Title string `json:"title"`
528-
Id string `json:"id"`
529-
State string `json:"state"`
530-
Query string `json:"query"`
531-
AlertType string `json:"alert_type"`
532-
AggregateConfig string `json:"aggregate_config"`
533-
EvalType string `json:"eval_type"`
534-
Targets string `json:"targets"`
527+
Severity string `json:"severity"`
528+
Title string `json:"title"`
529+
Id string `json:"id"`
530+
State string `json:"state"`
531+
Stream string `json:"stream"`
532+
AlertType string `json:"alertType"`
533+
Aggregates string `json:"aggregates"`
534+
EvalConfig string `json:"evalConfig"`
535+
Targets string `json:"targets"`
535536
}
536537

537538
var response []AlertConfig
@@ -551,30 +552,31 @@ func createAlertResponse(id string, state string, stream string) string {
551552
"state": "%s",
552553
"severity": "medium",
553554
"title": "AlertTitle",
554-
"query": "SELECT * FROM %s",
555+
"stream": "%s",
555556
"alertType": "threshold",
556-
"aggregateConfig": {
557+
"aggregates": {
557558
"operator": null,
558-
"aggregateConditions": [
559+
"aggregateConfig": [
559560
{
560-
"agg": "count",
561-
"conditionConfig": {
561+
"aggregateFunction": "count",
562+
"conditions": {
562563
"operator": null,
563-
"conditions": [
564+
"conditionConfig": [
564565
{
565566
"column": "status",
566567
"operator": ">=",
567568
"value": "200"
568569
}
569570
]
570571
},
572+
"groupBy": null,
571573
"column": "status",
572574
"operator": "<=",
573575
"value": 100
574576
}
575577
]
576578
},
577-
"evalType": {
579+
"evalConfig": {
578580
"rollingWindow": {
579581
"evalStart": "5m",
580582
"evalEnd": "now",
@@ -586,7 +588,7 @@ func createAlertResponse(id string, state string, stream string) string {
586588
"type": "webhook",
587589
"endpoint": "https://webhook.site/ec627445-d52b-44e9-948d-56671df3581e",
588590
"headers": {},
589-
"skip_tls_check": true,
591+
"skipTlsCheck": true,
590592
"repeat": {
591593
"interval": "1m",
592594
"times": 1

0 commit comments

Comments
 (0)