Skip to content

updates for alerts #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 27 additions & 25 deletions model.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,14 +478,15 @@ func getAlertBody(stream string) string {
{
"severity": "medium",
"title": "AlertTitle",
"query": "SELECT * FROM %s",
"stream": "%s",
"alertType": "threshold",
"aggregateConfig": {
"aggregateConditions": [
"aggregates": {
"operator": null,
"aggregateConfig": [
{
"agg": "count",
"conditionConfig": {
"conditions": [
"aggregateFunction": "count",
"conditions": {
"conditionConfig": [
{
"column": "status",
"operator": ">=",
Expand All @@ -499,7 +500,7 @@ func getAlertBody(stream string) string {
}
]
},
"evalType": {
"evalConfig": {
"rollingWindow": {
"evalStart": "5m",
"evalEnd": "now",
Expand All @@ -511,7 +512,7 @@ func getAlertBody(stream string) string {
"type": "webhook",
"endpoint": "https://webhook.site/ec627445-d52b-44e9-948d-56671df3581e",
"headers": {},
"skip_tls_check": true,
"skipTlsCheck": true,
"repeat": {
"interval": "1m",
"times": 1
Expand All @@ -523,15 +524,15 @@ func getAlertBody(stream string) string {

func getIdStateFromAlertResponse(body io.Reader) (string, string) {
type AlertConfig struct {
Severity string `json:"severity"`
Title string `json:"title"`
Id string `json:"id"`
State string `json:"state"`
Query string `json:"query"`
AlertType string `json:"alert_type"`
AggregateConfig string `json:"aggregate_config"`
EvalType string `json:"eval_type"`
Targets string `json:"targets"`
Severity string `json:"severity"`
Title string `json:"title"`
Id string `json:"id"`
State string `json:"state"`
Stream string `json:"stream"`
AlertType string `json:"alertType"`
Aggregates string `json:"aggregates"`
EvalConfig string `json:"evalConfig"`
Targets string `json:"targets"`
}

var response []AlertConfig
Expand All @@ -551,30 +552,31 @@ func createAlertResponse(id string, state string, stream string) string {
"state": "%s",
"severity": "medium",
"title": "AlertTitle",
"query": "SELECT * FROM %s",
"stream": "%s",
"alertType": "threshold",
"aggregateConfig": {
"aggregates": {
"operator": null,
"aggregateConditions": [
"aggregateConfig": [
{
"agg": "count",
"conditionConfig": {
"aggregateFunction": "count",
"conditions": {
"operator": null,
"conditions": [
"conditionConfig": [
{
"column": "status",
"operator": ">=",
"value": "200"
}
]
},
"groupBy": null,
"column": "status",
"operator": "<=",
"value": 100
}
]
},
"evalType": {
"evalConfig": {
"rollingWindow": {
"evalStart": "5m",
"evalEnd": "now",
Expand All @@ -586,7 +588,7 @@ func createAlertResponse(id string, state string, stream string) string {
"type": "webhook",
"endpoint": "https://webhook.site/ec627445-d52b-44e9-948d-56671df3581e",
"headers": {},
"skip_tls_check": true,
"skipTlsCheck": true,
"repeat": {
"interval": "1m",
"times": 1
Expand Down