From 8de534100f524f5cf6c80f652f85c96e5e7462d7 Mon Sep 17 00:00:00 2001 From: Rohil Surana Date: Mon, 17 May 2021 13:24:30 +0530 Subject: [PATCH] fix: recording rule upload via cli Co-authored-by: Abhishek --- config.yaml.example | 4 ++-- pkg/uploader/model.go | 45 ++++++++++++++++++++++--------------------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/config.yaml.example b/config.yaml.example index cd27f6ba..18220b2e 100644 --- a/config.yaml.example +++ b/config.yaml.example @@ -1,4 +1,4 @@ -port: 8080 +port: 3000 db: host: localhost user: postgres @@ -7,7 +7,7 @@ db: port: 5432 sslmode: disable cortex: - address: http://localhost:8080 + address: http://localhost:9009 newrelic: enabled: false appname: siren diff --git a/pkg/uploader/model.go b/pkg/uploader/model.go index 2e5fe94c..62bc18f7 100644 --- a/pkg/uploader/model.go +++ b/pkg/uploader/model.go @@ -5,41 +5,42 @@ import ( ) type variables struct { - Name string `json:"name"` - Value string `json:"value"` + Name string `yaml:"name"` + Value string `yaml:"value"` } type rule struct { - Template string `json:"template"` - Status string `json:"enabled"` - Variables []variables `json:"variables"` + Template string `yaml:"template"` + Status string `yaml:"status"` + Variables []variables `yaml:"variables"` } type ruleYaml struct { - ApiVersion string `json:"apiVersion"` - Entity string `json:"entity"` - Type string `json:"type"` - Namespace string `json:"namespace"` - Rules map[string]rule `json:"rules"` + ApiVersion string `yaml:"apiVersion"` + Entity string `yaml:"entity"` + Type string `yaml:"type"` + Namespace string `yaml:"namespace"` + Rules map[string]rule `yaml:"rules"` } type templatedRule struct { - Alert string `json:"alert"` - Expr string `json:"expr"` - For string `json:"for"` - Labels map[string]string `json:"labels"` - Annotations map[string]string `json:"annotations"` + Record string `yaml:"record,omitempty"` + Alert string `yaml:"alert,omitempty"` + Expr string `yaml:"expr"` + For string `yaml:"for,omitempty"` + Labels map[string]string `yaml:"labels,omitempty"` + Annotations map[string]string `yaml:"annotations,omitempty"` } type template struct { - Name string `json:"name"` - ApiVersion string `json:"apiVersion"` - Type string `json:"type"` - Body []templatedRule `json:"body"` - Tags []string `json:"tags"` - Variables []domain.Variable `json:"variables"` + Name string `yaml:"name"` + ApiVersion string `yaml:"apiVersion"` + Type string `yaml:"type"` + Body []templatedRule `yaml:"body"` + Tags []string `yaml:"tags"` + Variables []domain.Variable `yaml:"variables"` } type yamlObject struct { - Type string `json:"type"` + Type string `yaml:"type"` }