load config
This commit is contained in:
commit
566c2a1a76
3 changed files with 163 additions and 0 deletions
55
parser.dis
Normal file
55
parser.dis
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
type Alert struct {
|
||||
Status string `json:"status"`
|
||||
StartsAt string `json:"startsAt"`
|
||||
EndsAt string `json:"endsAt"`
|
||||
GeneratorURL string `json:"generatorURL"`
|
||||
Fingerprint string `json:"fingerprint"`
|
||||
SilenceURL string `json:"silenceURL"`
|
||||
DashboardURL string `json:"dashboardURL"`
|
||||
PanelURL string `json:"panelURL"`
|
||||
ValueString string `json:"valueString"`
|
||||
OrgId int `json:"orgId"`
|
||||
Labels map[string]any `json:"labels"`
|
||||
Annotations map[string]any `json:"annotations"`
|
||||
values map[int]any `json:"values"`
|
||||
}
|
||||
|
||||
type Payload struct {
|
||||
Receiver string `json:"receiver"`
|
||||
Status string `json:"firing"`
|
||||
ExternalURL string `json:"externalURL"`
|
||||
Version string `json:"version"`
|
||||
GroupKey string `json:"groupKey"`
|
||||
TruncatedAlerts int `json:"truncatedAlerts"`
|
||||
OrgID int `json:"orgId"`
|
||||
Title string `json:"title"`
|
||||
State string `json"state"`
|
||||
Message string `json:"message"`
|
||||
Alerts []Alert `json:"alerts"`
|
||||
GroupLabels map[string]any `json:"groupLabels"`
|
||||
CommonLabels map[string]any `json:"groupLabels"`
|
||||
CommonAnnotations map[string]any `json:"commonAnnotations"`
|
||||
}
|
||||
|
||||
func check(e error) {
|
||||
if e != nil {
|
||||
panic(e)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
data, err := os.ReadFile("./alert.json")
|
||||
check(err)
|
||||
var payload Payload
|
||||
p1 := json.Unmarshal([]byte(data), &payload)
|
||||
check(p1)
|
||||
fmt.Printf("Full payload: %+v\n", payload)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue