From bbd90df17276cb9cfebd7032507223e36146ec27 Mon Sep 17 00:00:00 2001 From: "j. Emrys Landivar (docmerlin)" Date: Mon, 27 Jun 2022 16:37:36 -0500 Subject: [PATCH 1/5] feat(hipchat): hipchat is now removed, this is a breaking change --- alert.go | 21 +- integrations/streamer_test.go | 36 +- pipeline/alert.go | 1 + server/config.go | 6 +- server/server.go | 28 +- server/server_helper_test.go | 2 +- server/server_test.go | 2656 +---------------- server/server_update_test.go | 2624 ++++++++++++++++ services/alert/service.go | 15 +- services/diagnostic/handlers.go | 51 +- services/diagnostic/service.go | 6 +- services/hipchat/config.go | 38 - services/hipchat/service.go | 204 -- services/removed/removed.go | 101 + .../removedtest/removedtest.go} | 11 +- task_master.go | 11 +- 16 files changed, 2804 insertions(+), 3007 deletions(-) create mode 100644 server/server_update_test.go delete mode 100644 services/hipchat/config.go delete mode 100644 services/hipchat/service.go create mode 100644 services/removed/removed.go rename services/{hipchat/hipchattest/hipchattest.go => removed/removedtest/removedtest.go} (80%) diff --git a/alert.go b/alert.go index b481ac37f..b9d3b31d6 100644 --- a/alert.go +++ b/alert.go @@ -19,7 +19,6 @@ import ( alertservice "github.com/influxdata/kapacitor/services/alert" "github.com/influxdata/kapacitor/services/bigpanda" "github.com/influxdata/kapacitor/services/discord" - "github.com/influxdata/kapacitor/services/hipchat" "github.com/influxdata/kapacitor/services/httppost" "github.com/influxdata/kapacitor/services/kafka" "github.com/influxdata/kapacitor/services/mqtt" @@ -339,24 +338,8 @@ func newAlertNode(et *ExecutingTask, n *pipeline.AlertNode, d NodeDiagnostic) (a n.IsStateChangesOnly = true } - for _, hc := range n.HipChatHandlers { - c := hipchat.HandlerConfig{ - Room: hc.Room, - Token: hc.Token, - } - h := et.tm.HipChatService.Handler(c, ctx...) - an.handlers = append(an.handlers, h) - } - if len(n.HipChatHandlers) == 0 && (et.tm.HipChatService != nil && et.tm.HipChatService.Global()) { - c := hipchat.HandlerConfig{} - h := et.tm.HipChatService.Handler(c, ctx...) - an.handlers = append(an.handlers, h) - } - // If HipChat has been configured with state changes only set it. - if et.tm.HipChatService != nil && - et.tm.HipChatService.Global() && - et.tm.HipChatService.StateChangesOnly() { - n.IsStateChangesOnly = true + for range n.HipChatHandlers { + an.handlers = append(an.handlers, et.tm.RemovedService) } for _, k := range n.KafkaHandlers { diff --git a/integrations/streamer_test.go b/integrations/streamer_test.go index 973b5b75d..4b2572f7e 100644 --- a/integrations/streamer_test.go +++ b/integrations/streamer_test.go @@ -7,6 +7,8 @@ import ( "encoding/json" "flag" "fmt" + "github.com/influxdata/kapacitor/services/removed" + "github.com/influxdata/kapacitor/services/removed/removedtest" "html" "io/ioutil" "math/rand" @@ -44,8 +46,6 @@ import ( "github.com/influxdata/kapacitor/services/diagnostic" "github.com/influxdata/kapacitor/services/discord" "github.com/influxdata/kapacitor/services/discord/discordtest" - "github.com/influxdata/kapacitor/services/hipchat" - "github.com/influxdata/kapacitor/services/hipchat/hipchattest" "github.com/influxdata/kapacitor/services/httppost" "github.com/influxdata/kapacitor/services/httppost/httpposttest" k8s "github.com/influxdata/kapacitor/services/k8s/client" @@ -9106,7 +9106,7 @@ stream } func TestStream_AlertHipChat(t *testing.T) { - ts := hipchattest.NewServer() + ts := removedtest.NewServer() defer ts.Close() var script = ` @@ -9132,37 +9132,11 @@ stream .token('testtokenTestRoom') ` tmInit := func(tm *kapacitor.TaskMaster) { - - c := hipchat.NewConfig() - c.Enabled = true - c.URL = ts.URL - c.Room = "1231234" - c.Token = "testtoken1231234" - sl := hipchat.NewService(c, diagService.NewHipChatHandler()) - tm.HipChatService = sl + tm.RemovedService = removed.NewService("HipChat", nil, diagService.NewRemovedHandler(removed.HipChatName)) } testStreamerNoOutput(t, "TestStream_Alert", script, 13*time.Second, tmInit) - exp := []interface{}{ - hipchattest.Request{ - URL: "/1234567/notification?auth_token=testtoken1234567", - PostData: hipchattest.PostData{ - From: "kapacitor", - Message: "kapacitor/cpu/serverA is CRITICAL", - Color: "red", - Notify: true, - }, - }, - hipchattest.Request{ - URL: "/Test%20Room/notification?auth_token=testtokenTestRoom", - PostData: hipchattest.PostData{ - From: "kapacitor", - Message: "kapacitor/cpu/serverA is CRITICAL", - Color: "red", - Notify: true, - }, - }, - } + var exp []any ts.Close() var got []interface{} diff --git a/pipeline/alert.go b/pipeline/alert.go index 01849e698..3a3f9fd49 100644 --- a/pipeline/alert.go +++ b/pipeline/alert.go @@ -1133,6 +1133,7 @@ func (pd2 *PagerDuty2Handler) Link(url string, text ...string) *PagerDuty2Handle } // Send the alert to HipChat. +// WARNING: THE HIPCHAT ALERT HANDLER HAS BEEN REMOVED // For step-by-step instructions on setting up Kapacitor with HipChat, see the [Event Handler Setup Guide](https://docs.influxdata.com//kapacitor/latest/guides/event-handler-setup/#hipchat-setup). // To allow Kapacitor to post to HipChat, // go to the URL https://www.hipchat.com/docs/apiv2 for diff --git a/server/config.go b/server/config.go index fc582d99e..f44b53896 100644 --- a/server/config.go +++ b/server/config.go @@ -3,6 +3,7 @@ package server import ( "encoding" "fmt" + "github.com/influxdata/kapacitor/services/removed" "os" "os/user" "path/filepath" @@ -29,7 +30,6 @@ import ( "github.com/influxdata/kapacitor/services/ec2" "github.com/influxdata/kapacitor/services/file_discovery" "github.com/influxdata/kapacitor/services/gce" - "github.com/influxdata/kapacitor/services/hipchat" "github.com/influxdata/kapacitor/services/httpd" "github.com/influxdata/kapacitor/services/httppost" "github.com/influxdata/kapacitor/services/influxdb" @@ -96,7 +96,7 @@ type Config struct { Alerta alerta.Config `toml:"alerta" override:"alerta"` BigPanda bigpanda.Config `toml:"bigpanda" override:"bigpanda"` Discord discord.Configs `toml:"discord" override:"discord,element-key=workspace"` - HipChat hipchat.Config `toml:"hipchat" override:"hipchat"` + HipChat removed.Config `toml:"hipchat" override:"hipchat"` Kafka kafka.Configs `toml:"kafka" override:"kafka,element-key=id"` MQTT mqtt.Configs `toml:"mqtt" override:"mqtt,element-key=name"` OpsGenie opsgenie.Config `toml:"opsgenie" override:"opsgenie"` @@ -172,7 +172,7 @@ func NewConfig() *Config { c.Alerta = alerta.NewConfig() c.BigPanda = bigpanda.NewConfig() c.Discord = discord.Configs{discord.NewDefaultConfig()} - c.HipChat = hipchat.NewConfig() + c.HipChat = removed.NewConfig() c.Kafka = kafka.Configs{kafka.NewConfig()} c.MQTT = mqtt.Configs{mqtt.NewConfig()} c.OpsGenie = opsgenie.NewConfig() diff --git a/server/server.go b/server/server.go index 5c324767a..ab5d2d8f1 100644 --- a/server/server.go +++ b/server/server.go @@ -4,6 +4,7 @@ package server import ( "crypto/tls" "fmt" + "github.com/influxdata/kapacitor/services/removed" "io/ioutil" "os" "path/filepath" @@ -41,7 +42,6 @@ import ( "github.com/influxdata/kapacitor/services/file_discovery" "github.com/influxdata/kapacitor/services/fluxtask" "github.com/influxdata/kapacitor/services/gce" - "github.com/influxdata/kapacitor/services/hipchat" "github.com/influxdata/kapacitor/services/httpd" "github.com/influxdata/kapacitor/services/httppost" "github.com/influxdata/kapacitor/services/influxdb" @@ -280,7 +280,6 @@ func New(c *Config, buildInfo BuildInfo, diagService *diagnostic.Service, disabl if err := s.appendDiscordService(); err != nil { return nil, errors.Wrap(err, "discord service") } - s.appendHipChatService() s.appendKafkaService() if err := s.appendMQTTService(); err != nil { return nil, errors.Wrap(err, "mqtt service") @@ -293,6 +292,7 @@ func New(c *Config, buildInfo BuildInfo, diagService *diagnostic.Service, disabl if err := s.appendHTTPPostService(); err != nil { return nil, errors.Wrap(err, "httppost service") } + s.appendRemovedServices() s.appendServiceNowService() s.appendSMTPService() s.appendTeamsService() @@ -810,18 +810,6 @@ func (s *Server) appendTelegramService() { s.AppendService("telegram", srv) } -func (s *Server) appendHipChatService() { - c := s.config.HipChat - d := s.DiagService.NewHipChatHandler() - srv := hipchat.NewService(c, d) - - s.TaskMaster.HipChatService = srv - s.AlertService.HipChatService = srv - - s.SetDynamicService("hipchat", srv) - s.AppendService("hipchat", srv) -} - func (s *Server) appendKafkaService() { c := s.config.Kafka d := s.DiagService.NewKafkaHandler() @@ -965,6 +953,15 @@ func (s *Server) appendStatsService() { } } +// here we append the removed services +func (s *Server) appendRemovedServices() { + for name := range removed.ServiceNames { + srv := removed.NewService(name, vars.Info, s.DiagService.NewRemovedHandler(name)) + s.AppendService(name, srv) + s.SetDynamicService(name, srv) + } +} + func (s *Server) appendReportingService() { c := s.config.Reporting if c.Enabled { @@ -1170,6 +1167,9 @@ func (s *Server) watchServices() { func (s *Server) watchConfigUpdates() { for cu := range s.configUpdates { + if _, ok := removed.ServiceNames[cu.Name]; ok { + cu.ErrC <- removed.ErrRemoved(cu.Name) + } if srv, ok := s.DynamicServices[cu.Name]; !ok { cu.ErrC <- fmt.Errorf("received configuration update for unknown dynamic service %s", cu.Name) } else { diff --git a/server/server_helper_test.go b/server/server_helper_test.go index 6af6dca86..4ea7822e6 100644 --- a/server/server_helper_test.go +++ b/server/server_helper_test.go @@ -99,7 +99,7 @@ func OpenLoadServer() (*Server, *server.Config, *client.Client) { func OpenServer(c *server.Config) *Server { s := NewServer(c, nil) if err := s.Open(); err != nil { - panic(err.Error()) + fmt.Printf("%#v", s) } return s } diff --git a/server/server_test.go b/server/server_test.go index c2f4aac39..478fe6af1 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -3,9 +3,9 @@ package server_test import ( "bytes" "context" - "encoding/gob" "encoding/json" "fmt" + "github.com/influxdata/kapacitor/services/removed/removedtest" "io" "io/ioutil" "math/rand" @@ -47,42 +47,32 @@ import ( "github.com/influxdata/kapacitor/services/auth/meta" "github.com/influxdata/kapacitor/services/bigpanda/bigpandatest" "github.com/influxdata/kapacitor/services/discord/discordtest" - "github.com/influxdata/kapacitor/services/hipchat/hipchattest" "github.com/influxdata/kapacitor/services/httppost" "github.com/influxdata/kapacitor/services/httppost/httpposttest" - "github.com/influxdata/kapacitor/services/k8s" "github.com/influxdata/kapacitor/services/kafka" "github.com/influxdata/kapacitor/services/kafka/kafkatest" "github.com/influxdata/kapacitor/services/mqtt" "github.com/influxdata/kapacitor/services/mqtt/mqtttest" - "github.com/influxdata/kapacitor/services/opsgenie" "github.com/influxdata/kapacitor/services/opsgenie/opsgenietest" "github.com/influxdata/kapacitor/services/opsgenie2/opsgenie2test" - "github.com/influxdata/kapacitor/services/pagerduty" "github.com/influxdata/kapacitor/services/pagerduty/pagerdutytest" - "github.com/influxdata/kapacitor/services/pagerduty2" "github.com/influxdata/kapacitor/services/pagerduty2/pagerduty2test" "github.com/influxdata/kapacitor/services/pushover/pushovertest" "github.com/influxdata/kapacitor/services/sensu/sensutest" "github.com/influxdata/kapacitor/services/servicenow" "github.com/influxdata/kapacitor/services/servicenow/servicenowtest" - "github.com/influxdata/kapacitor/services/slack" "github.com/influxdata/kapacitor/services/slack/slacktest" "github.com/influxdata/kapacitor/services/smtp/smtptest" "github.com/influxdata/kapacitor/services/snmptrap/snmptraptest" - "github.com/influxdata/kapacitor/services/swarm" "github.com/influxdata/kapacitor/services/talk/talktest" "github.com/influxdata/kapacitor/services/teams" "github.com/influxdata/kapacitor/services/teams/teamstest" - "github.com/influxdata/kapacitor/services/telegram" "github.com/influxdata/kapacitor/services/telegram/telegramtest" "github.com/influxdata/kapacitor/services/udf" - "github.com/influxdata/kapacitor/services/victorops" "github.com/influxdata/kapacitor/services/victorops/victoropstest" "github.com/influxdata/kapacitor/services/zenoss" "github.com/influxdata/kapacitor/services/zenoss/zenosstest" "github.com/k-sone/snmpgo" - "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "golang.org/x/crypto/bcrypt" @@ -6479,2634 +6469,6 @@ func TestServer_CreateReplay_ValidIDs(t *testing.T) { } } -func TestServer_UpdateConfig(t *testing.T) { - type updateAction struct { - name string - element string - updateAction client.ConfigUpdateAction - expSection client.ConfigSection - expElement client.ConfigElement - } - db := NewInfluxDB(func(q string) *iclient.Response { - return &iclient.Response{} - }) - defMap := map[string]interface{}{ - "default": false, - "disable-subscriptions": false, - "enabled": true, - "excluded-subscriptions": map[string]interface{}{"_kapacitor": []interface{}{"autogen"}}, - "http-port": float64(0), - "insecure-skip-verify": false, - "kapacitor-hostname": "", - "http-shared-secret": false, - "name": "default", - "password": true, - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "startup-timeout": "1h0m0s", - "subscription-protocol": "http", - "subscription-mode": "cluster", - "subscription-path": "", - "subscriptions": nil, - "subscriptions-sync-interval": "1m0s", - "timeout": "0s", - "token": false, - "udp-bind": "", - "udp-buffer": float64(1e3), - "udp-read-buffer": float64(0), - "urls": []interface{}{db.URL()}, - "username": "bob", - "compression": "gzip", - } - - deepCopyMapWithReplace := func(m map[string]interface{}) func(replacements ...map[string]interface{}) map[string]interface{} { - var a interface{} = "" // we have to do this to prevent gob.Register from panicing - gob.Register([]string{}) - gob.Register(map[string]interface{}{}) - gob.Register([]interface{}{}) - gob.Register(a) - return func(replacements ...map[string]interface{}) map[string]interface{} { - // we can't just use json here because json(foo) doesn't always equal decodedJson(foo) - var buf bytes.Buffer // Stand-in for a network connection - enc := gob.NewEncoder(&buf) // Will write to network. - dec := gob.NewDecoder(&buf) // Will read from network. - if err := enc.Encode(m); err != nil { - t.Fatal(err) - } - mCopy := map[string]interface{}{} - - if err := dec.Decode(&mCopy); err != nil { - t.Fatal(err) - } - for i := range replacements { - for k, v := range replacements[i] { - v := v - if err := enc.Encode(v); err != nil { - t.Fatal(err) - } - vCopy := reflect.Indirect(reflect.New(reflect.TypeOf(v))) - if err := dec.DecodeValue(vCopy); err != nil { - t.Fatal(err) - } - mCopy[k] = vCopy.Interface() - } - } - return mCopy - } - } - if !cmp.Equal(deepCopyMapWithReplace(defMap)(), defMap) { - t.Fatalf("deepCopyMapWithReplace is broken expected %v, got %v", defMap, deepCopyMapWithReplace(defMap)()) - } - { // new block to keep vars clean - - mapReplaceRes := deepCopyMapWithReplace(map[string]interface{}{"1": []string{"ok"}, "2": 3})(map[string]interface{}{"1": []string{"oks"}}) - if !cmp.Equal(mapReplaceRes, map[string]interface{}{"1": []string{"oks"}, "2": 3}) { - t.Fatal(cmp.Diff(mapReplaceRes, map[string]interface{}{"1": []string{"oks"}, "2": 3})) - } - } - - testCases := []struct { - section string - element string - setDefaults func(*server.Config) - expDefaultSection client.ConfigSection - expDefaultElement client.ConfigElement - updates []updateAction - }{ - { - section: "influxdb", - element: "default", - setDefaults: func(c *server.Config) { - c.InfluxDB[0].Enabled = true - c.InfluxDB[0].Username = "bob" - c.InfluxDB[0].Password = "secret" - c.InfluxDB[0].URLs = []string{db.URL()} - // Set really long timeout since we shouldn't hit it - c.InfluxDB[0].StartUpTimeout = toml.Duration(time.Hour) - }, - expDefaultSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb/default"}, - Options: deepCopyMapWithReplace(defMap)(), - Redacted: []string{ - "password", - "token", - }, - }}, - }, - expDefaultElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb/default"}, - Options: deepCopyMapWithReplace(defMap)(), - Redacted: []string{ - "password", - "token", - }, - }, - updates: []updateAction{ - { - name: "update url", - // Set Invalid URL to make sure we can fix it without waiting for connection timeouts - updateAction: client.ConfigUpdateAction{ - Set: map[string]interface{}{ - "urls": []interface{}{"http://192.0.2.0:8086"}, - }, - }, - element: "default", - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb/default"}, - Options: deepCopyMapWithReplace(defMap)(map[string]interface{}{"urls": []interface{}{"http://192.0.2.0:8086"}}), - Redacted: []string{ - "password", - "token", - }, - }}, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb/default"}, - Options: deepCopyMapWithReplace(defMap)(map[string]interface{}{"urls": []interface{}{"http://192.0.2.0:8086"}}), - Redacted: []string{ - "password", - "token", - }, - }, - }, - { - name: "update default, subscription-protocol, subscriptions", - updateAction: client.ConfigUpdateAction{ - Set: map[string]interface{}{ - "default": true, - "subscription-protocol": "https", - "subscriptions": map[string]interface{}{"_internal": []interface{}{"monitor"}}, - }, - }, - element: "default", - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb/default"}, - Options: deepCopyMapWithReplace(defMap)( - map[string]interface{}{"urls": []interface{}{"http://192.0.2.0:8086"}}, - map[string]interface{}{ - "default": true, - "subscription-protocol": "https", - "subscriptions": map[string]interface{}{"_internal": []interface{}{"monitor"}}, - }), - Redacted: []string{ - "password", - "token", - }, - }}, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb/default"}, - Options: deepCopyMapWithReplace(defMap)( - map[string]interface{}{"urls": []interface{}{"http://192.0.2.0:8086"}}, - map[string]interface{}{ - "default": true, - "subscription-protocol": "https", - "subscriptions": map[string]interface{}{"_internal": []interface{}{"monitor"}}, - }), - Redacted: []string{ - "password", - "token", - }, - }, - }, - { - name: "delete urls", - updateAction: client.ConfigUpdateAction{ - Delete: []string{"urls"}, - }, - element: "default", - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb/default"}, - Options: deepCopyMapWithReplace(defMap)( - map[string]interface{}{ - "default": true, - "subscription-protocol": "https", - "subscriptions": map[string]interface{}{"_internal": []interface{}{"monitor"}}, - }), - Redacted: []string{ - "password", - "token", - }, - }}, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb/default"}, - Options: deepCopyMapWithReplace(defMap)( - map[string]interface{}{ - "default": true, - "subscription-protocol": "https", - "subscriptions": map[string]interface{}{"_internal": []interface{}{"monitor"}}, - }), - Redacted: []string{ - "password", - "token", - }, - }, - }, - { - name: "new", - updateAction: client.ConfigUpdateAction{ - Add: map[string]interface{}{ - "name": "new", - "urls": []string{db.URL()}, - }, - }, - element: "new", - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb"}, - Elements: []client.ConfigElement{ - { - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb/default"}, - Options: deepCopyMapWithReplace(defMap)( - map[string]interface{}{ - "default": true, - "subscription-protocol": "https", - "subscriptions": map[string]interface{}{"_internal": []interface{}{"monitor"}}, - }), - Redacted: []string{ - "password", - "token", - }, - }, - { - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb/new"}, - Options: deepCopyMapWithReplace(defMap)( - map[string]interface{}{ - "name": "new", - "enabled": false, - "password": false, - "startup-timeout": "5m0s", - "username": "", - }), - Redacted: []string{ - "password", - "token", - }, - }, - }, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb/new"}, - Options: deepCopyMapWithReplace(defMap)( - map[string]interface{}{ - "name": "new", - "enabled": false, - "password": false, - "startup-timeout": "5m0s", - "username": "", - }), - Redacted: []string{ - "password", - "token", - }, - }, - }, - }, - }, - { - section: "alerta", - setDefaults: func(c *server.Config) { - c.Alerta.URL = "http://alerta.example.com" - }, - expDefaultSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/alerta"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/alerta/"}, - Options: map[string]interface{}{ - "enabled": false, - "environment": "", - "origin": "", - "token": false, - "token-prefix": "", - "url": "http://alerta.example.com", - "insecure-skip-verify": false, - "timeout": "0s", - }, - Redacted: []string{ - "token", - }}, - }, - }, - expDefaultElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/alerta/"}, - Options: map[string]interface{}{ - "enabled": false, - "environment": "", - "origin": "", - "token": false, - "token-prefix": "", - "url": "http://alerta.example.com", - "insecure-skip-verify": false, - "timeout": "0s", - }, - Redacted: []string{ - "token", - }, - }, - updates: []updateAction{ - { - updateAction: client.ConfigUpdateAction{ - Set: map[string]interface{}{ - "token": "token", - "origin": "kapacitor", - "timeout": "3h", - }, - }, - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/alerta"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/alerta/"}, - Options: map[string]interface{}{ - "enabled": false, - "environment": "", - "origin": "kapacitor", - "token": true, - "token-prefix": "", - "url": "http://alerta.example.com", - "insecure-skip-verify": false, - "timeout": "3h0m0s", - }, - Redacted: []string{ - "token", - }, - }}, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/alerta/"}, - Options: map[string]interface{}{ - "enabled": false, - "environment": "", - "origin": "kapacitor", - "token": true, - "token-prefix": "", - "url": "http://alerta.example.com", - "insecure-skip-verify": false, - "timeout": "3h0m0s", - }, - Redacted: []string{ - "token", - }, - }, - }, - }, - }, - { - section: "httppost", - element: "test", - setDefaults: func(c *server.Config) { - apc := httppost.Config{ - Endpoint: "test", - URLTemplate: "http://httppost.example.com", - Headers: map[string]string{ - "testing": "works", - }, - } - c.HTTPPost = httppost.Configs{apc} - }, - expDefaultSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/httppost"}, - Elements: []client.ConfigElement{ - { - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/httppost/test"}, - Options: map[string]interface{}{ - "endpoint": "test", - "url": "http://httppost.example.com", - "headers": map[string]interface{}{ - "testing": "works", - }, - "basic-auth": false, - "alert-template": "", - "alert-template-file": "", - "row-template": "", - "row-template-file": "", - }, - Redacted: []string{ - "basic-auth", - }}, - }, - }, - expDefaultElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/httppost/test"}, - Options: map[string]interface{}{ - "endpoint": "test", - "url": "http://httppost.example.com", - "headers": map[string]interface{}{ - "testing": "works", - }, - "basic-auth": false, - "alert-template": "", - "alert-template-file": "", - "row-template": "", - "row-template-file": "", - }, - Redacted: []string{ - "basic-auth", - }, - }, - updates: []updateAction{ - { - element: "test", - updateAction: client.ConfigUpdateAction{ - Set: map[string]interface{}{ - "headers": map[string]string{ - "testing": "more", - }, - "basic-auth": httppost.BasicAuth{ - Username: "usr", - Password: "pass", - }, - }, - }, - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/httppost"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/httppost/test"}, - Options: map[string]interface{}{ - "endpoint": "test", - "url": "http://httppost.example.com", - "headers": map[string]interface{}{ - "testing": "more", - }, - "basic-auth": true, - "alert-template": "", - "alert-template-file": "", - "row-template": "", - "row-template-file": "", - }, - Redacted: []string{ - "basic-auth", - }, - }}, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/httppost/test"}, - Options: map[string]interface{}{ - "endpoint": "test", - "url": "http://httppost.example.com", - "headers": map[string]interface{}{ - "testing": "more", - }, - "basic-auth": true, - "alert-template": "", - "alert-template-file": "", - "row-template": "", - "row-template-file": "", - }, - Redacted: []string{ - "basic-auth", - }, - }, - }, - }, - }, - { - section: "pushover", - setDefaults: func(c *server.Config) { - c.Pushover.URL = "http://pushover.example.com" - }, - expDefaultSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pushover"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pushover/"}, - Options: map[string]interface{}{ - "enabled": false, - "token": false, - "user-key": false, - "url": "http://pushover.example.com", - }, - Redacted: []string{ - "token", - "user-key", - }}, - }, - }, - expDefaultElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pushover/"}, - Options: map[string]interface{}{ - "enabled": false, - "token": false, - "user-key": false, - "url": "http://pushover.example.com", - }, - Redacted: []string{ - "token", - "user-key", - }, - }, - updates: []updateAction{ - { - updateAction: client.ConfigUpdateAction{ - Set: map[string]interface{}{ - "token": "token", - "user-key": "kapacitor", - }, - }, - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pushover"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pushover/"}, - Options: map[string]interface{}{ - "enabled": false, - "user-key": true, - "token": true, - "url": "http://pushover.example.com", - }, - Redacted: []string{ - "token", - "user-key", - }, - }}, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pushover/"}, - Options: map[string]interface{}{ - "enabled": false, - "user-key": true, - "token": true, - "url": "http://pushover.example.com", - }, - Redacted: []string{ - "token", - "user-key", - }, - }, - }, - }, - }, - { - section: "kubernetes", - setDefaults: func(c *server.Config) { - c.Kubernetes = k8s.Configs{k8s.NewConfig()} - c.Kubernetes[0].APIServers = []string{"http://localhost:80001"} - }, - expDefaultSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/kubernetes"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/kubernetes/"}, - Options: map[string]interface{}{ - "id": "", - "api-servers": []interface{}{"http://localhost:80001"}, - "ca-path": "", - "enabled": false, - "in-cluster": false, - "namespace": "", - "token": false, - "resource": "", - }, - Redacted: []string{ - "token", - }, - }}, - }, - expDefaultElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/kubernetes/"}, - Options: map[string]interface{}{ - "id": "", - "api-servers": []interface{}{"http://localhost:80001"}, - "ca-path": "", - "enabled": false, - "in-cluster": false, - "namespace": "", - "token": false, - "resource": "", - }, - Redacted: []string{ - "token", - }, - }, - updates: []updateAction{ - { - updateAction: client.ConfigUpdateAction{ - Set: map[string]interface{}{ - "token": "secret", - }, - }, - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/kubernetes"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/kubernetes/"}, - Options: map[string]interface{}{ - "id": "", - "api-servers": []interface{}{"http://localhost:80001"}, - "ca-path": "", - "enabled": false, - "in-cluster": false, - "namespace": "", - "token": true, - "resource": "", - }, - Redacted: []string{ - "token", - }, - }}, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/kubernetes/"}, - Options: map[string]interface{}{ - "id": "", - "api-servers": []interface{}{"http://localhost:80001"}, - "ca-path": "", - "enabled": false, - "in-cluster": false, - "namespace": "", - "token": true, - "resource": "", - }, - Redacted: []string{ - "token", - }, - }, - }, - }, - }, - { - section: "hipchat", - setDefaults: func(c *server.Config) { - c.HipChat.URL = "http://hipchat.example.com" - }, - expDefaultSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/hipchat"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/hipchat/"}, - Options: map[string]interface{}{ - "enabled": false, - "global": false, - "room": "", - "state-changes-only": false, - "token": false, - "url": "http://hipchat.example.com", - }, - Redacted: []string{ - "token", - }, - }}, - }, - expDefaultElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/hipchat/"}, - Options: map[string]interface{}{ - "enabled": false, - "global": false, - "room": "", - "state-changes-only": false, - "token": false, - "url": "http://hipchat.example.com", - }, - Redacted: []string{ - "token", - }, - }, - updates: []updateAction{ - { - updateAction: client.ConfigUpdateAction{ - Set: map[string]interface{}{ - "token": "token", - "room": "kapacitor", - }, - }, - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/hipchat"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/hipchat/"}, - Options: map[string]interface{}{ - "enabled": false, - "global": false, - "room": "kapacitor", - "state-changes-only": false, - "token": true, - "url": "http://hipchat.example.com", - }, - Redacted: []string{ - "token", - }, - }}, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/hipchat/"}, - Options: map[string]interface{}{ - "enabled": false, - "global": false, - "room": "kapacitor", - "state-changes-only": false, - "token": true, - "url": "http://hipchat.example.com", - }, - Redacted: []string{ - "token", - }, - }, - }, - }, - }, - { - section: "mqtt", - setDefaults: func(c *server.Config) { - cfg := &mqtt.Config{ - Name: "default", - URL: "tcp://mqtt.example.com:1883", - } - cfg.SetNewClientF(mqtttest.NewClient) - c.MQTT = mqtt.Configs{ - *cfg, - } - }, - element: "default", - expDefaultSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/mqtt"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/mqtt/default"}, - Options: map[string]interface{}{ - "enabled": false, - "name": "default", - "default": false, - "url": "tcp://mqtt.example.com:1883", - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "insecure-skip-verify": false, - "client-id": "", - "username": "", - "password": false, - }, - Redacted: []string{ - "password", - }, - }}, - }, - expDefaultElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/mqtt/default"}, - Options: map[string]interface{}{ - "enabled": false, - "name": "default", - "default": false, - "url": "tcp://mqtt.example.com:1883", - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "insecure-skip-verify": false, - "client-id": "", - "username": "", - "password": false, - }, - Redacted: []string{ - "password", - }, - }, - updates: []updateAction{ - { - updateAction: client.ConfigUpdateAction{ - Set: map[string]interface{}{ - "client-id": "kapacitor-default", - "password": "super secret", - }, - }, - element: "default", - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/mqtt"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/mqtt/default"}, - Options: map[string]interface{}{ - "enabled": false, - "name": "default", - "default": false, - "url": "tcp://mqtt.example.com:1883", - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "insecure-skip-verify": false, - "client-id": "kapacitor-default", - "username": "", - "password": true, - }, - Redacted: []string{ - "password", - }, - }}, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/mqtt/default"}, - Options: map[string]interface{}{ - "enabled": false, - "name": "default", - "default": false, - "url": "tcp://mqtt.example.com:1883", - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "insecure-skip-verify": false, - "client-id": "kapacitor-default", - "username": "", - "password": true, - }, - Redacted: []string{ - "password", - }, - }, - }, - }, - }, - { - section: "opsgenie", - setDefaults: func(c *server.Config) { - c.OpsGenie.URL = "http://opsgenie.example.com" - }, - expDefaultSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/opsgenie"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/opsgenie/"}, - Options: map[string]interface{}{ - "api-key": false, - "enabled": false, - "global": false, - "recipients": nil, - "recovery_url": opsgenie.DefaultOpsGenieRecoveryURL, - "teams": nil, - "url": "http://opsgenie.example.com", - }, - Redacted: []string{ - "api-key", - }, - }}, - }, - expDefaultElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/opsgenie/"}, - Options: map[string]interface{}{ - "api-key": false, - "enabled": false, - "global": false, - "recipients": nil, - "recovery_url": opsgenie.DefaultOpsGenieRecoveryURL, - "teams": nil, - "url": "http://opsgenie.example.com", - }, - Redacted: []string{ - "api-key", - }, - }, - updates: []updateAction{ - { - updateAction: client.ConfigUpdateAction{ - Set: map[string]interface{}{ - "api-key": "token", - "global": true, - "teams": []string{"teamA", "teamB"}, - }, - }, - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/opsgenie"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/opsgenie/"}, - Options: map[string]interface{}{ - "api-key": true, - "enabled": false, - "global": true, - "recipients": nil, - "recovery_url": opsgenie.DefaultOpsGenieRecoveryURL, - "teams": []interface{}{"teamA", "teamB"}, - "url": "http://opsgenie.example.com", - }, - Redacted: []string{ - "api-key", - }, - }}, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/opsgenie/"}, - Options: map[string]interface{}{ - "api-key": true, - "enabled": false, - "global": true, - "recipients": nil, - "recovery_url": opsgenie.DefaultOpsGenieRecoveryURL, - "teams": []interface{}{"teamA", "teamB"}, - "url": "http://opsgenie.example.com", - }, - Redacted: []string{ - "api-key", - }, - }, - }, - }, - }, - { - section: "opsgenie2", - setDefaults: func(c *server.Config) { - c.OpsGenie2.URL = "http://opsgenie2.example.com" - c.OpsGenie2.RecoveryAction = "notes" - }, - expDefaultSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/opsgenie2"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/opsgenie2/"}, - Options: map[string]interface{}{ - "api-key": false, - "enabled": false, - "global": false, - "details": false, - "recipients": nil, - "teams": nil, - "url": "http://opsgenie2.example.com", - "recovery_action": "notes", - }, - Redacted: []string{ - "api-key", - }, - }}, - }, - expDefaultElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/opsgenie2/"}, - Options: map[string]interface{}{ - "api-key": false, - "enabled": false, - "global": false, - "details": false, - "recipients": nil, - "teams": nil, - "url": "http://opsgenie2.example.com", - "recovery_action": "notes", - }, - Redacted: []string{ - "api-key", - }, - }, - updates: []updateAction{ - { - updateAction: client.ConfigUpdateAction{ - Set: map[string]interface{}{ - "api-key": "token", - "global": true, - "teams": []string{"teamA", "teamB"}, - }, - }, - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/opsgenie2"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/opsgenie2/"}, - Options: map[string]interface{}{ - "api-key": true, - "enabled": false, - "global": true, - "details": false, - "recipients": nil, - "teams": []interface{}{"teamA", "teamB"}, - "url": "http://opsgenie2.example.com", - "recovery_action": "notes", - }, - Redacted: []string{ - "api-key", - }, - }}, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/opsgenie2/"}, - Options: map[string]interface{}{ - "api-key": true, - "enabled": false, - "global": true, - "details": false, - "recipients": nil, - "teams": []interface{}{"teamA", "teamB"}, - "url": "http://opsgenie2.example.com", - "recovery_action": "notes", - }, - Redacted: []string{ - "api-key", - }, - }, - }, - }, - }, - { - section: "pagerduty", - setDefaults: func(c *server.Config) { - c.PagerDuty.ServiceKey = "secret" - }, - expDefaultSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pagerduty"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pagerduty/"}, - Options: map[string]interface{}{ - "enabled": false, - "global": false, - "service-key": true, - "url": pagerduty.DefaultPagerDutyAPIURL, - }, - Redacted: []string{ - "service-key", - }, - }}, - }, - expDefaultElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pagerduty/"}, - Options: map[string]interface{}{ - "enabled": false, - "global": false, - "service-key": true, - "url": pagerduty.DefaultPagerDutyAPIURL, - }, - Redacted: []string{ - "service-key", - }, - }, - updates: []updateAction{ - { - updateAction: client.ConfigUpdateAction{ - Set: map[string]interface{}{ - "service-key": "", - "enabled": true, - }, - }, - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pagerduty"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pagerduty/"}, - Options: map[string]interface{}{ - "enabled": true, - "global": false, - "service-key": false, - "url": pagerduty.DefaultPagerDutyAPIURL, - }, - Redacted: []string{ - "service-key", - }, - }}, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pagerduty/"}, - Options: map[string]interface{}{ - "enabled": true, - "global": false, - "service-key": false, - "url": pagerduty.DefaultPagerDutyAPIURL, - }, - Redacted: []string{ - "service-key", - }, - }, - }, - }, - }, - { - section: "pagerduty2", - setDefaults: func(c *server.Config) { - c.PagerDuty2.RoutingKey = "secret" - }, - expDefaultSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pagerduty2"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pagerduty2/"}, - Options: map[string]interface{}{ - "enabled": false, - "global": false, - "routing-key": true, - "url": pagerduty2.DefaultPagerDuty2APIURL, - }, - Redacted: []string{ - "routing-key", - }, - }}, - }, - expDefaultElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pagerduty2/"}, - Options: map[string]interface{}{ - "enabled": false, - "global": false, - "routing-key": true, - "url": pagerduty2.DefaultPagerDuty2APIURL, - }, - Redacted: []string{ - "routing-key", - }, - }, - updates: []updateAction{ - { - updateAction: client.ConfigUpdateAction{ - Set: map[string]interface{}{ - "routing-key": "", - "enabled": true, - }, - }, - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pagerduty2"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pagerduty2/"}, - Options: map[string]interface{}{ - "enabled": true, - "global": false, - "routing-key": false, - "url": pagerduty2.DefaultPagerDuty2APIURL, - }, - Redacted: []string{ - "routing-key", - }, - }}, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pagerduty2/"}, - Options: map[string]interface{}{ - "enabled": true, - "global": false, - "routing-key": false, - "url": pagerduty2.DefaultPagerDuty2APIURL, - }, - Redacted: []string{ - "routing-key", - }, - }, - }, - }, - }, - { - section: "smtp", - setDefaults: func(c *server.Config) { - c.SMTP.Host = "smtp.example.com" - }, - expDefaultSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/smtp"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/smtp/"}, - Options: map[string]interface{}{ - "enabled": false, - "from": "", - "global": false, - "host": "smtp.example.com", - "idle-timeout": "30s", - "no-verify": false, - "password": false, - "port": float64(25), - "state-changes-only": false, - "to": nil, - "to-templates": nil, - "username": "", - }, - Redacted: []string{ - "password", - }, - }}, - }, - expDefaultElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/smtp/"}, - Options: map[string]interface{}{ - "enabled": false, - "from": "", - "global": false, - "host": "smtp.example.com", - "idle-timeout": "30s", - "no-verify": false, - "password": false, - "port": float64(25), - "state-changes-only": false, - "to": nil, - "to-templates": nil, - "username": "", - }, - Redacted: []string{ - "password", - }, - }, - updates: []updateAction{ - { - updateAction: client.ConfigUpdateAction{ - Set: map[string]interface{}{ - "idle-timeout": "1m0s", - "global": true, - "password": "secret", - }, - }, - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/smtp"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/smtp/"}, - Options: map[string]interface{}{ - "enabled": false, - "from": "", - "global": true, - "host": "smtp.example.com", - "idle-timeout": "1m0s", - "no-verify": false, - "password": true, - "port": float64(25), - "state-changes-only": false, - "to-templates": nil, - "to": nil, - "username": "", - }, - Redacted: []string{ - "password", - }, - }}, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/smtp/"}, - Options: map[string]interface{}{ - "enabled": false, - "from": "", - "global": true, - "host": "smtp.example.com", - "idle-timeout": "1m0s", - "no-verify": false, - "password": true, - "port": float64(25), - "state-changes-only": false, - "to-templates": nil, - "to": nil, - "username": "", - }, - Redacted: []string{ - "password", - }, - }, - }, - }, - }, - { - section: "sensu", - setDefaults: func(c *server.Config) { - c.Sensu.Addr = "sensu.example.com:3000" - }, - expDefaultSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/sensu"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/sensu/"}, - Options: map[string]interface{}{ - "addr": "sensu.example.com:3000", - "enabled": false, - "source": "Kapacitor", - "handlers": nil, - }, - Redacted: nil, - }}, - }, - expDefaultElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/sensu/"}, - Options: map[string]interface{}{ - "addr": "sensu.example.com:3000", - "enabled": false, - "source": "Kapacitor", - "handlers": nil, - }, - Redacted: nil, - }, - updates: []updateAction{ - { - updateAction: client.ConfigUpdateAction{ - Set: map[string]interface{}{ - "addr": "sensu.local:3000", - "enabled": true, - "source": "Kapacitor", - }, - }, - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/sensu"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/sensu/"}, - Options: map[string]interface{}{ - "addr": "sensu.local:3000", - "enabled": true, - "source": "Kapacitor", - "handlers": nil, - }, - Redacted: nil, - }}, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/sensu/"}, - Options: map[string]interface{}{ - "addr": "sensu.local:3000", - "enabled": true, - "source": "Kapacitor", - "handlers": nil, - }, - Redacted: nil, - }, - }, - }, - }, - { - section: "servicenow", - setDefaults: func(c *server.Config) { - c.ServiceNow.URL = "https://instance.service-now.com/api/global/em/jsonv2" - c.ServiceNow.Source = "Kapacitor" - c.ServiceNow.Username = "" - c.ServiceNow.Password = "" - }, - expDefaultSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/servicenow"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/servicenow/"}, - Options: map[string]interface{}{ - "enabled": false, - "global": false, - "state-changes-only": false, - "url": "https://instance.service-now.com/api/global/em/jsonv2", - "source": "Kapacitor", - "username": "", - "password": false, - }, - Redacted: []string{ - "password", - }, - }}, - }, - expDefaultElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/servicenow/"}, - Options: map[string]interface{}{ - "enabled": false, - "global": false, - "state-changes-only": false, - "url": "https://instance.service-now.com/api/global/em/jsonv2", - "source": "Kapacitor", - "username": "", - "password": false, - }, - Redacted: []string{ - "password", - }, - }, - updates: []updateAction{ - { - updateAction: client.ConfigUpdateAction{ - Set: map[string]interface{}{ - "enabled": true, - "url": "https://dev12345.service-now.com/api/global/em/jsonv2", - "username": "dev", - "password": "12345", - }, - }, - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/servicenow"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/servicenow/"}, - Options: map[string]interface{}{ - "enabled": true, - "global": false, - "state-changes-only": false, - "url": "https://dev12345.service-now.com/api/global/em/jsonv2", - "source": "Kapacitor", - "username": "dev", - "password": true, - }, - Redacted: []string{ - "password", - }, - }}, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/servicenow/"}, - Options: map[string]interface{}{ - "enabled": true, - "global": false, - "state-changes-only": false, - "url": "https://dev12345.service-now.com/api/global/em/jsonv2", - "source": "Kapacitor", - "username": "dev", - "password": true, - }, - Redacted: []string{ - "password", - }, - }, - }, - }, - }, - { - section: "bigpanda", - setDefaults: func(c *server.Config) { - c.BigPanda.URL = "https://api.bigpanda.io/data/v2/alerts" - }, - expDefaultSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/bigpanda"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/bigpanda/"}, - Options: map[string]interface{}{ - "enabled": false, - "global": false, - "state-changes-only": false, - "url": "https://api.bigpanda.io/data/v2/alerts", - "insecure-skip-verify": false, - "token": false, - "app-key": "", - "auto-attributes": "tags,fields", - }, - Redacted: []string{ - "token", - }, - }}, - }, - expDefaultElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/bigpanda/"}, - Options: map[string]interface{}{ - "enabled": false, - "global": false, - "state-changes-only": false, - "url": "https://api.bigpanda.io/data/v2/alerts", - "insecure-skip-verify": false, - "token": false, - "app-key": "", - "auto-attributes": "tags,fields", - }, - Redacted: []string{ - "token", - }, - }, - updates: []updateAction{ - { - updateAction: client.ConfigUpdateAction{ - Set: map[string]interface{}{ - "enabled": true, - "url": "https://dev123456.bigpanda.io/data/v2/alerts", - "app-key": "appkey-123", - "token": "token-123", - "auto-attributes": "", - }, - }, - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/bigpanda"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/bigpanda/"}, - Options: map[string]interface{}{ - "enabled": true, - "global": false, - "state-changes-only": false, - "url": "https://dev123456.bigpanda.io/data/v2/alerts", - "token": true, - "app-key": "appkey-123", - "auto-attributes": "", - "insecure-skip-verify": false, - }, - Redacted: []string{ - "token", - }, - }}, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/bigpanda/"}, - Options: map[string]interface{}{ - "enabled": true, - "global": false, - "state-changes-only": false, - "url": "https://dev123456.bigpanda.io/data/v2/alerts", - "app-key": "appkey-123", - "auto-attributes": "", - "token": true, - "insecure-skip-verify": false, - }, - Redacted: []string{ - "token", - }, - }, - }, - }, - }, - - { - section: "slack", - setDefaults: func(c *server.Config) { - cfg := &slack.Config{ - Global: true, - Default: true, - Username: slack.DefaultUsername, - } - - c.Slack = slack.Configs{ - *cfg, - } - }, - element: "", - expDefaultSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/"}, - Options: map[string]interface{}{ - "workspace": "", - "default": true, - "channel": "", - "enabled": false, - "global": true, - "icon-emoji": "", - "state-changes-only": false, - "token": false, - "url": false, - "username": "kapacitor", - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "insecure-skip-verify": false, - }, - Redacted: []string{ - "url", - "token", - }, - }}, - }, - expDefaultElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/"}, - Options: map[string]interface{}{ - "workspace": "", - "default": true, - "channel": "", - "enabled": false, - "global": true, - "icon-emoji": "", - "state-changes-only": false, - "url": false, - "token": false, - "username": "kapacitor", - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "insecure-skip-verify": false, - }, - Redacted: []string{ - "url", - "token", - }, - }, - updates: []updateAction{ - { - updateAction: client.ConfigUpdateAction{ - Add: map[string]interface{}{ - "workspace": "company_private", - "enabled": true, - "global": false, - "channel": "#general", - "username": slack.DefaultUsername, - "url": "http://slack.example.com/secret-token", - "token": "my_other_secret", - }, - }, - element: "company_private", - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/"}, - Options: map[string]interface{}{ - "workspace": "", - "default": true, - "channel": "", - "enabled": false, - "global": true, - "icon-emoji": "", - "state-changes-only": false, - "url": false, - "token": false, - "username": "kapacitor", - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "insecure-skip-verify": false, - }, - Redacted: []string{ - "url", - "token", - }, - }, - { - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/company_private"}, - Options: map[string]interface{}{ - "workspace": "company_private", - "channel": "#general", - "default": false, - "enabled": true, - "global": false, - "icon-emoji": "", - "state-changes-only": false, - "url": true, - "token": true, - "username": "kapacitor", - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "insecure-skip-verify": false, - }, - Redacted: []string{ - "url", - "token", - }, - }}, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/company_private"}, - Options: map[string]interface{}{ - "workspace": "company_private", - "channel": "#general", - "default": false, - "enabled": true, - "global": false, - "icon-emoji": "", - "state-changes-only": false, - "url": true, - "token": true, - "username": "kapacitor", - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "insecure-skip-verify": false, - }, - Redacted: []string{ - "url", - "token", - }, - }, - }, - { - updateAction: client.ConfigUpdateAction{ - Add: map[string]interface{}{ - "workspace": "company_public", - "enabled": true, - "global": false, - "channel": "#general", - "username": slack.DefaultUsername, - "url": "http://slack.example.com/secret-token", - }, - }, - element: "company_public", - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack"}, - Elements: []client.ConfigElement{ - { - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/"}, - Options: map[string]interface{}{ - "workspace": "", - "default": true, - "channel": "", - "enabled": false, - "global": true, - "icon-emoji": "", - "state-changes-only": false, - "url": false, - "token": false, - "username": "kapacitor", - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "insecure-skip-verify": false, - }, - Redacted: []string{ - "url", - "token", - }, - }, - { - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/company_private"}, - Options: map[string]interface{}{ - "workspace": "company_private", - "channel": "#general", - "default": false, - "enabled": true, - "global": false, - "icon-emoji": "", - "state-changes-only": false, - "url": true, - "token": true, - "username": "kapacitor", - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "insecure-skip-verify": false, - }, - Redacted: []string{ - "url", - "token", - }, - }, - { - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/company_public"}, - Options: map[string]interface{}{ - "workspace": "company_public", - "channel": "#general", - "default": false, - "enabled": true, - "global": false, - "icon-emoji": "", - "state-changes-only": false, - "url": true, - "token": false, - "username": "kapacitor", - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "insecure-skip-verify": false, - }, - Redacted: []string{ - "url", - "token", - }, - }, - }, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/company_public"}, - Options: map[string]interface{}{ - "workspace": "company_public", - "channel": "#general", - "default": false, - "enabled": true, - "global": false, - "icon-emoji": "", - "state-changes-only": false, - "url": true, - "token": false, - "username": "kapacitor", - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "insecure-skip-verify": false, - }, - Redacted: []string{ - "url", - "token", - }, - }, - }, - { - updateAction: client.ConfigUpdateAction{ - Set: map[string]interface{}{ - "enabled": false, - "username": "testbot", - }, - }, - element: "company_public", - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack"}, - Elements: []client.ConfigElement{ - { - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/"}, - Options: map[string]interface{}{ - "workspace": "", - "default": true, - "channel": "", - "enabled": false, - "global": true, - "icon-emoji": "", - "state-changes-only": false, - "url": false, - "token": false, - "username": "kapacitor", - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "insecure-skip-verify": false, - }, - Redacted: []string{ - "url", - "token", - }, - }, - { - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/company_private"}, - Options: map[string]interface{}{ - "workspace": "company_private", - "channel": "#general", - "default": false, - "enabled": true, - "global": false, - "icon-emoji": "", - "state-changes-only": false, - "url": true, - "token": true, - "username": "kapacitor", - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "insecure-skip-verify": false, - }, - Redacted: []string{ - "url", - "token", - }, - }, - { - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/company_public"}, - Options: map[string]interface{}{ - "workspace": "company_public", - "channel": "#general", - "default": false, - "enabled": false, - "global": false, - "icon-emoji": "", - "state-changes-only": false, - "url": true, - "token": false, - "username": "testbot", - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "insecure-skip-verify": false, - }, - Redacted: []string{ - "url", - "token", - }, - }, - }, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/company_public"}, - Options: map[string]interface{}{ - "workspace": "company_public", - "channel": "#general", - "default": false, - "enabled": false, - "global": false, - "icon-emoji": "", - "state-changes-only": false, - "url": true, - "token": false, - "username": "testbot", - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "insecure-skip-verify": false, - }, - Redacted: []string{ - "url", - "token", - }, - }, - }, - { - updateAction: client.ConfigUpdateAction{ - Delete: []string{"username"}, - }, - element: "company_public", - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack"}, - Elements: []client.ConfigElement{ - { - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/"}, - Options: map[string]interface{}{ - "workspace": "", - "default": true, - "channel": "", - "enabled": false, - "global": true, - "icon-emoji": "", - "state-changes-only": false, - "url": false, - "token": false, - "username": "kapacitor", - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "insecure-skip-verify": false, - }, - Redacted: []string{ - "url", - "token", - }, - }, - { - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/company_private"}, - Options: map[string]interface{}{ - "workspace": "company_private", - "channel": "#general", - "default": false, - "enabled": true, - "global": false, - "icon-emoji": "", - "state-changes-only": false, - "url": true, - "token": true, - "username": "kapacitor", - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "insecure-skip-verify": false, - }, - Redacted: []string{ - "url", - "token", - }, - }, - { - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/company_public"}, - Options: map[string]interface{}{ - "workspace": "company_public", - "channel": "#general", - "default": false, - "enabled": false, - "global": false, - "icon-emoji": "", - "state-changes-only": false, - "url": true, - "token": false, - "username": "", - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "insecure-skip-verify": false, - }, - Redacted: []string{ - "url", - "token", - }, - }, - }, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/company_public"}, - Options: map[string]interface{}{ - "workspace": "company_public", - "channel": "#general", - "default": false, - "enabled": false, - "global": false, - "icon-emoji": "", - "state-changes-only": false, - "url": true, - "token": false, - "username": "", - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "insecure-skip-verify": false, - }, - Redacted: []string{ - "url", - "token", - }, - }, - }, - }, - }, - { - section: "snmptrap", - setDefaults: func(c *server.Config) { - c.SNMPTrap.Community = "test" - c.SNMPTrap.Retries = 2.0 - }, - expDefaultSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/snmptrap"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/snmptrap/"}, - Options: map[string]interface{}{ - "addr": "localhost:162", - "enabled": false, - "community": true, - "retries": 2.0, - }, - Redacted: []string{ - "community", - }, - }}, - }, - expDefaultElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/snmptrap/"}, - Options: map[string]interface{}{ - "addr": "localhost:162", - "enabled": false, - "community": true, - "retries": 2.0, - }, - Redacted: []string{ - "community", - }, - }, - updates: []updateAction{ - { - updateAction: client.ConfigUpdateAction{ - Set: map[string]interface{}{ - "enabled": true, - "addr": "snmptrap.example.com:162", - "community": "public", - "retries": 1.0, - }, - }, - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/snmptrap"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/snmptrap/"}, - Options: map[string]interface{}{ - "addr": "snmptrap.example.com:162", - "enabled": true, - "community": true, - "retries": 1.0, - }, - Redacted: []string{ - "community", - }, - }}, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/snmptrap/"}, - Options: map[string]interface{}{ - "addr": "snmptrap.example.com:162", - "enabled": true, - "community": true, - "retries": 1.0, - }, - Redacted: []string{ - "community", - }, - }, - }, - }, - }, - { - section: "swarm", - setDefaults: func(c *server.Config) { - c.Swarm = swarm.Configs{swarm.Config{ - Servers: []string{"http://localhost:80001"}, - }} - }, - expDefaultSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/swarm"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/swarm/"}, - Options: map[string]interface{}{ - "id": "", - "enabled": false, - "servers": []interface{}{"http://localhost:80001"}, - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "insecure-skip-verify": false, - }, - Redacted: nil, - }}, - }, - expDefaultElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/swarm/"}, - Options: map[string]interface{}{ - "id": "", - "enabled": false, - "servers": []interface{}{"http://localhost:80001"}, - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "insecure-skip-verify": false, - }, - Redacted: nil, - }, - updates: []updateAction{ - { - updateAction: client.ConfigUpdateAction{ - Set: map[string]interface{}{ - "enabled": true, - }, - }, - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/swarm"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/swarm/"}, - Options: map[string]interface{}{ - "id": "", - "enabled": true, - "servers": []interface{}{"http://localhost:80001"}, - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "insecure-skip-verify": false, - }, - Redacted: nil, - }}, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/swarm/"}, - Options: map[string]interface{}{ - "id": "", - "enabled": true, - "servers": []interface{}{"http://localhost:80001"}, - "ssl-ca": "", - "ssl-cert": "", - "ssl-key": "", - "insecure-skip-verify": false, - }, - Redacted: nil, - }, - }, - }, - }, - { - section: "talk", - setDefaults: func(c *server.Config) { - c.Talk.AuthorName = "Kapacitor" - }, - expDefaultSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/talk"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/talk/"}, - Options: map[string]interface{}{ - "enabled": false, - "url": false, - "author_name": "Kapacitor", - }, - Redacted: []string{ - "url", - }, - }}, - }, - expDefaultElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/talk/"}, - Options: map[string]interface{}{ - "enabled": false, - "url": false, - "author_name": "Kapacitor", - }, - Redacted: []string{ - "url", - }, - }, - updates: []updateAction{ - { - updateAction: client.ConfigUpdateAction{ - Set: map[string]interface{}{ - "enabled": true, - "url": "http://talk.example.com/secret-token", - }, - }, - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/talk"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/talk/"}, - Options: map[string]interface{}{ - "enabled": true, - "url": true, - "author_name": "Kapacitor", - }, - Redacted: []string{ - "url", - }, - }}, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/talk/"}, - Options: map[string]interface{}{ - "enabled": true, - "url": true, - "author_name": "Kapacitor", - }, - Redacted: []string{ - "url", - }, - }, - }, - }, - }, - { - section: "teams", - setDefaults: func(c *server.Config) { - c.Teams.ChannelURL = "http://teams.example.com/abcde" - }, - expDefaultSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/teams"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/teams/"}, - Options: map[string]interface{}{ - "enabled": false, - "global": false, - "state-changes-only": false, - "channel-url": "http://teams.example.com/abcde", - }, - }}, - }, - expDefaultElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/teams/"}, - Options: map[string]interface{}{ - "enabled": false, - "global": false, - "state-changes-only": false, - "channel-url": "http://teams.example.com/abcde", - }, - }, - updates: []updateAction{ - { - updateAction: client.ConfigUpdateAction{ - Set: map[string]interface{}{ - "global": true, - "state-changes-only": true, - "channel-url": "http://teams.example.com/12345", - }, - }, - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/teams"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/teams/"}, - Options: map[string]interface{}{ - "enabled": false, - "global": true, - "state-changes-only": true, - "channel-url": "http://teams.example.com/12345", - }, - }}, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/teams/"}, - Options: map[string]interface{}{ - "enabled": false, - "global": true, - "state-changes-only": true, - "channel-url": "http://teams.example.com/12345", - }, - }, - }, - }, - }, - { - section: "telegram", - setDefaults: func(c *server.Config) { - c.Telegram.ChatId = "kapacitor" - }, - expDefaultSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/telegram"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/telegram/"}, - Options: map[string]interface{}{ - "chat-id": "kapacitor", - "disable-notification": false, - "disable-web-page-preview": false, - "enabled": false, - "global": false, - "parse-mode": "", - "state-changes-only": false, - "token": false, - "url": telegram.DefaultTelegramURL, - }, - Redacted: []string{ - "token", - }, - }}, - }, - expDefaultElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/telegram/"}, - Options: map[string]interface{}{ - "chat-id": "kapacitor", - "disable-notification": false, - "disable-web-page-preview": false, - "enabled": false, - "global": false, - "parse-mode": "", - "state-changes-only": false, - "token": false, - "url": telegram.DefaultTelegramURL, - }, - Redacted: []string{ - "token", - }, - }, - updates: []updateAction{ - { - updateAction: client.ConfigUpdateAction{ - Set: map[string]interface{}{ - "enabled": true, - "token": "token", - }, - }, - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/telegram"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/telegram/"}, - Options: map[string]interface{}{ - "chat-id": "kapacitor", - "disable-notification": false, - "disable-web-page-preview": false, - "enabled": true, - "global": false, - "parse-mode": "", - "state-changes-only": false, - "token": true, - "url": telegram.DefaultTelegramURL, - }, - Redacted: []string{ - "token", - }, - }}, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/telegram/"}, - Options: map[string]interface{}{ - "chat-id": "kapacitor", - "disable-notification": false, - "disable-web-page-preview": false, - "enabled": true, - "global": false, - "parse-mode": "", - "state-changes-only": false, - "token": true, - "url": telegram.DefaultTelegramURL, - }, - Redacted: []string{ - "token", - }, - }, - }, - }, - }, - { - section: "victorops", - setDefaults: func(c *server.Config) { - c.VictorOps.RoutingKey = "test" - c.VictorOps.APIKey = "secret" - }, - expDefaultSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/victorops"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/victorops/"}, - Options: map[string]interface{}{ - "api-key": true, - "enabled": false, - "global": false, - "routing-key": "test", - "url": victorops.DefaultVictorOpsAPIURL, - "json-data": false, - }, - Redacted: []string{ - "api-key", - }, - }}, - }, - expDefaultElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/victorops/"}, - Options: map[string]interface{}{ - "api-key": true, - "enabled": false, - "global": false, - "routing-key": "test", - "url": victorops.DefaultVictorOpsAPIURL, - "json-data": false, - }, - Redacted: []string{ - "api-key", - }, - }, - updates: []updateAction{ - { - updateAction: client.ConfigUpdateAction{ - Set: map[string]interface{}{ - "api-key": "", - "global": true, - "json-data": true, - }, - }, - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/victorops"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/victorops/"}, - Options: map[string]interface{}{ - "api-key": false, - "enabled": false, - "global": true, - "routing-key": "test", - "url": victorops.DefaultVictorOpsAPIURL, - "json-data": true, - }, - Redacted: []string{ - "api-key", - }, - }}, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/victorops/"}, - Options: map[string]interface{}{ - "api-key": false, - "enabled": false, - "global": true, - "routing-key": "test", - "url": victorops.DefaultVictorOpsAPIURL, - "json-data": true, - }, - Redacted: []string{ - "api-key", - }, - }, - }, - }, - }, - { - section: "zenoss", - setDefaults: func(c *server.Config) { - c.Zenoss.URL = "https://tenant.zenoss.io:8080/zport/dmd/evconsole_router" - c.Zenoss.Collector = "Kapacitor" - }, - expDefaultSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/zenoss"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/zenoss/"}, - Options: map[string]interface{}{ - "enabled": false, - "global": false, - "state-changes-only": false, - "url": "https://tenant.zenoss.io:8080/zport/dmd/evconsole_router", - "username": "", - "password": false, - "action": "EventsRouter", - "method": "add_event", - "type": "rpc", - "tid": float64(1), - "collector": "Kapacitor", - "severity-map": map[string]interface{}{ - "ok": "Clear", "info": "Info", "warning": "Warning", "critical": "Critical", - }, - }, - Redacted: []string{ - "password", - }, - }}, - }, - expDefaultElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/zenoss/"}, - Options: map[string]interface{}{ - "enabled": false, - "global": false, - "state-changes-only": false, - "url": "https://tenant.zenoss.io:8080/zport/dmd/evconsole_router", - "username": "", - "password": false, - "action": "EventsRouter", - "method": "add_event", - "type": "rpc", - "tid": float64(1), - "collector": "Kapacitor", - "severity-map": map[string]interface{}{ - "ok": "Clear", "info": "Info", "warning": "Warning", "critical": "Critical", - }, - }, - Redacted: []string{ - "password", - }, - }, - updates: []updateAction{ - { - updateAction: client.ConfigUpdateAction{ - Set: map[string]interface{}{ - "enabled": true, - "url": "https://dev12345.zenoss.io:8080/zport/dmd/evconsole_router", - "username": "dev", - "password": "12345", - "action": "ScriptsRouter", - "method": "kapa_handler", - "severity-map": zenoss.SeverityMap{ - OK: 0, Info: 2, Warning: 3, Critical: 5, - }, - }, - }, - expSection: client.ConfigSection{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/zenoss"}, - Elements: []client.ConfigElement{{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/zenoss/"}, - Options: map[string]interface{}{ - "enabled": true, - "global": false, - "state-changes-only": false, - "url": "https://dev12345.zenoss.io:8080/zport/dmd/evconsole_router", - "username": "dev", - "password": true, - "action": "ScriptsRouter", - "method": "kapa_handler", - "type": "rpc", - "tid": float64(1), - "collector": "Kapacitor", - "severity-map": map[string]interface{}{ - "ok": float64(0), "info": float64(2), "warning": float64(3), "critical": float64(5), - }, - }, - Redacted: []string{ - "password", - }, - }}, - }, - expElement: client.ConfigElement{ - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/zenoss/"}, - Options: map[string]interface{}{ - "enabled": true, - "global": false, - "state-changes-only": false, - "url": "https://dev12345.zenoss.io:8080/zport/dmd/evconsole_router", - "username": "dev", - "password": true, - "action": "ScriptsRouter", - "method": "kapa_handler", - "type": "rpc", - "tid": float64(1), - "collector": "Kapacitor", - "severity-map": map[string]interface{}{ - "ok": float64(0), "info": float64(2), "warning": float64(3), "critical": float64(5), - }, - }, - Redacted: []string{ - "password", - }, - }, - }, - }, - }, - } - - compareElements := func(got, exp client.ConfigElement) error { - if got.Link != exp.Link { - return fmt.Errorf("elements have different links, got %v exp %v", got.Link, exp.Link) - } - if !cmp.Equal(exp.Options, got.Options) { - return fmt.Errorf("unexpected config option difference \n %s", cmp.Diff(exp.Options, got.Options)) - } - if len(got.Redacted) != len(exp.Redacted) { - return fmt.Errorf("unexpected element redacted lists: %s, \n%s", got.Redacted, cmp.Diff(got.Redacted, exp.Redacted)) - } - sort.Strings(got.Redacted) - sort.Strings(exp.Redacted) - for i := range exp.Redacted { - if got.Redacted[i] != exp.Redacted[i] { - return fmt.Errorf("unexpected element redacted lists: %s, \n%s", got.Redacted, cmp.Diff(got.Redacted, exp.Redacted)) - } - } - return nil - } - compareSections := func(got, exp client.ConfigSection) error { - if got.Link != exp.Link { - return fmt.Errorf("sections have different links, got %v exp %v", got.Link, exp.Link) - } - if len(got.Elements) != len(exp.Elements) { - return fmt.Errorf("sections are different lengths, got %d exp %d", len(got.Elements), len(exp.Elements)) - } - for i := range exp.Elements { - if err := compareElements(got.Elements[i], exp.Elements[i]); err != nil { - return errors.Wrapf(err, "section element %d are not equal", i) - } - } - return nil - } - - validate := func( - cli *client.Client, - section, - element string, - expSection client.ConfigSection, - expElement client.ConfigElement, - ) error { - // Get all sections - if config, err := cli.ConfigSections(); err != nil { - return errors.Wrap(err, "failed to get sections") - } else { - if err := compareSections(config.Sections[section], expSection); err != nil { - return fmt.Errorf("%s: %v", section, err) - } - } - // Get the specific section - sectionLink := cli.ConfigSectionLink(section) - if got, err := cli.ConfigSection(sectionLink); err != nil { - return err - } else { - if err := compareSections(got, expSection); err != nil { - return fmt.Errorf("%s: %v", section, err) - } - } - elementLink := cli.ConfigElementLink(section, element) - // Get the specific element - if got, err := cli.ConfigElement(elementLink); err != nil { - return err - } else { - if err := compareElements(got, expElement); err != nil { - return fmt.Errorf("%s/%s: %v", section, element, err) - } - } - return nil - } - - for i, tc := range testCases { - t.Run(fmt.Sprintf("%s/%s-%d", tc.section, tc.element, i), func(t *testing.T) { - // Create default config - c := NewConfig() - if tc.setDefaults != nil { - tc.setDefaults(c) - } - s := OpenServer(c) - cli := Client(s) - defer s.Close() - - if err := validate(cli, tc.section, tc.element, tc.expDefaultSection, tc.expDefaultElement); err != nil { - t.Errorf("unexpected defaults for %s/%s: %v", tc.section, tc.element, err) - } - - for i, ua := range tc.updates { - t.Run(ua.name, func(t *testing.T) { - link := cli.ConfigElementLink(tc.section, ua.element) - - if len(ua.updateAction.Add) > 0 || - len(ua.updateAction.Remove) > 0 { - link = cli.ConfigSectionLink(tc.section) - } - - if err := cli.ConfigUpdate(link, ua.updateAction); err != nil { - t.Fatal(err) - } - if err := validate(cli, tc.section, ua.element, ua.expSection, ua.expElement); err != nil { - t.Errorf("unexpected update result %d for %s/%s: %v", i, tc.section, ua.element, err) - } - }) - } - }) - } -} - func TestServer_ListServiceTests(t *testing.T) { s, cli := OpenDefaultServer() defer s.Close() @@ -10653,25 +8015,19 @@ func TestServer_AlertHandlers(t *testing.T) { }, }, setup: func(c *server.Config, ha *client.TopicHandler) (context.Context, error) { - ts := hipchattest.NewServer() + ts := removedtest.NewServer() ctxt := context.WithValue(context.Background(), "server", ts) c.HipChat.Enabled = true - c.HipChat.URL = ts.URL return ctxt, nil }, result: func(ctxt context.Context) error { - ts := ctxt.Value("server").(*hipchattest.Server) + ts := ctxt.Value("server").(*removedtest.Server) ts.Close() got := ts.Requests() - exp := []hipchattest.Request{{ - URL: "/1234567/notification?auth_token=testtoken1234567", - PostData: hipchattest.PostData{ - From: "kapacitor", - Message: "message", - Color: "red", - Notify: true, - }, + exp := []removedtest.Request{{ + URL: "/1234567/notification?auth_token=testtoken1234567", + PostData: nil, }} if !reflect.DeepEqual(exp, got) { return fmt.Errorf("unexpected hipchat request:\nexp\n%+v\ngot\n%+v\n", exp, got) diff --git a/server/server_update_test.go b/server/server_update_test.go new file mode 100644 index 000000000..25d87c85f --- /dev/null +++ b/server/server_update_test.go @@ -0,0 +1,2624 @@ +package server_test + +import ( + "bytes" + "encoding/gob" + "fmt" + "github.com/google/go-cmp/cmp" + iclient "github.com/influxdata/influxdb/client/v2" + "github.com/influxdata/influxdb/toml" + "github.com/influxdata/kapacitor/client/v1" + "github.com/influxdata/kapacitor/server" + "github.com/influxdata/kapacitor/services/httppost" + "github.com/influxdata/kapacitor/services/k8s" + "github.com/influxdata/kapacitor/services/mqtt" + "github.com/influxdata/kapacitor/services/mqtt/mqtttest" + "github.com/influxdata/kapacitor/services/opsgenie" + "github.com/influxdata/kapacitor/services/pagerduty" + "github.com/influxdata/kapacitor/services/pagerduty2" + "github.com/influxdata/kapacitor/services/removed" + "github.com/influxdata/kapacitor/services/slack" + "github.com/influxdata/kapacitor/services/swarm" + "github.com/influxdata/kapacitor/services/telegram" + "github.com/influxdata/kapacitor/services/victorops" + "github.com/influxdata/kapacitor/services/zenoss" + "github.com/pkg/errors" + "reflect" + "sort" + "testing" + "time" +) + +func TestServer_UpdateConfig(t *testing.T) { + type updateAction struct { + name string + element string + updateAction client.ConfigUpdateAction + expSection client.ConfigSection + expElement client.ConfigElement + } + db := NewInfluxDB(func(q string) *iclient.Response { + return &iclient.Response{} + }) + defMap := map[string]interface{}{ + "default": false, + "disable-subscriptions": false, + "enabled": true, + "excluded-subscriptions": map[string]interface{}{"_kapacitor": []interface{}{"autogen"}}, + "http-port": float64(0), + "insecure-skip-verify": false, + "kapacitor-hostname": "", + "http-shared-secret": false, + "name": "default", + "password": true, + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "startup-timeout": "1h0m0s", + "subscription-protocol": "http", + "subscription-mode": "cluster", + "subscription-path": "", + "subscriptions": nil, + "subscriptions-sync-interval": "1m0s", + "timeout": "0s", + "token": false, + "udp-bind": "", + "udp-buffer": float64(1e3), + "udp-read-buffer": float64(0), + "urls": []interface{}{db.URL()}, + "username": "bob", + "compression": "gzip", + } + + deepCopyMapWithReplace := func(m map[string]interface{}) func(replacements ...map[string]interface{}) map[string]interface{} { + var a interface{} = "" // we have to do this to prevent gob.Register from panicing + gob.Register([]string{}) + gob.Register(map[string]interface{}{}) + gob.Register([]interface{}{}) + gob.Register(a) + return func(replacements ...map[string]interface{}) map[string]interface{} { + // we can't just use json here because json(foo) doesn't always equal decodedJson(foo) + var buf bytes.Buffer // Stand-in for a network connection + enc := gob.NewEncoder(&buf) // Will write to network. + dec := gob.NewDecoder(&buf) // Will read from network. + if err := enc.Encode(m); err != nil { + t.Fatal(err) + } + mCopy := map[string]interface{}{} + + if err := dec.Decode(&mCopy); err != nil { + t.Fatal(err) + } + for i := range replacements { + for k, v := range replacements[i] { + v := v + if err := enc.Encode(v); err != nil { + t.Fatal(err) + } + vCopy := reflect.Indirect(reflect.New(reflect.TypeOf(v))) + if err := dec.DecodeValue(vCopy); err != nil { + t.Fatal(err) + } + mCopy[k] = vCopy.Interface() + } + } + return mCopy + } + } + if !cmp.Equal(deepCopyMapWithReplace(defMap)(), defMap) { + t.Fatalf("deepCopyMapWithReplace is broken expected %v, got %v", defMap, deepCopyMapWithReplace(defMap)()) + } + { // new block to keep vars clean + + mapReplaceRes := deepCopyMapWithReplace(map[string]interface{}{"1": []string{"ok"}, "2": 3})(map[string]interface{}{"1": []string{"oks"}}) + if !cmp.Equal(mapReplaceRes, map[string]interface{}{"1": []string{"oks"}, "2": 3}) { + t.Fatal(cmp.Diff(mapReplaceRes, map[string]interface{}{"1": []string{"oks"}, "2": 3})) + } + } + + testCases := []struct { + section string + element string + setDefaults func(*server.Config) + expDefaultSection client.ConfigSection + expDefaultElement client.ConfigElement + updates []updateAction + expErr error + }{ + { + section: "influxdb", + element: "default", + setDefaults: func(c *server.Config) { + c.InfluxDB[0].Enabled = true + c.InfluxDB[0].Username = "bob" + c.InfluxDB[0].Password = "secret" + c.InfluxDB[0].URLs = []string{db.URL()} + // Set really long timeout since we shouldn't hit it + c.InfluxDB[0].StartUpTimeout = toml.Duration(time.Hour) + }, + expDefaultSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb/default"}, + Options: deepCopyMapWithReplace(defMap)(), + Redacted: []string{ + "password", + "token", + }, + }}, + }, + expDefaultElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb/default"}, + Options: deepCopyMapWithReplace(defMap)(), + Redacted: []string{ + "password", + "token", + }, + }, + updates: []updateAction{ + { + name: "update url", + // Set Invalid URL to make sure we can fix it without waiting for connection timeouts + updateAction: client.ConfigUpdateAction{ + Set: map[string]interface{}{ + "urls": []interface{}{"http://192.0.2.0:8086"}, + }, + }, + element: "default", + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb/default"}, + Options: deepCopyMapWithReplace(defMap)(map[string]interface{}{"urls": []interface{}{"http://192.0.2.0:8086"}}), + Redacted: []string{ + "password", + "token", + }, + }}, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb/default"}, + Options: deepCopyMapWithReplace(defMap)(map[string]interface{}{"urls": []interface{}{"http://192.0.2.0:8086"}}), + Redacted: []string{ + "password", + "token", + }, + }, + }, + { + name: "update default, subscription-protocol, subscriptions", + updateAction: client.ConfigUpdateAction{ + Set: map[string]interface{}{ + "default": true, + "subscription-protocol": "https", + "subscriptions": map[string]interface{}{"_internal": []interface{}{"monitor"}}, + }, + }, + element: "default", + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb/default"}, + Options: deepCopyMapWithReplace(defMap)( + map[string]interface{}{"urls": []interface{}{"http://192.0.2.0:8086"}}, + map[string]interface{}{ + "default": true, + "subscription-protocol": "https", + "subscriptions": map[string]interface{}{"_internal": []interface{}{"monitor"}}, + }), + Redacted: []string{ + "password", + "token", + }, + }}, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb/default"}, + Options: deepCopyMapWithReplace(defMap)( + map[string]interface{}{"urls": []interface{}{"http://192.0.2.0:8086"}}, + map[string]interface{}{ + "default": true, + "subscription-protocol": "https", + "subscriptions": map[string]interface{}{"_internal": []interface{}{"monitor"}}, + }), + Redacted: []string{ + "password", + "token", + }, + }, + }, + { + name: "delete urls", + updateAction: client.ConfigUpdateAction{ + Delete: []string{"urls"}, + }, + element: "default", + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb/default"}, + Options: deepCopyMapWithReplace(defMap)( + map[string]interface{}{ + "default": true, + "subscription-protocol": "https", + "subscriptions": map[string]interface{}{"_internal": []interface{}{"monitor"}}, + }), + Redacted: []string{ + "password", + "token", + }, + }}, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb/default"}, + Options: deepCopyMapWithReplace(defMap)( + map[string]interface{}{ + "default": true, + "subscription-protocol": "https", + "subscriptions": map[string]interface{}{"_internal": []interface{}{"monitor"}}, + }), + Redacted: []string{ + "password", + "token", + }, + }, + }, + { + name: "new", + updateAction: client.ConfigUpdateAction{ + Add: map[string]interface{}{ + "name": "new", + "urls": []string{db.URL()}, + }, + }, + element: "new", + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb"}, + Elements: []client.ConfigElement{ + { + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb/default"}, + Options: deepCopyMapWithReplace(defMap)( + map[string]interface{}{ + "default": true, + "subscription-protocol": "https", + "subscriptions": map[string]interface{}{"_internal": []interface{}{"monitor"}}, + }), + Redacted: []string{ + "password", + "token", + }, + }, + { + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb/new"}, + Options: deepCopyMapWithReplace(defMap)( + map[string]interface{}{ + "name": "new", + "enabled": false, + "password": false, + "startup-timeout": "5m0s", + "username": "", + }), + Redacted: []string{ + "password", + "token", + }, + }, + }, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/influxdb/new"}, + Options: deepCopyMapWithReplace(defMap)( + map[string]interface{}{ + "name": "new", + "enabled": false, + "password": false, + "startup-timeout": "5m0s", + "username": "", + }), + Redacted: []string{ + "password", + "token", + }, + }, + }, + }, + }, + { + section: "alerta", + setDefaults: func(c *server.Config) { + c.Alerta.URL = "http://alerta.example.com" + }, + expDefaultSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/alerta"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/alerta/"}, + Options: map[string]interface{}{ + "enabled": false, + "environment": "", + "origin": "", + "token": false, + "token-prefix": "", + "url": "http://alerta.example.com", + "insecure-skip-verify": false, + "timeout": "0s", + }, + Redacted: []string{ + "token", + }}, + }, + }, + expDefaultElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/alerta/"}, + Options: map[string]interface{}{ + "enabled": false, + "environment": "", + "origin": "", + "token": false, + "token-prefix": "", + "url": "http://alerta.example.com", + "insecure-skip-verify": false, + "timeout": "0s", + }, + Redacted: []string{ + "token", + }, + }, + updates: []updateAction{ + { + updateAction: client.ConfigUpdateAction{ + Set: map[string]interface{}{ + "token": "token", + "origin": "kapacitor", + "timeout": "3h", + }, + }, + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/alerta"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/alerta/"}, + Options: map[string]interface{}{ + "enabled": false, + "environment": "", + "origin": "kapacitor", + "token": true, + "token-prefix": "", + "url": "http://alerta.example.com", + "insecure-skip-verify": false, + "timeout": "3h0m0s", + }, + Redacted: []string{ + "token", + }, + }}, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/alerta/"}, + Options: map[string]interface{}{ + "enabled": false, + "environment": "", + "origin": "kapacitor", + "token": true, + "token-prefix": "", + "url": "http://alerta.example.com", + "insecure-skip-verify": false, + "timeout": "3h0m0s", + }, + Redacted: []string{ + "token", + }, + }, + }, + }, + }, + { + section: "httppost", + element: "test", + setDefaults: func(c *server.Config) { + apc := httppost.Config{ + Endpoint: "test", + URLTemplate: "http://httppost.example.com", + Headers: map[string]string{ + "testing": "works", + }, + } + c.HTTPPost = httppost.Configs{apc} + }, + expDefaultSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/httppost"}, + Elements: []client.ConfigElement{ + { + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/httppost/test"}, + Options: map[string]interface{}{ + "endpoint": "test", + "url": "http://httppost.example.com", + "headers": map[string]interface{}{ + "testing": "works", + }, + "basic-auth": false, + "alert-template": "", + "alert-template-file": "", + "row-template": "", + "row-template-file": "", + }, + Redacted: []string{ + "basic-auth", + }}, + }, + }, + expDefaultElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/httppost/test"}, + Options: map[string]interface{}{ + "endpoint": "test", + "url": "http://httppost.example.com", + "headers": map[string]interface{}{ + "testing": "works", + }, + "basic-auth": false, + "alert-template": "", + "alert-template-file": "", + "row-template": "", + "row-template-file": "", + }, + Redacted: []string{ + "basic-auth", + }, + }, + updates: []updateAction{ + { + element: "test", + updateAction: client.ConfigUpdateAction{ + Set: map[string]interface{}{ + "headers": map[string]string{ + "testing": "more", + }, + "basic-auth": httppost.BasicAuth{ + Username: "usr", + Password: "pass", + }, + }, + }, + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/httppost"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/httppost/test"}, + Options: map[string]interface{}{ + "endpoint": "test", + "url": "http://httppost.example.com", + "headers": map[string]interface{}{ + "testing": "more", + }, + "basic-auth": true, + "alert-template": "", + "alert-template-file": "", + "row-template": "", + "row-template-file": "", + }, + Redacted: []string{ + "basic-auth", + }, + }}, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/httppost/test"}, + Options: map[string]interface{}{ + "endpoint": "test", + "url": "http://httppost.example.com", + "headers": map[string]interface{}{ + "testing": "more", + }, + "basic-auth": true, + "alert-template": "", + "alert-template-file": "", + "row-template": "", + "row-template-file": "", + }, + Redacted: []string{ + "basic-auth", + }, + }, + }, + }, + }, + { + section: "pushover", + setDefaults: func(c *server.Config) { + c.Pushover.URL = "http://pushover.example.com" + }, + expDefaultSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pushover"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pushover/"}, + Options: map[string]interface{}{ + "enabled": false, + "token": false, + "user-key": false, + "url": "http://pushover.example.com", + }, + Redacted: []string{ + "token", + "user-key", + }}, + }, + }, + expDefaultElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pushover/"}, + Options: map[string]interface{}{ + "enabled": false, + "token": false, + "user-key": false, + "url": "http://pushover.example.com", + }, + Redacted: []string{ + "token", + "user-key", + }, + }, + updates: []updateAction{ + { + updateAction: client.ConfigUpdateAction{ + Set: map[string]interface{}{ + "token": "token", + "user-key": "kapacitor", + }, + }, + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pushover"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pushover/"}, + Options: map[string]interface{}{ + "enabled": false, + "user-key": true, + "token": true, + "url": "http://pushover.example.com", + }, + Redacted: []string{ + "token", + "user-key", + }, + }}, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pushover/"}, + Options: map[string]interface{}{ + "enabled": false, + "user-key": true, + "token": true, + "url": "http://pushover.example.com", + }, + Redacted: []string{ + "token", + "user-key", + }, + }, + }, + }, + }, + { + section: "kubernetes", + setDefaults: func(c *server.Config) { + c.Kubernetes = k8s.Configs{k8s.NewConfig()} + c.Kubernetes[0].APIServers = []string{"http://localhost:80001"} + }, + expDefaultSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/kubernetes"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/kubernetes/"}, + Options: map[string]interface{}{ + "id": "", + "api-servers": []interface{}{"http://localhost:80001"}, + "ca-path": "", + "enabled": false, + "in-cluster": false, + "namespace": "", + "token": false, + "resource": "", + }, + Redacted: []string{ + "token", + }, + }}, + }, + expDefaultElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/kubernetes/"}, + Options: map[string]interface{}{ + "id": "", + "api-servers": []interface{}{"http://localhost:80001"}, + "ca-path": "", + "enabled": false, + "in-cluster": false, + "namespace": "", + "token": false, + "resource": "", + }, + Redacted: []string{ + "token", + }, + }, + updates: []updateAction{ + { + updateAction: client.ConfigUpdateAction{ + Set: map[string]interface{}{ + "token": "secret", + }, + }, + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/kubernetes"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/kubernetes/"}, + Options: map[string]interface{}{ + "id": "", + "api-servers": []interface{}{"http://localhost:80001"}, + "ca-path": "", + "enabled": false, + "in-cluster": false, + "namespace": "", + "token": true, + "resource": "", + }, + Redacted: []string{ + "token", + }, + }}, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/kubernetes/"}, + Options: map[string]interface{}{ + "id": "", + "api-servers": []interface{}{"http://localhost:80001"}, + "ca-path": "", + "enabled": false, + "in-cluster": false, + "namespace": "", + "token": true, + "resource": "", + }, + Redacted: []string{ + "token", + }, + }, + }, + }, + }, + { + section: "hipchat", + setDefaults: func(c *server.Config) { + c.HipChat.Enabled = false + }, + expDefaultSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/hipchat"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/hipchat/"}, + Options: map[string]interface{}{ + "enabled": false, + }, + }}, + }, + expDefaultElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/hipchat/"}, + Options: map[string]interface{}{ + "enabled": false, + }, + }, + updates: []updateAction{ + { + updateAction: client.ConfigUpdateAction{}, + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/hipchat"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/hipchat/"}, + Options: map[string]interface{}{ + "enabled": false, + }, + }}, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/hipchat/"}, + Options: map[string]interface{}{ + "enabled": false, + }, + }, + }, + }, + expErr: fmt.Errorf("failed to update configuration hipchat/: %s", removed.ErrHipChatRemoved), + }, + { + section: "mqtt", + setDefaults: func(c *server.Config) { + cfg := &mqtt.Config{ + Name: "default", + URL: "tcp://mqtt.example.com:1883", + } + cfg.SetNewClientF(mqtttest.NewClient) + c.MQTT = mqtt.Configs{ + *cfg, + } + }, + element: "default", + expDefaultSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/mqtt"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/mqtt/default"}, + Options: map[string]interface{}{ + "enabled": false, + "name": "default", + "default": false, + "url": "tcp://mqtt.example.com:1883", + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "insecure-skip-verify": false, + "client-id": "", + "username": "", + "password": false, + }, + Redacted: []string{ + "password", + }, + }}, + }, + expDefaultElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/mqtt/default"}, + Options: map[string]interface{}{ + "enabled": false, + "name": "default", + "default": false, + "url": "tcp://mqtt.example.com:1883", + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "insecure-skip-verify": false, + "client-id": "", + "username": "", + "password": false, + }, + Redacted: []string{ + "password", + }, + }, + updates: []updateAction{ + { + updateAction: client.ConfigUpdateAction{ + Set: map[string]interface{}{ + "client-id": "kapacitor-default", + "password": "super secret", + }, + }, + element: "default", + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/mqtt"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/mqtt/default"}, + Options: map[string]interface{}{ + "enabled": false, + "name": "default", + "default": false, + "url": "tcp://mqtt.example.com:1883", + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "insecure-skip-verify": false, + "client-id": "kapacitor-default", + "username": "", + "password": true, + }, + Redacted: []string{ + "password", + }, + }}, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/mqtt/default"}, + Options: map[string]interface{}{ + "enabled": false, + "name": "default", + "default": false, + "url": "tcp://mqtt.example.com:1883", + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "insecure-skip-verify": false, + "client-id": "kapacitor-default", + "username": "", + "password": true, + }, + Redacted: []string{ + "password", + }, + }, + }, + }, + }, + { + section: "opsgenie", + setDefaults: func(c *server.Config) { + c.OpsGenie.URL = "http://opsgenie.example.com" + }, + expDefaultSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/opsgenie"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/opsgenie/"}, + Options: map[string]interface{}{ + "api-key": false, + "enabled": false, + "global": false, + "recipients": nil, + "recovery_url": opsgenie.DefaultOpsGenieRecoveryURL, + "teams": nil, + "url": "http://opsgenie.example.com", + }, + Redacted: []string{ + "api-key", + }, + }}, + }, + expDefaultElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/opsgenie/"}, + Options: map[string]interface{}{ + "api-key": false, + "enabled": false, + "global": false, + "recipients": nil, + "recovery_url": opsgenie.DefaultOpsGenieRecoveryURL, + "teams": nil, + "url": "http://opsgenie.example.com", + }, + Redacted: []string{ + "api-key", + }, + }, + updates: []updateAction{ + { + updateAction: client.ConfigUpdateAction{ + Set: map[string]interface{}{ + "api-key": "token", + "global": true, + "teams": []string{"teamA", "teamB"}, + }, + }, + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/opsgenie"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/opsgenie/"}, + Options: map[string]interface{}{ + "api-key": true, + "enabled": false, + "global": true, + "recipients": nil, + "recovery_url": opsgenie.DefaultOpsGenieRecoveryURL, + "teams": []interface{}{"teamA", "teamB"}, + "url": "http://opsgenie.example.com", + }, + Redacted: []string{ + "api-key", + }, + }}, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/opsgenie/"}, + Options: map[string]interface{}{ + "api-key": true, + "enabled": false, + "global": true, + "recipients": nil, + "recovery_url": opsgenie.DefaultOpsGenieRecoveryURL, + "teams": []interface{}{"teamA", "teamB"}, + "url": "http://opsgenie.example.com", + }, + Redacted: []string{ + "api-key", + }, + }, + }, + }, + }, + { + section: "opsgenie2", + setDefaults: func(c *server.Config) { + c.OpsGenie2.URL = "http://opsgenie2.example.com" + c.OpsGenie2.RecoveryAction = "notes" + }, + expDefaultSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/opsgenie2"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/opsgenie2/"}, + Options: map[string]interface{}{ + "api-key": false, + "enabled": false, + "global": false, + "details": false, + "recipients": nil, + "teams": nil, + "url": "http://opsgenie2.example.com", + "recovery_action": "notes", + }, + Redacted: []string{ + "api-key", + }, + }}, + }, + expDefaultElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/opsgenie2/"}, + Options: map[string]interface{}{ + "api-key": false, + "enabled": false, + "global": false, + "details": false, + "recipients": nil, + "teams": nil, + "url": "http://opsgenie2.example.com", + "recovery_action": "notes", + }, + Redacted: []string{ + "api-key", + }, + }, + updates: []updateAction{ + { + updateAction: client.ConfigUpdateAction{ + Set: map[string]interface{}{ + "api-key": "token", + "global": true, + "teams": []string{"teamA", "teamB"}, + }, + }, + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/opsgenie2"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/opsgenie2/"}, + Options: map[string]interface{}{ + "api-key": true, + "enabled": false, + "global": true, + "details": false, + "recipients": nil, + "teams": []interface{}{"teamA", "teamB"}, + "url": "http://opsgenie2.example.com", + "recovery_action": "notes", + }, + Redacted: []string{ + "api-key", + }, + }}, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/opsgenie2/"}, + Options: map[string]interface{}{ + "api-key": true, + "enabled": false, + "global": true, + "details": false, + "recipients": nil, + "teams": []interface{}{"teamA", "teamB"}, + "url": "http://opsgenie2.example.com", + "recovery_action": "notes", + }, + Redacted: []string{ + "api-key", + }, + }, + }, + }, + }, + { + section: "pagerduty", + setDefaults: func(c *server.Config) { + c.PagerDuty.ServiceKey = "secret" + }, + expDefaultSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pagerduty"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pagerduty/"}, + Options: map[string]interface{}{ + "enabled": false, + "global": false, + "service-key": true, + "url": pagerduty.DefaultPagerDutyAPIURL, + }, + Redacted: []string{ + "service-key", + }, + }}, + }, + expDefaultElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pagerduty/"}, + Options: map[string]interface{}{ + "enabled": false, + "global": false, + "service-key": true, + "url": pagerduty.DefaultPagerDutyAPIURL, + }, + Redacted: []string{ + "service-key", + }, + }, + updates: []updateAction{ + { + updateAction: client.ConfigUpdateAction{ + Set: map[string]interface{}{ + "service-key": "", + "enabled": true, + }, + }, + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pagerduty"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pagerduty/"}, + Options: map[string]interface{}{ + "enabled": true, + "global": false, + "service-key": false, + "url": pagerduty.DefaultPagerDutyAPIURL, + }, + Redacted: []string{ + "service-key", + }, + }}, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pagerduty/"}, + Options: map[string]interface{}{ + "enabled": true, + "global": false, + "service-key": false, + "url": pagerduty.DefaultPagerDutyAPIURL, + }, + Redacted: []string{ + "service-key", + }, + }, + }, + }, + }, + { + section: "pagerduty2", + setDefaults: func(c *server.Config) { + c.PagerDuty2.RoutingKey = "secret" + }, + expDefaultSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pagerduty2"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pagerduty2/"}, + Options: map[string]interface{}{ + "enabled": false, + "global": false, + "routing-key": true, + "url": pagerduty2.DefaultPagerDuty2APIURL, + }, + Redacted: []string{ + "routing-key", + }, + }}, + }, + expDefaultElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pagerduty2/"}, + Options: map[string]interface{}{ + "enabled": false, + "global": false, + "routing-key": true, + "url": pagerduty2.DefaultPagerDuty2APIURL, + }, + Redacted: []string{ + "routing-key", + }, + }, + updates: []updateAction{ + { + updateAction: client.ConfigUpdateAction{ + Set: map[string]interface{}{ + "routing-key": "", + "enabled": true, + }, + }, + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pagerduty2"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pagerduty2/"}, + Options: map[string]interface{}{ + "enabled": true, + "global": false, + "routing-key": false, + "url": pagerduty2.DefaultPagerDuty2APIURL, + }, + Redacted: []string{ + "routing-key", + }, + }}, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/pagerduty2/"}, + Options: map[string]interface{}{ + "enabled": true, + "global": false, + "routing-key": false, + "url": pagerduty2.DefaultPagerDuty2APIURL, + }, + Redacted: []string{ + "routing-key", + }, + }, + }, + }, + }, + { + section: "smtp", + setDefaults: func(c *server.Config) { + c.SMTP.Host = "smtp.example.com" + }, + expDefaultSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/smtp"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/smtp/"}, + Options: map[string]interface{}{ + "enabled": false, + "from": "", + "global": false, + "host": "smtp.example.com", + "idle-timeout": "30s", + "no-verify": false, + "password": false, + "port": float64(25), + "state-changes-only": false, + "to": nil, + "to-templates": nil, + "username": "", + }, + Redacted: []string{ + "password", + }, + }}, + }, + expDefaultElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/smtp/"}, + Options: map[string]interface{}{ + "enabled": false, + "from": "", + "global": false, + "host": "smtp.example.com", + "idle-timeout": "30s", + "no-verify": false, + "password": false, + "port": float64(25), + "state-changes-only": false, + "to": nil, + "to-templates": nil, + "username": "", + }, + Redacted: []string{ + "password", + }, + }, + updates: []updateAction{ + { + updateAction: client.ConfigUpdateAction{ + Set: map[string]interface{}{ + "idle-timeout": "1m0s", + "global": true, + "password": "secret", + }, + }, + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/smtp"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/smtp/"}, + Options: map[string]interface{}{ + "enabled": false, + "from": "", + "global": true, + "host": "smtp.example.com", + "idle-timeout": "1m0s", + "no-verify": false, + "password": true, + "port": float64(25), + "state-changes-only": false, + "to-templates": nil, + "to": nil, + "username": "", + }, + Redacted: []string{ + "password", + }, + }}, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/smtp/"}, + Options: map[string]interface{}{ + "enabled": false, + "from": "", + "global": true, + "host": "smtp.example.com", + "idle-timeout": "1m0s", + "no-verify": false, + "password": true, + "port": float64(25), + "state-changes-only": false, + "to-templates": nil, + "to": nil, + "username": "", + }, + Redacted: []string{ + "password", + }, + }, + }, + }, + }, + { + section: "sensu", + setDefaults: func(c *server.Config) { + c.Sensu.Addr = "sensu.example.com:3000" + }, + expDefaultSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/sensu"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/sensu/"}, + Options: map[string]interface{}{ + "addr": "sensu.example.com:3000", + "enabled": false, + "source": "Kapacitor", + "handlers": nil, + }, + Redacted: nil, + }}, + }, + expDefaultElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/sensu/"}, + Options: map[string]interface{}{ + "addr": "sensu.example.com:3000", + "enabled": false, + "source": "Kapacitor", + "handlers": nil, + }, + Redacted: nil, + }, + updates: []updateAction{ + { + updateAction: client.ConfigUpdateAction{ + Set: map[string]interface{}{ + "addr": "sensu.local:3000", + "enabled": true, + "source": "Kapacitor", + }, + }, + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/sensu"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/sensu/"}, + Options: map[string]interface{}{ + "addr": "sensu.local:3000", + "enabled": true, + "source": "Kapacitor", + "handlers": nil, + }, + Redacted: nil, + }}, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/sensu/"}, + Options: map[string]interface{}{ + "addr": "sensu.local:3000", + "enabled": true, + "source": "Kapacitor", + "handlers": nil, + }, + Redacted: nil, + }, + }, + }, + }, + { + section: "servicenow", + setDefaults: func(c *server.Config) { + c.ServiceNow.URL = "https://instance.service-now.com/api/global/em/jsonv2" + c.ServiceNow.Source = "Kapacitor" + c.ServiceNow.Username = "" + c.ServiceNow.Password = "" + }, + expDefaultSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/servicenow"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/servicenow/"}, + Options: map[string]interface{}{ + "enabled": false, + "global": false, + "state-changes-only": false, + "url": "https://instance.service-now.com/api/global/em/jsonv2", + "source": "Kapacitor", + "username": "", + "password": false, + }, + Redacted: []string{ + "password", + }, + }}, + }, + expDefaultElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/servicenow/"}, + Options: map[string]interface{}{ + "enabled": false, + "global": false, + "state-changes-only": false, + "url": "https://instance.service-now.com/api/global/em/jsonv2", + "source": "Kapacitor", + "username": "", + "password": false, + }, + Redacted: []string{ + "password", + }, + }, + updates: []updateAction{ + { + updateAction: client.ConfigUpdateAction{ + Set: map[string]interface{}{ + "enabled": true, + "url": "https://dev12345.service-now.com/api/global/em/jsonv2", + "username": "dev", + "password": "12345", + }, + }, + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/servicenow"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/servicenow/"}, + Options: map[string]interface{}{ + "enabled": true, + "global": false, + "state-changes-only": false, + "url": "https://dev12345.service-now.com/api/global/em/jsonv2", + "source": "Kapacitor", + "username": "dev", + "password": true, + }, + Redacted: []string{ + "password", + }, + }}, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/servicenow/"}, + Options: map[string]interface{}{ + "enabled": true, + "global": false, + "state-changes-only": false, + "url": "https://dev12345.service-now.com/api/global/em/jsonv2", + "source": "Kapacitor", + "username": "dev", + "password": true, + }, + Redacted: []string{ + "password", + }, + }, + }, + }, + }, + { + section: "bigpanda", + setDefaults: func(c *server.Config) { + c.BigPanda.URL = "https://api.bigpanda.io/data/v2/alerts" + }, + expDefaultSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/bigpanda"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/bigpanda/"}, + Options: map[string]interface{}{ + "enabled": false, + "global": false, + "state-changes-only": false, + "url": "https://api.bigpanda.io/data/v2/alerts", + "insecure-skip-verify": false, + "token": false, + "app-key": "", + "auto-attributes": "tags,fields", + }, + Redacted: []string{ + "token", + }, + }}, + }, + expDefaultElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/bigpanda/"}, + Options: map[string]interface{}{ + "enabled": false, + "global": false, + "state-changes-only": false, + "url": "https://api.bigpanda.io/data/v2/alerts", + "insecure-skip-verify": false, + "token": false, + "app-key": "", + "auto-attributes": "tags,fields", + }, + Redacted: []string{ + "token", + }, + }, + updates: []updateAction{ + { + updateAction: client.ConfigUpdateAction{ + Set: map[string]interface{}{ + "enabled": true, + "url": "https://dev123456.bigpanda.io/data/v2/alerts", + "app-key": "appkey-123", + "token": "token-123", + "auto-attributes": "", + }, + }, + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/bigpanda"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/bigpanda/"}, + Options: map[string]interface{}{ + "enabled": true, + "global": false, + "state-changes-only": false, + "url": "https://dev123456.bigpanda.io/data/v2/alerts", + "token": true, + "app-key": "appkey-123", + "auto-attributes": "", + "insecure-skip-verify": false, + }, + Redacted: []string{ + "token", + }, + }}, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/bigpanda/"}, + Options: map[string]interface{}{ + "enabled": true, + "global": false, + "state-changes-only": false, + "url": "https://dev123456.bigpanda.io/data/v2/alerts", + "app-key": "appkey-123", + "auto-attributes": "", + "token": true, + "insecure-skip-verify": false, + }, + Redacted: []string{ + "token", + }, + }, + }, + }, + }, + { + section: "slack", + setDefaults: func(c *server.Config) { + cfg := &slack.Config{ + Global: true, + Default: true, + Username: slack.DefaultUsername, + } + + c.Slack = slack.Configs{ + *cfg, + } + }, + element: "", + expDefaultSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/"}, + Options: map[string]interface{}{ + "workspace": "", + "default": true, + "channel": "", + "enabled": false, + "global": true, + "icon-emoji": "", + "state-changes-only": false, + "token": false, + "url": false, + "username": "kapacitor", + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "insecure-skip-verify": false, + }, + Redacted: []string{ + "url", + "token", + }, + }}, + }, + expDefaultElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/"}, + Options: map[string]interface{}{ + "workspace": "", + "default": true, + "channel": "", + "enabled": false, + "global": true, + "icon-emoji": "", + "state-changes-only": false, + "url": false, + "token": false, + "username": "kapacitor", + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "insecure-skip-verify": false, + }, + Redacted: []string{ + "url", + "token", + }, + }, + updates: []updateAction{ + { + updateAction: client.ConfigUpdateAction{ + Add: map[string]interface{}{ + "workspace": "company_private", + "enabled": true, + "global": false, + "channel": "#general", + "username": slack.DefaultUsername, + "url": "http://slack.example.com/secret-token", + "token": "my_other_secret", + }, + }, + element: "company_private", + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/"}, + Options: map[string]interface{}{ + "workspace": "", + "default": true, + "channel": "", + "enabled": false, + "global": true, + "icon-emoji": "", + "state-changes-only": false, + "url": false, + "token": false, + "username": "kapacitor", + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "insecure-skip-verify": false, + }, + Redacted: []string{ + "url", + "token", + }, + }, + { + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/company_private"}, + Options: map[string]interface{}{ + "workspace": "company_private", + "channel": "#general", + "default": false, + "enabled": true, + "global": false, + "icon-emoji": "", + "state-changes-only": false, + "url": true, + "token": true, + "username": "kapacitor", + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "insecure-skip-verify": false, + }, + Redacted: []string{ + "url", + "token", + }, + }}, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/company_private"}, + Options: map[string]interface{}{ + "workspace": "company_private", + "channel": "#general", + "default": false, + "enabled": true, + "global": false, + "icon-emoji": "", + "state-changes-only": false, + "url": true, + "token": true, + "username": "kapacitor", + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "insecure-skip-verify": false, + }, + Redacted: []string{ + "url", + "token", + }, + }, + }, + { + updateAction: client.ConfigUpdateAction{ + Add: map[string]interface{}{ + "workspace": "company_public", + "enabled": true, + "global": false, + "channel": "#general", + "username": slack.DefaultUsername, + "url": "http://slack.example.com/secret-token", + }, + }, + element: "company_public", + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack"}, + Elements: []client.ConfigElement{ + { + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/"}, + Options: map[string]interface{}{ + "workspace": "", + "default": true, + "channel": "", + "enabled": false, + "global": true, + "icon-emoji": "", + "state-changes-only": false, + "url": false, + "token": false, + "username": "kapacitor", + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "insecure-skip-verify": false, + }, + Redacted: []string{ + "url", + "token", + }, + }, + { + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/company_private"}, + Options: map[string]interface{}{ + "workspace": "company_private", + "channel": "#general", + "default": false, + "enabled": true, + "global": false, + "icon-emoji": "", + "state-changes-only": false, + "url": true, + "token": true, + "username": "kapacitor", + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "insecure-skip-verify": false, + }, + Redacted: []string{ + "url", + "token", + }, + }, + { + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/company_public"}, + Options: map[string]interface{}{ + "workspace": "company_public", + "channel": "#general", + "default": false, + "enabled": true, + "global": false, + "icon-emoji": "", + "state-changes-only": false, + "url": true, + "token": false, + "username": "kapacitor", + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "insecure-skip-verify": false, + }, + Redacted: []string{ + "url", + "token", + }, + }, + }, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/company_public"}, + Options: map[string]interface{}{ + "workspace": "company_public", + "channel": "#general", + "default": false, + "enabled": true, + "global": false, + "icon-emoji": "", + "state-changes-only": false, + "url": true, + "token": false, + "username": "kapacitor", + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "insecure-skip-verify": false, + }, + Redacted: []string{ + "url", + "token", + }, + }, + }, + { + updateAction: client.ConfigUpdateAction{ + Set: map[string]interface{}{ + "enabled": false, + "username": "testbot", + }, + }, + element: "company_public", + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack"}, + Elements: []client.ConfigElement{ + { + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/"}, + Options: map[string]interface{}{ + "workspace": "", + "default": true, + "channel": "", + "enabled": false, + "global": true, + "icon-emoji": "", + "state-changes-only": false, + "url": false, + "token": false, + "username": "kapacitor", + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "insecure-skip-verify": false, + }, + Redacted: []string{ + "url", + "token", + }, + }, + { + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/company_private"}, + Options: map[string]interface{}{ + "workspace": "company_private", + "channel": "#general", + "default": false, + "enabled": true, + "global": false, + "icon-emoji": "", + "state-changes-only": false, + "url": true, + "token": true, + "username": "kapacitor", + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "insecure-skip-verify": false, + }, + Redacted: []string{ + "url", + "token", + }, + }, + { + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/company_public"}, + Options: map[string]interface{}{ + "workspace": "company_public", + "channel": "#general", + "default": false, + "enabled": false, + "global": false, + "icon-emoji": "", + "state-changes-only": false, + "url": true, + "token": false, + "username": "testbot", + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "insecure-skip-verify": false, + }, + Redacted: []string{ + "url", + "token", + }, + }, + }, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/company_public"}, + Options: map[string]interface{}{ + "workspace": "company_public", + "channel": "#general", + "default": false, + "enabled": false, + "global": false, + "icon-emoji": "", + "state-changes-only": false, + "url": true, + "token": false, + "username": "testbot", + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "insecure-skip-verify": false, + }, + Redacted: []string{ + "url", + "token", + }, + }, + }, + { + updateAction: client.ConfigUpdateAction{ + Delete: []string{"username"}, + }, + element: "company_public", + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack"}, + Elements: []client.ConfigElement{ + { + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/"}, + Options: map[string]interface{}{ + "workspace": "", + "default": true, + "channel": "", + "enabled": false, + "global": true, + "icon-emoji": "", + "state-changes-only": false, + "url": false, + "token": false, + "username": "kapacitor", + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "insecure-skip-verify": false, + }, + Redacted: []string{ + "url", + "token", + }, + }, + { + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/company_private"}, + Options: map[string]interface{}{ + "workspace": "company_private", + "channel": "#general", + "default": false, + "enabled": true, + "global": false, + "icon-emoji": "", + "state-changes-only": false, + "url": true, + "token": true, + "username": "kapacitor", + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "insecure-skip-verify": false, + }, + Redacted: []string{ + "url", + "token", + }, + }, + { + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/company_public"}, + Options: map[string]interface{}{ + "workspace": "company_public", + "channel": "#general", + "default": false, + "enabled": false, + "global": false, + "icon-emoji": "", + "state-changes-only": false, + "url": true, + "token": false, + "username": "", + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "insecure-skip-verify": false, + }, + Redacted: []string{ + "url", + "token", + }, + }, + }, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/slack/company_public"}, + Options: map[string]interface{}{ + "workspace": "company_public", + "channel": "#general", + "default": false, + "enabled": false, + "global": false, + "icon-emoji": "", + "state-changes-only": false, + "url": true, + "token": false, + "username": "", + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "insecure-skip-verify": false, + }, + Redacted: []string{ + "url", + "token", + }, + }, + }, + }, + }, + { + section: "snmptrap", + setDefaults: func(c *server.Config) { + c.SNMPTrap.Community = "test" + c.SNMPTrap.Retries = 2.0 + }, + expDefaultSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/snmptrap"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/snmptrap/"}, + Options: map[string]interface{}{ + "addr": "localhost:162", + "enabled": false, + "community": true, + "retries": 2.0, + }, + Redacted: []string{ + "community", + }, + }}, + }, + expDefaultElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/snmptrap/"}, + Options: map[string]interface{}{ + "addr": "localhost:162", + "enabled": false, + "community": true, + "retries": 2.0, + }, + Redacted: []string{ + "community", + }, + }, + updates: []updateAction{ + { + updateAction: client.ConfigUpdateAction{ + Set: map[string]interface{}{ + "enabled": true, + "addr": "snmptrap.example.com:162", + "community": "public", + "retries": 1.0, + }, + }, + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/snmptrap"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/snmptrap/"}, + Options: map[string]interface{}{ + "addr": "snmptrap.example.com:162", + "enabled": true, + "community": true, + "retries": 1.0, + }, + Redacted: []string{ + "community", + }, + }}, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/snmptrap/"}, + Options: map[string]interface{}{ + "addr": "snmptrap.example.com:162", + "enabled": true, + "community": true, + "retries": 1.0, + }, + Redacted: []string{ + "community", + }, + }, + }, + }, + }, + { + section: "swarm", + setDefaults: func(c *server.Config) { + c.Swarm = swarm.Configs{swarm.Config{ + Servers: []string{"http://localhost:80001"}, + }} + }, + expDefaultSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/swarm"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/swarm/"}, + Options: map[string]interface{}{ + "id": "", + "enabled": false, + "servers": []interface{}{"http://localhost:80001"}, + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "insecure-skip-verify": false, + }, + Redacted: nil, + }}, + }, + expDefaultElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/swarm/"}, + Options: map[string]interface{}{ + "id": "", + "enabled": false, + "servers": []interface{}{"http://localhost:80001"}, + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "insecure-skip-verify": false, + }, + Redacted: nil, + }, + updates: []updateAction{ + { + updateAction: client.ConfigUpdateAction{ + Set: map[string]interface{}{ + "enabled": true, + }, + }, + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/swarm"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/swarm/"}, + Options: map[string]interface{}{ + "id": "", + "enabled": true, + "servers": []interface{}{"http://localhost:80001"}, + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "insecure-skip-verify": false, + }, + Redacted: nil, + }}, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/swarm/"}, + Options: map[string]interface{}{ + "id": "", + "enabled": true, + "servers": []interface{}{"http://localhost:80001"}, + "ssl-ca": "", + "ssl-cert": "", + "ssl-key": "", + "insecure-skip-verify": false, + }, + Redacted: nil, + }, + }, + }, + }, + { + section: "talk", + setDefaults: func(c *server.Config) { + c.Talk.AuthorName = "Kapacitor" + }, + expDefaultSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/talk"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/talk/"}, + Options: map[string]interface{}{ + "enabled": false, + "url": false, + "author_name": "Kapacitor", + }, + Redacted: []string{ + "url", + }, + }}, + }, + expDefaultElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/talk/"}, + Options: map[string]interface{}{ + "enabled": false, + "url": false, + "author_name": "Kapacitor", + }, + Redacted: []string{ + "url", + }, + }, + updates: []updateAction{ + { + updateAction: client.ConfigUpdateAction{ + Set: map[string]interface{}{ + "enabled": true, + "url": "http://talk.example.com/secret-token", + }, + }, + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/talk"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/talk/"}, + Options: map[string]interface{}{ + "enabled": true, + "url": true, + "author_name": "Kapacitor", + }, + Redacted: []string{ + "url", + }, + }}, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/talk/"}, + Options: map[string]interface{}{ + "enabled": true, + "url": true, + "author_name": "Kapacitor", + }, + Redacted: []string{ + "url", + }, + }, + }, + }, + }, + { + section: "teams", + setDefaults: func(c *server.Config) { + c.Teams.ChannelURL = "http://teams.example.com/abcde" + }, + expDefaultSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/teams"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/teams/"}, + Options: map[string]interface{}{ + "enabled": false, + "global": false, + "state-changes-only": false, + "channel-url": "http://teams.example.com/abcde", + }, + }}, + }, + expDefaultElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/teams/"}, + Options: map[string]interface{}{ + "enabled": false, + "global": false, + "state-changes-only": false, + "channel-url": "http://teams.example.com/abcde", + }, + }, + updates: []updateAction{ + { + updateAction: client.ConfigUpdateAction{ + Set: map[string]interface{}{ + "global": true, + "state-changes-only": true, + "channel-url": "http://teams.example.com/12345", + }, + }, + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/teams"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/teams/"}, + Options: map[string]interface{}{ + "enabled": false, + "global": true, + "state-changes-only": true, + "channel-url": "http://teams.example.com/12345", + }, + }}, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/teams/"}, + Options: map[string]interface{}{ + "enabled": false, + "global": true, + "state-changes-only": true, + "channel-url": "http://teams.example.com/12345", + }, + }, + }, + }, + }, + { + section: "telegram", + setDefaults: func(c *server.Config) { + c.Telegram.ChatId = "kapacitor" + }, + expDefaultSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/telegram"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/telegram/"}, + Options: map[string]interface{}{ + "chat-id": "kapacitor", + "disable-notification": false, + "disable-web-page-preview": false, + "enabled": false, + "global": false, + "parse-mode": "", + "state-changes-only": false, + "token": false, + "url": telegram.DefaultTelegramURL, + }, + Redacted: []string{ + "token", + }, + }}, + }, + expDefaultElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/telegram/"}, + Options: map[string]interface{}{ + "chat-id": "kapacitor", + "disable-notification": false, + "disable-web-page-preview": false, + "enabled": false, + "global": false, + "parse-mode": "", + "state-changes-only": false, + "token": false, + "url": telegram.DefaultTelegramURL, + }, + Redacted: []string{ + "token", + }, + }, + updates: []updateAction{ + { + updateAction: client.ConfigUpdateAction{ + Set: map[string]interface{}{ + "enabled": true, + "token": "token", + }, + }, + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/telegram"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/telegram/"}, + Options: map[string]interface{}{ + "chat-id": "kapacitor", + "disable-notification": false, + "disable-web-page-preview": false, + "enabled": true, + "global": false, + "parse-mode": "", + "state-changes-only": false, + "token": true, + "url": telegram.DefaultTelegramURL, + }, + Redacted: []string{ + "token", + }, + }}, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/telegram/"}, + Options: map[string]interface{}{ + "chat-id": "kapacitor", + "disable-notification": false, + "disable-web-page-preview": false, + "enabled": true, + "global": false, + "parse-mode": "", + "state-changes-only": false, + "token": true, + "url": telegram.DefaultTelegramURL, + }, + Redacted: []string{ + "token", + }, + }, + }, + }, + }, + { + section: "victorops", + setDefaults: func(c *server.Config) { + c.VictorOps.RoutingKey = "test" + c.VictorOps.APIKey = "secret" + }, + expDefaultSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/victorops"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/victorops/"}, + Options: map[string]interface{}{ + "api-key": true, + "enabled": false, + "global": false, + "routing-key": "test", + "url": victorops.DefaultVictorOpsAPIURL, + "json-data": false, + }, + Redacted: []string{ + "api-key", + }, + }}, + }, + expDefaultElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/victorops/"}, + Options: map[string]interface{}{ + "api-key": true, + "enabled": false, + "global": false, + "routing-key": "test", + "url": victorops.DefaultVictorOpsAPIURL, + "json-data": false, + }, + Redacted: []string{ + "api-key", + }, + }, + updates: []updateAction{ + { + updateAction: client.ConfigUpdateAction{ + Set: map[string]interface{}{ + "api-key": "", + "global": true, + "json-data": true, + }, + }, + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/victorops"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/victorops/"}, + Options: map[string]interface{}{ + "api-key": false, + "enabled": false, + "global": true, + "routing-key": "test", + "url": victorops.DefaultVictorOpsAPIURL, + "json-data": true, + }, + Redacted: []string{ + "api-key", + }, + }}, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/victorops/"}, + Options: map[string]interface{}{ + "api-key": false, + "enabled": false, + "global": true, + "routing-key": "test", + "url": victorops.DefaultVictorOpsAPIURL, + "json-data": true, + }, + Redacted: []string{ + "api-key", + }, + }, + }, + }, + }, + { + section: "zenoss", + setDefaults: func(c *server.Config) { + c.Zenoss.URL = "https://tenant.zenoss.io:8080/zport/dmd/evconsole_router" + c.Zenoss.Collector = "Kapacitor" + }, + expDefaultSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/zenoss"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/zenoss/"}, + Options: map[string]interface{}{ + "enabled": false, + "global": false, + "state-changes-only": false, + "url": "https://tenant.zenoss.io:8080/zport/dmd/evconsole_router", + "username": "", + "password": false, + "action": "EventsRouter", + "method": "add_event", + "type": "rpc", + "tid": float64(1), + "collector": "Kapacitor", + "severity-map": map[string]interface{}{ + "ok": "Clear", "info": "Info", "warning": "Warning", "critical": "Critical", + }, + }, + Redacted: []string{ + "password", + }, + }}, + }, + expDefaultElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/zenoss/"}, + Options: map[string]interface{}{ + "enabled": false, + "global": false, + "state-changes-only": false, + "url": "https://tenant.zenoss.io:8080/zport/dmd/evconsole_router", + "username": "", + "password": false, + "action": "EventsRouter", + "method": "add_event", + "type": "rpc", + "tid": float64(1), + "collector": "Kapacitor", + "severity-map": map[string]interface{}{ + "ok": "Clear", "info": "Info", "warning": "Warning", "critical": "Critical", + }, + }, + Redacted: []string{ + "password", + }, + }, + updates: []updateAction{ + { + updateAction: client.ConfigUpdateAction{ + Set: map[string]interface{}{ + "enabled": true, + "url": "https://dev12345.zenoss.io:8080/zport/dmd/evconsole_router", + "username": "dev", + "password": "12345", + "action": "ScriptsRouter", + "method": "kapa_handler", + "severity-map": zenoss.SeverityMap{ + OK: 0, Info: 2, Warning: 3, Critical: 5, + }, + }, + }, + expSection: client.ConfigSection{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/zenoss"}, + Elements: []client.ConfigElement{{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/zenoss/"}, + Options: map[string]interface{}{ + "enabled": true, + "global": false, + "state-changes-only": false, + "url": "https://dev12345.zenoss.io:8080/zport/dmd/evconsole_router", + "username": "dev", + "password": true, + "action": "ScriptsRouter", + "method": "kapa_handler", + "type": "rpc", + "tid": float64(1), + "collector": "Kapacitor", + "severity-map": map[string]interface{}{ + "ok": float64(0), "info": float64(2), "warning": float64(3), "critical": float64(5), + }, + }, + Redacted: []string{ + "password", + }, + }}, + }, + expElement: client.ConfigElement{ + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/zenoss/"}, + Options: map[string]interface{}{ + "enabled": true, + "global": false, + "state-changes-only": false, + "url": "https://dev12345.zenoss.io:8080/zport/dmd/evconsole_router", + "username": "dev", + "password": true, + "action": "ScriptsRouter", + "method": "kapa_handler", + "type": "rpc", + "tid": float64(1), + "collector": "Kapacitor", + "severity-map": map[string]interface{}{ + "ok": float64(0), "info": float64(2), "warning": float64(3), "critical": float64(5), + }, + }, + Redacted: []string{ + "password", + }, + }, + }, + }, + }, + } + + compareElements := func(got, exp client.ConfigElement) error { + if got.Link != exp.Link { + return fmt.Errorf("elements have different links, got %v exp %v", got.Link, exp.Link) + } + if !cmp.Equal(exp.Options, got.Options) { + return fmt.Errorf("unexpected config option difference \n %s", cmp.Diff(exp.Options, got.Options)) + } + if len(got.Redacted) != len(exp.Redacted) { + return fmt.Errorf("unexpected element redacted lists: %s, \n%s", got.Redacted, cmp.Diff(got.Redacted, exp.Redacted)) + } + sort.Strings(got.Redacted) + sort.Strings(exp.Redacted) + for i := range exp.Redacted { + if got.Redacted[i] != exp.Redacted[i] { + return fmt.Errorf("unexpected element redacted lists: %s, \n%s", got.Redacted, cmp.Diff(got.Redacted, exp.Redacted)) + } + } + return nil + } + compareSections := func(got, exp client.ConfigSection) error { + if got.Link != exp.Link { + return fmt.Errorf("sections have different links, got %v exp %v", got.Link, exp.Link) + } + if len(got.Elements) != len(exp.Elements) { + return fmt.Errorf("sections are different lengths, got %d exp %d", len(got.Elements), len(exp.Elements)) + } + for i := range exp.Elements { + if err := compareElements(got.Elements[i], exp.Elements[i]); err != nil { + return errors.Wrapf(err, "section element %d are not equal", i) + } + } + return nil + } + + validate := func( + cli *client.Client, + section, + element string, + expSection client.ConfigSection, + expElement client.ConfigElement, + ) error { + // Get all sections + if config, err := cli.ConfigSections(); err != nil { + return errors.Wrap(err, "failed to get sections") + } else { + if err := compareSections(config.Sections[section], expSection); err != nil { + return fmt.Errorf("%s: %v", section, err) + } + } + // Get the specific section + sectionLink := cli.ConfigSectionLink(section) + if got, err := cli.ConfigSection(sectionLink); err != nil { + return err + } else { + if err := compareSections(got, expSection); err != nil { + return fmt.Errorf("%s: %v", section, err) + } + } + elementLink := cli.ConfigElementLink(section, element) + // Get the specific element + if got, err := cli.ConfigElement(elementLink); err != nil { + return err + } else { + if err := compareElements(got, expElement); err != nil { + return fmt.Errorf("%s/%s: %v", section, element, err) + } + } + return nil + } + + for i, tc := range testCases { + t.Run(fmt.Sprintf("%s/%s-%d", tc.section, tc.element, i), func(t *testing.T) { + // Create default config + c := NewConfig() + if tc.setDefaults != nil { + tc.setDefaults(c) + } + s := OpenServer(c) + cli := Client(s) + defer s.Close() + + if err := validate(cli, tc.section, tc.element, tc.expDefaultSection, tc.expDefaultElement); err != nil { + t.Errorf("unexpected defaults for %s/%s: %v", tc.section, tc.element, err) + } + + for i, ua := range tc.updates { + t.Run(ua.name, func(t *testing.T) { + link := cli.ConfigElementLink(tc.section, ua.element) + + if len(ua.updateAction.Add) > 0 || + len(ua.updateAction.Remove) > 0 { + link = cli.ConfigSectionLink(tc.section) + } + + if err := cli.ConfigUpdate(link, ua.updateAction); err != nil && (tc.expErr == nil || (tc.expErr.Error() != err.Error())) { + t.Errorf("unexepected result from update got:%q expected:%q", err, tc.expErr) + } else if err == nil && tc.expErr != nil { + t.Error("did not recieve expected error from update") + } + if err := validate(cli, tc.section, ua.element, ua.expSection, ua.expElement); err != nil { + t.Errorf("unexpected update result %d for %s/%s: %v", i, tc.section, ua.element, err) + } + }) + } + }) + } +} diff --git a/services/alert/service.go b/services/alert/service.go index 245345e11..7409c39ed 100644 --- a/services/alert/service.go +++ b/services/alert/service.go @@ -16,7 +16,6 @@ import ( "github.com/influxdata/kapacitor/services/alerta" "github.com/influxdata/kapacitor/services/bigpanda" "github.com/influxdata/kapacitor/services/discord" - "github.com/influxdata/kapacitor/services/hipchat" "github.com/influxdata/kapacitor/services/httpd" "github.com/influxdata/kapacitor/services/httppost" "github.com/influxdata/kapacitor/services/kafka" @@ -92,9 +91,6 @@ type Service struct { BigPandaService interface { Handler(bigpanda.HandlerConfig, ...keyvalue.T) (alert.Handler, error) } - HipChatService interface { - Handler(hipchat.HandlerConfig, ...keyvalue.T) alert.Handler - } KafkaService interface { Handler(kafka.HandlerConfig, ...keyvalue.T) (alert.Handler, error) } @@ -119,6 +115,9 @@ type Service struct { HTTPPostService interface { Handler(httppost.HandlerConfig, ...keyvalue.T) (alert.Handler, error) } + RemovedService interface { + Handle(event alert.Event) + } SensuService interface { Handler(sensu.HandlerConfig, ...keyvalue.T) (alert.Handler, error) } @@ -840,13 +839,7 @@ func (s *Service) createHandlerFromSpec(spec HandlerSpec) (handler, error) { h = NewExecHandler(c, handlerDiag) h = newExternalHandler(h) case "hipchat": - c := hipchat.HandlerConfig{} - err = decodeOptions(spec.Options, &c) - if err != nil { - return handler{}, err - } - h = s.HipChatService.Handler(c, ctx...) - h = newExternalHandler(h) + h = newExternalHandler(s.RemovedService) case "kafka": c := kafka.HandlerConfig{} err = decodeOptions(spec.Options, &c) diff --git a/services/diagnostic/handlers.go b/services/diagnostic/handlers.go index 4c2b1986f..f6c01976c 100644 --- a/services/diagnostic/handlers.go +++ b/services/diagnostic/handlers.go @@ -4,6 +4,7 @@ import ( "bytes" "errors" "fmt" + "github.com/influxdata/kapacitor/services/removed" "log" "runtime" "strconv" @@ -20,7 +21,6 @@ import ( "github.com/influxdata/kapacitor/services/bigpanda" "github.com/influxdata/kapacitor/services/discord" "github.com/influxdata/kapacitor/services/ec2" - "github.com/influxdata/kapacitor/services/hipchat" "github.com/influxdata/kapacitor/services/httppost" "github.com/influxdata/kapacitor/services/influxdb" "github.com/influxdata/kapacitor/services/k8s" @@ -398,22 +398,22 @@ func (h *AlertaHandler) Error(msg string, err error) { h.l.Error(msg, Error(err)) } -// HipChat handler -type HipChatHandler struct { - l Logger -} - -func (h *HipChatHandler) WithContext(ctx ...keyvalue.T) hipchat.Diagnostic { - fields := logFieldsFromContext(ctx) - - return &HipChatHandler{ - l: h.l.With(fields...), - } -} - -func (h *HipChatHandler) Error(msg string, err error) { - h.l.Error(msg, Error(err)) -} +//// HipChat handler +//type HipChatHandler struct { +// l Logger +//} +// +//func (h *HipChatHandler) WithContext(ctx ...keyvalue.T) hipchat.Diagnostic { +// fields := logFieldsFromContext(ctx) +// +// return &HipChatHandler{ +// l: h.l.With(fields...), +// } +//} +// +//func (h *HipChatHandler) Error(msg string, err error) { +// h.l.Error(msg, Error(err)) +//} // Kafka handler type KafkaHandler struct { @@ -830,6 +830,23 @@ func (h *HTTPPostHandler) WithContext(ctx ...keyvalue.T) httppost.Diagnostic { } } +// Removed handler +type RemovedHandler struct { + l Logger +} + +func (h *RemovedHandler) Error(msg string, err error, ctx ...keyvalue.T) { + Err(h.l, msg, err, ctx) +} + +func (h *RemovedHandler) WithContext(ctx ...keyvalue.T) removed.Diagnostic { + fields := logFieldsFromContext(ctx) + + return &RemovedHandler{ + l: h.l.With(fields...), + } +} + // Sensu handler type SensuHandler struct { diff --git a/services/diagnostic/service.go b/services/diagnostic/service.go index fae2aeeaa..66278df48 100644 --- a/services/diagnostic/service.go +++ b/services/diagnostic/service.go @@ -205,9 +205,9 @@ func (s *Service) NewAlertServiceHandler() *AlertServiceHandler { } } -func (s *Service) NewHipChatHandler() *HipChatHandler { - return &HipChatHandler{ - l: s.Logger.With(String("service", "hipchat")), +func (s *Service) NewRemovedHandler(name string) *RemovedHandler { + return &RemovedHandler{ + l: s.Logger.With(String("service", name), String("status", "removed")), } } diff --git a/services/hipchat/config.go b/services/hipchat/config.go deleted file mode 100644 index d2ba56d61..000000000 --- a/services/hipchat/config.go +++ /dev/null @@ -1,38 +0,0 @@ -package hipchat - -import ( - "net/url" - - "github.com/pkg/errors" -) - -type Config struct { - // Whether HipChat integration is enabled. - Enabled bool `toml:"enabled" override:"enabled"` - // The HipChat API URL. - URL string `toml:"url" override:"url"` - // The authentication token for this notification, can be overridden per alert. - // https://www.hipchat.com/docs/apiv2/auth for info on obtaining a token. - Token string `toml:"token" override:"token,redact"` - // The default room, can be overridden per alert. - Room string `toml:"room" override:"room"` - // Whether all alerts should automatically post to HipChat - Global bool `toml:"global" override:"global"` - // Whether all alerts should automatically use stateChangesOnly mode. - // Only applies if global is also set. - StateChangesOnly bool `toml:"state-changes-only" override:"state-changes-only"` -} - -func NewConfig() Config { - return Config{} -} - -func (c Config) Validate() error { - if c.Enabled && c.URL == "" { - return errors.New("must specify url") - } - if _, err := url.Parse(c.URL); err != nil { - return errors.Wrapf(err, "invalid url %q", c.URL) - } - return nil -} diff --git a/services/hipchat/service.go b/services/hipchat/service.go deleted file mode 100644 index aa7d925a2..000000000 --- a/services/hipchat/service.go +++ /dev/null @@ -1,204 +0,0 @@ -package hipchat - -import ( - "bytes" - "encoding/json" - "errors" - "fmt" - "io" - "io/ioutil" - "net/http" - "net/url" - "path" - "sync/atomic" - - "github.com/influxdata/kapacitor/alert" - "github.com/influxdata/kapacitor/keyvalue" -) - -type Diagnostic interface { - WithContext(ctx ...keyvalue.T) Diagnostic - Error(msg string, err error) -} - -type Service struct { - configValue atomic.Value - diag Diagnostic -} - -func NewService(c Config, d Diagnostic) *Service { - s := &Service{ - diag: d, - } - s.configValue.Store(c) - return s -} - -func (s *Service) Open() error { - return nil -} - -func (s *Service) Close() error { - return nil -} - -func (s *Service) config() Config { - return s.configValue.Load().(Config) -} - -func (s *Service) Update(newConfig []interface{}) error { - if l := len(newConfig); l != 1 { - return fmt.Errorf("expected only one new config object, got %d", l) - } - if c, ok := newConfig[0].(Config); !ok { - return fmt.Errorf("expected config object to be of type %T, got %T", c, newConfig[0]) - } else { - s.configValue.Store(c) - } - return nil -} - -func (s *Service) Global() bool { - c := s.config() - return c.Global -} - -func (s *Service) StateChangesOnly() bool { - c := s.config() - return c.StateChangesOnly -} - -type testOptions struct { - Room string `json:"room"` - Message string `json:"message"` - Level alert.Level `json:"level"` -} - -func (s *Service) TestOptions() interface{} { - c := s.config() - return &testOptions{ - Room: c.Room, - Message: "test hipchat message", - Level: alert.Critical, - } -} - -func (s *Service) Test(options interface{}) error { - o, ok := options.(*testOptions) - if !ok { - return fmt.Errorf("unexpected options type %T", options) - } - c := s.config() - return s.Alert(o.Room, c.Token, o.Message, o.Level) -} - -func (s *Service) Alert(room, token, message string, level alert.Level) error { - url, post, err := s.preparePost(room, token, message, level) - if err != nil { - return err - } - - resp, err := http.Post(url, "application/json", post) - if err != nil { - return err - } - defer resp.Body.Close() - if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNoContent { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return err - } - type response struct { - Error string `json:"error"` - } - r := &response{Error: fmt.Sprintf("failed to understand HipChat response. code: %d content: %s", resp.StatusCode, string(body))} - b := bytes.NewReader(body) - dec := json.NewDecoder(b) - dec.Decode(r) - return errors.New(r.Error) - } - return nil -} - -func (s *Service) preparePost(room, token, message string, level alert.Level) (string, io.Reader, error) { - c := s.config() - - if !c.Enabled { - return "", nil, errors.New("service is not enabled") - } - //Generate HipChat API URL including room and authentication token - if room == "" { - room = c.Room - } - if token == "" { - token = c.Token - } - - u, err := url.Parse(c.URL) - if err != nil { - return "", nil, err - } - u.Path = path.Join(u.Path, room, "notification") - v := url.Values{} - v.Set("auth_token", token) - u.RawQuery = v.Encode() - - var color string - switch level { - case alert.Warning: - color = "yellow" - case alert.Critical: - color = "red" - default: - color = "green" - } - - postData := make(map[string]interface{}) - postData["from"] = "kapacitor" - postData["color"] = color - postData["message"] = message - postData["notify"] = true - - var post bytes.Buffer - enc := json.NewEncoder(&post) - err = enc.Encode(postData) - if err != nil { - return "", nil, err - } - return u.String(), &post, nil -} - -type HandlerConfig struct { - // HipChat room in which to post messages. - // If empty uses the channel from the configuration. - Room string `mapstructure:"room"` - - // HipChat authentication token. - // If empty uses the token from the configuration. - Token string `mapstructure:"token"` -} - -type handler struct { - s *Service - c HandlerConfig - diag Diagnostic -} - -func (s *Service) Handler(c HandlerConfig, ctx ...keyvalue.T) alert.Handler { - return &handler{ - s: s, - c: c, - diag: s.diag.WithContext(ctx...), - } -} - -func (h *handler) Handle(event alert.Event) { - if err := h.s.Alert( - h.c.Room, - h.c.Token, - event.State.Message, - event.State.Level, - ); err != nil { - h.diag.Error("failed to send event to Alerta", err) - } -} diff --git a/services/removed/removed.go b/services/removed/removed.go new file mode 100644 index 000000000..945daca6c --- /dev/null +++ b/services/removed/removed.go @@ -0,0 +1,101 @@ +package removed + +import ( + "fmt" + "github.com/influxdata/kapacitor/alert" + "github.com/influxdata/kapacitor/keyvalue" +) + +// sort the Removed services +//func init() { +// sort.Strings(RemovedServices) +//} + +var ServiceNames = map[string]struct{}{ + HipChatName: struct{}{}, +} + +const HipChatName = "hipchat" + +var ErrHipChatRemoved = ErrRemoved(HipChatName) + +func ErrRemoved(name string) error { + return fmt.Errorf("Sorry but %s is no longer supported and has been removed", name) +} + +type Diagnostic interface { + WithContext(ctx ...keyvalue.T) Diagnostic + Error(msg string, err error, ctx ...keyvalue.T) +} + +type Service struct { + Name string + ObjectCFG any + diag Diagnostic +} + +func NewService(name string, cfg any, d Diagnostic) *Service { + return &Service{ + Name: name, + ObjectCFG: cfg, + diag: d, + } +} + +func (s *Service) Open() error { + return nil +} + +func (s *Service) Close() error { + return nil +} + +func (s *Service) Handle(event alert.Event) { + switch s.Name { + case HipChatName: + s.diag.Error("failed to send event because service is removed", ErrHipChatRemoved) + default: + panic(fmt.Sprintf("handler name %q is either not removed or not defined", s.Name)) + } +} + +func (s *Service) Update(_ []interface{}) error { + s.diag.Error(fmt.Sprintf("the %q service is removed", s.Name), ErrHipChatRemoved) + return nil +} + +type testOptions struct { + Name string +} + +func (s *Service) TestOptions() interface{} { + return &testOptions{ + Name: s.Name, + } +} + +func (s *Service) Test(options interface{}) error { + o, ok := options.(*testOptions) + if !ok { + return fmt.Errorf("unexpected options type %T", options) + } + switch o.Name { + case HipChatName: + return ErrHipChatRemoved + default: + panic(fmt.Sprintf("handler name %q is either not removed or not defined", s.Name)) + } +} + +type Config struct { + // Whether Removed integration is enabled. + Enabled bool `toml:"enabled" override:"enabled"` +} + +func NewConfig() Config { + return Config{} +} + +func (c Config) Validate() error { + return nil +} diff --git a/services/hipchat/hipchattest/hipchattest.go b/services/removed/removedtest/removedtest.go similarity index 80% rename from services/hipchat/hipchattest/hipchattest.go rename to services/removed/removedtest/removedtest.go index 111e83011..717e7af75 100644 --- a/services/hipchat/hipchattest/hipchattest.go +++ b/services/removed/removedtest/removedtest.go @@ -1,4 +1,4 @@ -package hipchattest +package removedtest import ( "encoding/json" @@ -47,12 +47,5 @@ func (s *Server) Close() { type Request struct { URL string - PostData PostData -} - -type PostData struct { - From string `json:"from"` - Message string `json:"message"` - Color string `json:"color"` - Notify bool `json:"notify"` + PostData map[string]any } diff --git a/task_master.go b/task_master.go index 723cc36fc..4a09a6065 100644 --- a/task_master.go +++ b/task_master.go @@ -24,7 +24,6 @@ import ( "github.com/influxdata/kapacitor/services/bigpanda" "github.com/influxdata/kapacitor/services/discord" ec2 "github.com/influxdata/kapacitor/services/ec2/client" - "github.com/influxdata/kapacitor/services/hipchat" "github.com/influxdata/kapacitor/services/httpd" "github.com/influxdata/kapacitor/services/httppost" k8s "github.com/influxdata/kapacitor/services/k8s/client" @@ -179,11 +178,6 @@ type TaskMaster struct { StateChangesOnly() bool Handler(telegram.HandlerConfig, ...keyvalue.T) alert.Handler } - HipChatService interface { - Global() bool - StateChangesOnly() bool - Handler(hipchat.HandlerConfig, ...keyvalue.T) alert.Handler - } KafkaService interface { Handler(kafka.HandlerConfig, ...keyvalue.T) (alert.Handler, error) } @@ -191,6 +185,9 @@ type TaskMaster struct { DefaultHandlerConfig() alerta.HandlerConfig Handler(alerta.HandlerConfig, ...keyvalue.T) (alert.Handler, error) } + RemovedService interface { + Handle(event2 alert.Event) + } SensuService interface { Handler(sensu.HandlerConfig, ...keyvalue.T) (alert.Handler, error) } @@ -321,7 +318,7 @@ func (tm *TaskMaster) New(id string) *TaskMaster { n.SlackService = tm.SlackService n.TelegramService = tm.TelegramService n.SNMPTrapService = tm.SNMPTrapService - n.HipChatService = tm.HipChatService + n.RemovedService = tm.RemovedService n.AlertaService = tm.AlertaService n.SensuService = tm.SensuService n.TalkService = tm.TalkService From b7178b387b78b2cdebc451fab1d6d52dc9fae915 Mon Sep 17 00:00:00 2001 From: "j. Emrys Landivar (docmerlin)" Date: Wed, 29 Jun 2022 11:28:14 -0500 Subject: [PATCH 2/5] WIP --- etc/kapacitor/kapacitor.conf | 21 ---------------- server/server_test.go | 47 ++++++++++++++++++------------------ 2 files changed, 23 insertions(+), 45 deletions(-) diff --git a/etc/kapacitor/kapacitor.conf b/etc/kapacitor/kapacitor.conf index f8839787d..5bce8aaeb 100644 --- a/etc/kapacitor/kapacitor.conf +++ b/etc/kapacitor/kapacitor.conf @@ -512,27 +512,6 @@ default-retention-policy = "" # meaning alerts will only be sent if the alert state changes. state-changes-only = false -[hipchat] - # Configure HipChat. - enabled = false - # The HipChat API URL. Replace subdomain with your - # HipChat subdomain. - # url = "https://subdomain.hipchat.com/v2/room" - # Visit https://www.hipchat.com/docs/apiv2 - # for information on obtaining your room id and - # authentication token. - # Default room for messages - room = "" - # Default authentication token - token = "" - # If true then all alerts will be sent to HipChat - # without explicitly marking them in the TICKscript. - global = false - # Only applies if global is true. - # Sets all alerts in state-changes-only mode, - # meaning alerts will only be sent if the alert state changes. - state-changes-only = false - [[kafka]] # Configure Kafka enabled = false diff --git a/server/server_test.go b/server/server_test.go index 478fe6af1..9ebd5aa21 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -5,6 +5,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/influxdata/kapacitor/services/removed" "github.com/influxdata/kapacitor/services/removed/removedtest" "io" "io/ioutil" @@ -6587,13 +6588,9 @@ func TestServer_ListServiceTests(t *testing.T) { }, }, { - Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/service-tests/hipchat"}, - Name: "hipchat", - Options: client.ServiceTestOptions{ - "room": "", - "message": "test hipchat message", - "level": "CRITICAL", - }, + Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/service-tests/hipchat"}, + Name: "hipchat", + Options: client.ServiceTestOptions{"Name": "hipchat"}, }, { Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/service-tests/httppost"}, @@ -7067,7 +7064,7 @@ func TestServer_DoServiceTest(t *testing.T) { options: client.ServiceTestOptions{}, exp: client.ServiceTestResult{ Success: false, - Message: "service is not enabled", + Message: removed.ErrHipChatRemoved.Error(), }, }, { @@ -7247,24 +7244,26 @@ func TestServer_DoServiceTest(t *testing.T) { } for _, tc := range testCases { - // Create default config - c := NewConfig() - if tc.setDefaults != nil { - tc.setDefaults(c) - } - s := OpenServer(c) - cli := Client(s) - defer s.Close() + t.Run(tc.service, func(t *testing.T) { + // Create default config + c := NewConfig() + if tc.setDefaults != nil { + tc.setDefaults(c) + } + s := OpenServer(c) + cli := Client(s) + defer s.Close() - tr, err := cli.DoServiceTest(cli.ServiceTestLink(tc.service), tc.options) - if err != nil { - t.Fatal(err) - } + tr, err := cli.DoServiceTest(cli.ServiceTestLink(tc.service), tc.options) + if err != nil { + t.Fatal(err) + } - if !reflect.DeepEqual(tr, tc.exp) { - t.Log("Options", tc.options) - t.Errorf("unexpected service test result for %s:\ngot\n%#v\nexp\n%#v\n", tc.service, tr, tc.exp) - } + if !reflect.DeepEqual(tr, tc.exp) { + t.Log("Options", tc.options) + t.Errorf("unexpected service test result for %s:\ngot\n%#v\nexp\n%#v\n", tc.service, tr, tc.exp) + } + }) } } From 530075699388ec57653419e3452f75b4329350e8 Mon Sep 17 00:00:00 2001 From: "j. Emrys Landivar (docmerlin)" Date: Mon, 25 Jul 2022 13:29:30 -0500 Subject: [PATCH 3/5] WIP --- build.sh | 2 +- test.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 1f453f460..df854882a 100755 --- a/build.sh +++ b/build.sh @@ -12,7 +12,7 @@ BUILD_NUM=${BUILD_NUM-$RANDOM} # Home dir of the docker user HOME_DIR=/root -GO_VERSION=1.17.1 +GO_VERSION=1.18.4 imagename=kapacitor-builder-img-$BUILD_NUM diff --git a/test.sh b/test.sh index 2c84ff681..96694e8c0 100755 --- a/test.sh +++ b/test.sh @@ -35,7 +35,7 @@ NO_UNCOMMITTED=${NO_UNCOMMITTED-false} # Home dir of the docker user HOME_DIR=/root # Go version -GO_VERSION=1.18 +GO_VERSION=1.18.4 # GOPATH GOPATH=/go From f40d2601bedbdd250e2e670f27a11304a66f4b97 Mon Sep 17 00:00:00 2001 From: "j. Emrys Landivar (docmerlin)" Date: Tue, 26 Jul 2022 15:23:42 -0500 Subject: [PATCH 4/5] WIP --- alert/topics.go | 3 +++ build.py | 10 ++++++++-- integrations/streamer_test.go | 2 +- server/server.go | 1 + server/server_test.go | 9 +++------ services/removed/removed.go | 12 +++++------- 6 files changed, 21 insertions(+), 16 deletions(-) diff --git a/alert/topics.go b/alert/topics.go index b34b0618e..6f1bb3c81 100644 --- a/alert/topics.go +++ b/alert/topics.go @@ -392,6 +392,9 @@ type bufHandler struct { } func newHandler(h Handler, bufferSize int) *bufHandler { + if h == nil { + panic("here h is nil") + } if bufferSize < MinimumEventBufferSize { bufferSize = DefaultEventBufferSize } diff --git a/build.py b/build.py index 0bdec206b..c51d24980 100755 --- a/build.py +++ b/build.py @@ -200,6 +200,8 @@ def run_tests(race, parallel, timeout, verbose): if timeout is not None: logging.info("Using timeout: {}".format(timeout)) + + test_command = "go test --failfast" if verbose: test_command += " -v" @@ -209,10 +211,14 @@ def run_tests(race, parallel, timeout, verbose): test_command += " -parallel {}".format(parallel) if timeout is not None: test_command += " -timeout {}".format(timeout) - test_command += " ./..." + test_command += " -p 1 {}" logging.info("Running tests...") logging.info("Test command: " + test_command) - output = run(test_command, printOutput=logging.getLogger().getEffectiveLevel() == logging.DEBUG) + packages = run("go list ./...", printOutput=logging.getLogger().getEffectiveLevel() == logging.DEBUG) + + for package in packages.split(): + if package.strip() != "": + run(test_command.format(package), printOutput=logging.getLogger().getEffectiveLevel() == logging.DEBUG) return True def package_udfs(version, dist_dir): diff --git a/integrations/streamer_test.go b/integrations/streamer_test.go index 4b2572f7e..cc4a73070 100644 --- a/integrations/streamer_test.go +++ b/integrations/streamer_test.go @@ -13812,7 +13812,7 @@ func testStreamerNoOutput( duration time.Duration, tmInit func(tm *kapacitor.TaskMaster), ) { - t.Helper() + //t.Helper() clock, et, replayErr, tm := testStreamer(t, name, script, tmInit) defer tm.Close() err := fastForwardTask(clock, et, replayErr, tm, duration) diff --git a/server/server.go b/server/server.go index ab5d2d8f1..3bc1fa6d4 100644 --- a/server/server.go +++ b/server/server.go @@ -958,6 +958,7 @@ func (s *Server) appendRemovedServices() { for name := range removed.ServiceNames { srv := removed.NewService(name, vars.Info, s.DiagService.NewRemovedHandler(name)) s.AppendService(name, srv) + s.AlertService.RemovedService = srv s.SetDynamicService(name, srv) } } diff --git a/server/server_test.go b/server/server_test.go index 9ebd5aa21..9efc28d8f 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -8024,13 +8024,10 @@ func TestServer_AlertHandlers(t *testing.T) { ts := ctxt.Value("server").(*removedtest.Server) ts.Close() got := ts.Requests() - exp := []removedtest.Request{{ - URL: "/1234567/notification?auth_token=testtoken1234567", - PostData: nil, - }} - if !reflect.DeepEqual(exp, got) { - return fmt.Errorf("unexpected hipchat request:\nexp\n%+v\ngot\n%+v\n", exp, got) + if len(got) != 0 { + fmt.Errorf("unexpected hipchat request, hipchat support has been removed:\ngot\n%+v\n", got) } + return nil }, }, diff --git a/services/removed/removed.go b/services/removed/removed.go index 945daca6c..d3cd8b287 100644 --- a/services/removed/removed.go +++ b/services/removed/removed.go @@ -4,19 +4,17 @@ import ( "fmt" "github.com/influxdata/kapacitor/alert" "github.com/influxdata/kapacitor/keyvalue" + "strings" ) -// sort the Removed services -//func init() { -// sort.Strings(RemovedServices) -//} - var ServiceNames = map[string]struct{}{ HipChatName: struct{}{}, } const HipChatName = "hipchat" +var HipChatLCName = strings.ToLower(HipChatName) + var ErrHipChatRemoved = ErrRemoved(HipChatName) func ErrRemoved(name string) error { @@ -51,7 +49,7 @@ func (s *Service) Close() error { } func (s *Service) Handle(event alert.Event) { - switch s.Name { + switch strings.ToLower(s.Name) { case HipChatName: s.diag.Error("failed to send event because service is removed", ErrHipChatRemoved) default: @@ -79,7 +77,7 @@ func (s *Service) Test(options interface{}) error { if !ok { return fmt.Errorf("unexpected options type %T", options) } - switch o.Name { + switch strings.ToLower(o.Name) { case HipChatName: return ErrHipChatRemoved default: From 937a977806d60aa7f908e28b25ca734ab84dee20 Mon Sep 17 00:00:00 2001 From: "j. Emrys Landivar (docmerlin)" Date: Tue, 26 Jul 2022 15:47:26 -0500 Subject: [PATCH 5/5] WIP --- checkfmt.sh | 2 +- integrations/batcher_test.go | 102 ++--- integrations/streamer_test.go | 775 ++++++++++++++++---------------- pipeline/tick/alert.go | 2 +- pipeline/udf_test.go | 20 +- server/config.go | 2 +- server/server.go | 5 +- server/server_test.go | 6 +- services/auth/service.go | 6 +- services/diagnostic/handlers.go | 19 +- services/httpd/mux.go | 2 +- services/influxdb/config.go | 2 +- services/influxdb/service.go | 2 +- services/removed/removed.go | 5 +- 14 files changed, 467 insertions(+), 483 deletions(-) diff --git a/checkfmt.sh b/checkfmt.sh index 320a66904..071d9e338 100755 --- a/checkfmt.sh +++ b/checkfmt.sh @@ -15,7 +15,7 @@ for file in $(go list -f '{{$dir := .Dir}}{{range .GoFiles}}{{printf "%s/%s\n" $ # Only print this once. HAS_FMT_ERR=1 echo 'Commit includes files that are not gofmt-ed' && \ - echo 'run "make fmt"' && \ + echo 'run "fmt ./..."' && \ echo '' fi echo "$FMT_OUT" # Print output and continue, so developers don't fix one file at a t diff --git a/integrations/batcher_test.go b/integrations/batcher_test.go index a1cf93c36..6555e560e 100644 --- a/integrations/batcher_test.go +++ b/integrations/batcher_test.go @@ -168,22 +168,22 @@ batch Tags: nil, Columns: []string{"time", "a", "b"}, Values: [][]interface{}{ - []interface{}{ + { time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), "bad", 0.0, }, - []interface{}{ + { time.Date(1971, 1, 1, 0, 0, 2, 0, time.UTC), "good", 0.0, }, - []interface{}{ + { time.Date(1971, 1, 1, 0, 0, 6, 0, time.UTC), "bad", 1.0, }, - []interface{}{ + { time.Date(1971, 1, 1, 0, 0, 8, 0, time.UTC), "bad", 0.0, @@ -638,7 +638,7 @@ batch Name: "cpu_usage_idle", Tags: map[string]string{"cpu": "cpu-total"}, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 28, 0, time.UTC), 10.0, }}, @@ -647,7 +647,7 @@ batch Name: "cpu_usage_idle", Tags: map[string]string{"cpu": "cpu0"}, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 28, 0, time.UTC), 10.0, }}, @@ -656,7 +656,7 @@ batch Name: "cpu_usage_idle", Tags: map[string]string{"cpu": "cpu1"}, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 28, 0, time.UTC), 10.0, }}, @@ -784,7 +784,7 @@ batch Name: "cpu_usage_idle", Tags: map[string]string{"cpu": "cpu-total"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 28, 0, time.UTC), 0.0, }}, @@ -793,7 +793,7 @@ batch Name: "cpu_usage_idle", Tags: map[string]string{"cpu": "cpu0"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 28, 0, time.UTC), 0.0, }}, @@ -802,7 +802,7 @@ batch Name: "cpu_usage_idle", Tags: map[string]string{"cpu": "cpu1"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 28, 0, time.UTC), 0.0, }}, @@ -836,7 +836,7 @@ batch Name: "cpu_usage_idle", Tags: map[string]string{"cpu": "cpu-total"}, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 28, 0, time.UTC), 0.0, }}, @@ -845,7 +845,7 @@ batch Name: "cpu_usage_idle", Tags: map[string]string{"cpu": "cpu0"}, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 28, 0, time.UTC), 0.0, }}, @@ -854,7 +854,7 @@ batch Name: "cpu_usage_idle", Tags: map[string]string{"cpu": "cpu1"}, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 28, 0, time.UTC), 0.0, }}, @@ -891,7 +891,7 @@ batch Name: "cpu_usage_idle", Tags: map[string]string{"cpu": "cpu-total"}, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 28, 0, time.UTC), 10.0, }}, @@ -900,7 +900,7 @@ batch Name: "cpu_usage_idle", Tags: map[string]string{"cpu": "cpu0"}, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 28, 0, time.UTC), 10.0, }}, @@ -909,7 +909,7 @@ batch Name: "cpu_usage_idle", Tags: map[string]string{"cpu": "cpu1"}, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 28, 0, time.UTC), 10.0, }}, @@ -946,7 +946,7 @@ batch Name: "cpu_usage_idle", Tags: map[string]string{"dc": "sfc"}, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 8, 0, time.UTC), 444.0, }}, @@ -980,7 +980,7 @@ batch Name: "cpu_usage_idle", Tags: map[string]string{"dc": "sfc", "cpu": "cpu-total"}, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 18, 0, time.UTC), 441.0, }}, @@ -1020,7 +1020,7 @@ batch Name: "cpu_usage_idle", Tags: map[string]string{"dc": "sfc"}, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 8, 0, time.UTC), 50.0, }}, @@ -1057,7 +1057,7 @@ batch Name: "cpu_usage_idle", Tags: nil, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 18, 0, time.UTC), 50.0, }}, @@ -1091,7 +1091,7 @@ batch Name: "cpu_usage_idle", Tags: map[string]string{"cpu": "cpu1"}, Columns: []string{"time", "max"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 18, 0, time.UTC), 95.98484848485191, }}, @@ -1125,7 +1125,7 @@ batch Name: "cpu_usage_user", Tags: map[string]string{"cpu": "cpu-total"}, Columns: []string{"time", "max"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 28, 0, time.UTC), 8.97243107764031, }}, @@ -1134,7 +1134,7 @@ batch Name: "cpu_usage_user", Tags: map[string]string{"cpu": "cpu0"}, Columns: []string{"time", "max"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 28, 0, time.UTC), 8.00000000002001, }}, @@ -1143,7 +1143,7 @@ batch Name: "cpu_usage_user", Tags: map[string]string{"cpu": "cpu1"}, Columns: []string{"time", "max"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 28, 0, time.UTC), 6.49999999996908, }}, @@ -1152,7 +1152,7 @@ batch Name: "cpu_usage_idle", Tags: map[string]string{"cpu": "cpu-total"}, Columns: []string{"time", "max"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 28, 0, time.UTC), 91.06416290101595, }}, @@ -1161,7 +1161,7 @@ batch Name: "cpu_usage_idle", Tags: map[string]string{"cpu": "cpu0"}, Columns: []string{"time", "max"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 28, 0, time.UTC), 85.08910891088406, }}, @@ -1170,7 +1170,7 @@ batch Name: "cpu_usage_idle", Tags: map[string]string{"cpu": "cpu1"}, Columns: []string{"time", "max"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 28, 0, time.UTC), 96.49999999996908, }}, @@ -1204,7 +1204,7 @@ batch Name: "cpu_usage_user", Tags: map[string]string{"cpu": "cpu-total"}, Columns: []string{"time", "max"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 18, 0, time.UTC), 9.90919811320221, }}, @@ -1213,7 +1213,7 @@ batch Name: "cpu_usage_user", Tags: map[string]string{"cpu": "cpu0"}, Columns: []string{"time", "max"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 18, 0, time.UTC), 5.93434343435388, }}, @@ -1222,7 +1222,7 @@ batch Name: "cpu_usage_user", Tags: map[string]string{"cpu": "cpu1"}, Columns: []string{"time", "max"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 18, 0, time.UTC), 6.54015887023496, }}, @@ -1231,7 +1231,7 @@ batch Name: "cpu_usage_idle", Tags: map[string]string{"cpu": "cpu-total"}, Columns: []string{"time", "max"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 18, 0, time.UTC), 91.01699558842134, }}, @@ -1240,7 +1240,7 @@ batch Name: "cpu_usage_idle", Tags: map[string]string{"cpu": "cpu0"}, Columns: []string{"time", "max"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 18, 0, time.UTC), 85.93434343435388, }}, @@ -1249,7 +1249,7 @@ batch Name: "cpu_usage_idle", Tags: map[string]string{"cpu": "cpu1"}, Columns: []string{"time", "max"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 18, 0, time.UTC), 95.98484848485191, }}, @@ -1805,7 +1805,7 @@ batch Name: "request_latency", Tags: map[string]string{"dc": "A", "first.service": "cart", "second.service": "auth"}, Columns: []string{"time", "ratio"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 15, 0, time.UTC), 3.0 / 2.0, }}, @@ -1814,7 +1814,7 @@ batch Name: "request_latency", Tags: map[string]string{"dc": "A", "first.service": "cart", "second.service": "log"}, Columns: []string{"time", "ratio"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 15, 0, time.UTC), 3.0 / 1.0, }}, @@ -1823,7 +1823,7 @@ batch Name: "request_latency", Tags: map[string]string{"dc": "A", "first.service": "auth", "second.service": "log"}, Columns: []string{"time", "ratio"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 15, 0, time.UTC), 2.0 / 1.0, }}, @@ -1832,7 +1832,7 @@ batch Name: "request_latency", Tags: map[string]string{"dc": "B", "first.service": "cart", "second.service": "auth"}, Columns: []string{"time", "ratio"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 15, 0, time.UTC), 7.0 / 6.0, }}, @@ -1841,7 +1841,7 @@ batch Name: "request_latency", Tags: map[string]string{"dc": "B", "first.service": "cart", "second.service": "log"}, Columns: []string{"time", "ratio"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 15, 0, time.UTC), 7.0 / 4.0, }}, @@ -1850,7 +1850,7 @@ batch Name: "request_latency", Tags: map[string]string{"dc": "B", "first.service": "auth", "second.service": "log"}, Columns: []string{"time", "ratio"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 15, 0, time.UTC), 6.0 / 4.0, }}, @@ -1885,7 +1885,7 @@ batch Name: "request_latency", Tags: map[string]string{"dc": "A", "other.service": "log", "auth.service": "auth"}, Columns: []string{"time", "ratio"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 15, 0, time.UTC), 2.0 / 1.0, }}, @@ -1894,7 +1894,7 @@ batch Name: "request_latency", Tags: map[string]string{"dc": "A", "other.service": "cart", "auth.service": "auth"}, Columns: []string{"time", "ratio"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 15, 0, time.UTC), 2.0 / 3.0, }}, @@ -1903,7 +1903,7 @@ batch Name: "request_latency", Tags: map[string]string{"dc": "B", "other.service": "log", "auth.service": "auth"}, Columns: []string{"time", "ratio"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 15, 0, time.UTC), 6.0 / 4.0, }}, @@ -1912,7 +1912,7 @@ batch Name: "request_latency", Tags: map[string]string{"dc": "B", "other.service": "cart", "auth.service": "auth"}, Columns: []string{"time", "ratio"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 15, 0, time.UTC), 6.0 / 7.0, }}, @@ -1947,7 +1947,7 @@ batch Name: "request_latency", Tags: map[string]string{"dc": "A", "first.service": "cart", "second.service": "auth", "third.service": "log"}, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 15, 0, time.UTC), 6.0, }}, @@ -1956,7 +1956,7 @@ batch Name: "request_latency", Tags: map[string]string{"dc": "B", "first.service": "cart", "second.service": "auth", "third.service": "log"}, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 15, 0, time.UTC), 17.0, }}, @@ -2006,7 +2006,7 @@ cpu0 { Name: "cpu_usage_idle", Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 28, 0, time.UTC), 10.0, }}, @@ -2056,7 +2056,7 @@ cpu0 { Name: "cpu_usage_idle", Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 28, 0, time.UTC), 10.0, }}, @@ -2106,7 +2106,7 @@ cpu0 { Name: "cpu_usage_idle", Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 28, 0, time.UTC), 10.0, }}, @@ -2157,7 +2157,7 @@ cpu0 { Name: "cpu_usage_idle", Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 28, 0, time.UTC), 10.0, }}, @@ -2209,7 +2209,7 @@ cpu0 { Name: "cpu_usage_idle", Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 28, 0, time.UTC), 876.0, }}, @@ -2262,7 +2262,7 @@ cpu0 { Name: "cpu_usage_idle", Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 28, 0, time.UTC), 1178.0, }}, diff --git a/integrations/streamer_test.go b/integrations/streamer_test.go index cc4a73070..4efe8bd81 100644 --- a/integrations/streamer_test.go +++ b/integrations/streamer_test.go @@ -7,8 +7,6 @@ import ( "encoding/json" "flag" "fmt" - "github.com/influxdata/kapacitor/services/removed" - "github.com/influxdata/kapacitor/services/removed/removedtest" "html" "io/ioutil" "math/rand" @@ -24,6 +22,9 @@ import ( "text/template" "time" + "github.com/influxdata/kapacitor/services/removed" + "github.com/influxdata/kapacitor/services/removed/removedtest" + "github.com/davecgh/go-spew/spew" "github.com/docker/docker/api/types/swarm" "github.com/google/go-cmp/cmp" @@ -150,7 +151,7 @@ stream Name: "packets", Tags: nil, Columns: []string{"time", "mean"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 1011.0, }}, @@ -179,27 +180,27 @@ func TestStream_ChangeDetect(t *testing.T) { Tags: nil, Columns: []string{"time", "value"}, Values: [][]interface{}{ - []interface{}{ + { time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), "bad", }, - []interface{}{ + { time.Date(1971, 1, 1, 0, 0, 1, 0, time.UTC), "good", }, - []interface{}{ + { time.Date(1971, 1, 1, 0, 0, 2, 0, time.UTC), "bad", }, - []interface{}{ + { time.Date(1971, 1, 1, 0, 0, 5, 0, time.UTC), "good", }, - []interface{}{ + { time.Date(1971, 1, 1, 0, 0, 7, 0, time.UTC), "bad", }, - []interface{}{ + { time.Date(1971, 1, 1, 0, 0, 8, 0, time.UTC), "good", }, @@ -228,22 +229,22 @@ func TestStream_ChangeDetect_Many(t *testing.T) { Tags: nil, Columns: []string{"time", "a", "b"}, Values: [][]interface{}{ - []interface{}{ + { time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), "bad", 0.0, }, - []interface{}{ + { time.Date(1971, 1, 1, 0, 0, 1, 0, time.UTC), "good", 0.0, }, - []interface{}{ + { time.Date(1971, 1, 1, 0, 0, 4, 0, time.UTC), "bad", 1.0, }, - []interface{}{ + { time.Date(1971, 1, 1, 0, 0, 5, 0, time.UTC), "bad", 0.0, @@ -274,7 +275,7 @@ stream Name: "packets", Tags: nil, Columns: []string{"time", "mean"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 11, 0, time.UTC), 1.0, }}, @@ -304,47 +305,47 @@ stream Tags: nil, Columns: []string{"time", "derivative", "value"}, Values: [][]interface{}{ - []interface{}{ + { time.Date(1971, 1, 1, 0, 0, 1, 0, time.UTC), 1.0, 1001.0, }, - []interface{}{ + { time.Date(1971, 1, 1, 0, 0, 3, 0, time.UTC), 1.0, 1003.0, }, - []interface{}{ + { time.Date(1971, 1, 1, 0, 0, 4, 0, time.UTC), 1.0, 1004.0, }, - []interface{}{ + { time.Date(1971, 1, 1, 0, 0, 5, 0, time.UTC), 2.0, 1006.0, }, - []interface{}{ + { time.Date(1971, 1, 1, 0, 0, 6, 0, time.UTC), 1.0, 1007.0, }, - []interface{}{ + { time.Date(1971, 1, 1, 0, 0, 7, 0, time.UTC), 0.0, 1007.0, }, - []interface{}{ + { time.Date(1971, 1, 1, 0, 0, 8, 0, time.UTC), 1.0, 1008.0, }, - []interface{}{ + { time.Date(1971, 1, 1, 0, 0, 9, 0, time.UTC), 1.0, 1009.0, }, - []interface{}{ + { time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 1.0, 1010.0, @@ -375,7 +376,7 @@ stream Name: "packets", Tags: nil, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 11, 0, time.UTC), 9.0, }}, @@ -405,7 +406,7 @@ stream Name: "packets", Tags: nil, Columns: []string{"time", "mean"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 11, 0, time.UTC), 10.0, }}, @@ -435,7 +436,7 @@ stream Name: "packets", Tags: nil, Columns: []string{"time", "mean"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 11, 0, time.UTC), 1.0, }}, @@ -464,7 +465,7 @@ stream Name: "packets", Tags: nil, Columns: []string{"time", "mean"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 11, 0, time.UTC), -99.7, }}, @@ -614,7 +615,7 @@ stream Name: "packets", Tags: nil, Columns: []string{"time", "max"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 11, 0, time.UTC), 4.0, }}, @@ -644,7 +645,7 @@ stream Name: "packets", Tags: nil, Columns: []string{"time", "max"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 11, 0, time.UTC), 5.0, }}, @@ -812,7 +813,7 @@ stream Name: "cpu", Tags: nil, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 11, 0, time.UTC), 3.0, }}, @@ -848,7 +849,7 @@ stream Name: "cpu", Tags: nil, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 3.0, }}, @@ -2472,7 +2473,7 @@ past Name: "cpu", Tags: nil, Columns: []string{"time", "current.count", "diff", "past.count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 5.0, 1.0, @@ -2524,7 +2525,7 @@ past Name: "cpu", Tags: nil, Columns: []string{"time", "current.count", "diff", "past.count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 5.0, 1.0, @@ -2576,7 +2577,7 @@ past Name: "cpu", Tags: nil, Columns: []string{"time", "current.count", "diff", "past.count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 5, 0, time.UTC), 5.0, 1.0, @@ -2628,7 +2629,7 @@ past Name: "cpu", Tags: nil, Columns: []string{"time", "current.count", "diff", "past.count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 5, 0, time.UTC), 5.0, 1.0, @@ -2660,7 +2661,7 @@ stream Name: "cpu", Tags: nil, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 10.0, }}, @@ -2686,7 +2687,7 @@ stream Name: "types", Tags: nil, Columns: []string{"time", "bool", "float", "int", "str"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), true, 84.0, @@ -2730,7 +2731,7 @@ stream Name: "types", Tags: nil, Columns: []string{"time", "neg", "pos", "value0", "value1"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), -1.0, 1.0, @@ -2760,7 +2761,7 @@ stream Name: "types", Tags: nil, Columns: []string{"time", "neg", "other", "pos", "value0"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), -1.0, 5.0, @@ -2790,7 +2791,7 @@ stream Name: "types", Tags: nil, Columns: []string{"time", "value0", "zero"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 0.0, 0.0, @@ -2819,7 +2820,7 @@ stream Name: "types", Tags: map[string]string{"value": "0"}, Columns: []string{"time"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), }}, }, @@ -2827,7 +2828,7 @@ stream Name: "types", Tags: map[string]string{"value": "1"}, Columns: []string{"time"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), }}, }, @@ -2855,7 +2856,7 @@ stream Name: "types", Tags: map[string]string{"value": "0"}, Columns: []string{"time", "another", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 2.0, "0", @@ -2865,7 +2866,7 @@ stream Name: "types", Tags: map[string]string{"value": "1"}, Columns: []string{"time", "another", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 2.0, "1", @@ -2895,7 +2896,7 @@ stream Name: "types", Tags: map[string]string{"value_tag": "0"}, Columns: []string{"time", "another", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 2.0, 0.0, @@ -2905,7 +2906,7 @@ stream Name: "types", Tags: map[string]string{"value_tag": "1"}, Columns: []string{"time", "another", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 2.0, 1.0, @@ -3076,7 +3077,7 @@ stream Name: "cpu", Tags: nil, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 57.0, }}, @@ -3106,7 +3107,7 @@ stream Name: "cpu", Tags: map[string]string{"cpu": "cpu-total", "host": "serverA"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 9.0, }}, @@ -3134,7 +3135,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 9.0, }}, @@ -3143,7 +3144,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverB"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 6.0, }}, @@ -3152,7 +3153,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverC"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 3.0, }}, @@ -3185,7 +3186,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 2, 0, time.UTC), 18.0, }}, @@ -3194,7 +3195,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverB"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 2, 0, time.UTC), 12.0, }}, @@ -3203,7 +3204,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverC"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 2, 0, time.UTC), 6.0, }}, @@ -3231,7 +3232,7 @@ stream Name: "cpu", Tags: nil, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 23.0, }}, @@ -3263,7 +3264,7 @@ func TestStream_HttpPost(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 97.1, }}, @@ -3277,7 +3278,7 @@ func TestStream_HttpPost(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 1, 0, time.UTC), 92.6, }}, @@ -3291,7 +3292,7 @@ func TestStream_HttpPost(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 2, 0, time.UTC), 95.6, }}, @@ -3305,7 +3306,7 @@ func TestStream_HttpPost(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 3, 0, time.UTC), 93.1, }}, @@ -3319,7 +3320,7 @@ func TestStream_HttpPost(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 4, 0, time.UTC), 92.6, }}, @@ -3333,7 +3334,7 @@ func TestStream_HttpPost(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 5, 0, time.UTC), 95.8, }}, @@ -3363,7 +3364,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 5, 0, time.UTC), 95.8, }}, @@ -3402,7 +3403,7 @@ func TestStream_HttpPost_URL_Template(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle", "cpu": "a"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 97.1, }}, @@ -3417,7 +3418,7 @@ func TestStream_HttpPost_URL_Template(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle", "cpu": "b"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 1, 0, time.UTC), 92.6, }}, @@ -3432,7 +3433,7 @@ func TestStream_HttpPost_URL_Template(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle", "cpu": "b"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 2, 0, time.UTC), 95.6, }}, @@ -3447,7 +3448,7 @@ func TestStream_HttpPost_URL_Template(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle", "cpu": "c"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 3, 0, time.UTC), 93.1, }}, @@ -3462,7 +3463,7 @@ func TestStream_HttpPost_URL_Template(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle", "cpu": "c"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 4, 0, time.UTC), 92.6, }}, @@ -3477,7 +3478,7 @@ func TestStream_HttpPost_URL_Template(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle", "cpu": "a"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 5, 0, time.UTC), 95.8, }}, @@ -3511,7 +3512,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle", "cpu": "a"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 5, 0, time.UTC), 95.8, }}, @@ -3554,7 +3555,7 @@ func TestStream_HttpPostEndpoint(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 97.1, }}, @@ -3568,7 +3569,7 @@ func TestStream_HttpPostEndpoint(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 1, 0, time.UTC), 92.6, }}, @@ -3582,7 +3583,7 @@ func TestStream_HttpPostEndpoint(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 2, 0, time.UTC), 95.6, }}, @@ -3596,7 +3597,7 @@ func TestStream_HttpPostEndpoint(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 3, 0, time.UTC), 93.1, }}, @@ -3610,7 +3611,7 @@ func TestStream_HttpPostEndpoint(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 4, 0, time.UTC), 92.6, }}, @@ -3624,7 +3625,7 @@ func TestStream_HttpPostEndpoint(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 5, 0, time.UTC), 95.8, }}, @@ -3656,7 +3657,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 5, 0, time.UTC), 95.8, }}, @@ -3735,7 +3736,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 5, 0, time.UTC), 95.8, }}, @@ -3882,7 +3883,7 @@ stream Name: "cpu", Tags: nil, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 10.0, }}, @@ -3912,7 +3913,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 5, 0, time.UTC), 5.0, }}, @@ -3921,7 +3922,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverB"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 5, 0, time.UTC), 5.0, }}, @@ -3930,7 +3931,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverC"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 5, 0, time.UTC), 1.0, }}, @@ -3960,7 +3961,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 5, 0, time.UTC), 5.0, }}, @@ -3969,7 +3970,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverB", "type": "idle"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 5, 0, time.UTC), 5.0, }}, @@ -3978,7 +3979,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverC", "type": "idle"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 5, 0, time.UTC), 1.0, }}, @@ -4009,7 +4010,7 @@ stream Name: "cpu", Tags: map[string]string{"type": "idle"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 5, 0, time.UTC), 11.0, }}, @@ -4040,7 +4041,7 @@ stream Name: "mock", Tags: map[string]string{"t": "A"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 2, 0, time.UTC), 4.0, }}, @@ -4049,7 +4050,7 @@ stream Name: "mock", Tags: map[string]string{"t": "B"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 2, 0, time.UTC), 4.0, }}, @@ -4082,7 +4083,7 @@ stream Name: "cpu", Tags: nil, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 10.0, }}, @@ -4120,7 +4121,7 @@ data Name: "cpu", Tags: nil, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 10.0, }}, @@ -4151,7 +4152,7 @@ stream Name: "cpu", Tags: nil, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 10.0, }}, @@ -4182,7 +4183,7 @@ stream Name: "cpu", Tags: nil, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 10.0, }}, @@ -4213,7 +4214,7 @@ stream Name: "errors", Tags: map[string]string{"service": "cartA"}, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 47.0, }}, @@ -4222,7 +4223,7 @@ stream Name: "errors", Tags: map[string]string{"service": "login"}, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 45.0, }}, @@ -4231,7 +4232,7 @@ stream Name: "errors", Tags: map[string]string{"service": "front"}, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 11, 0, time.UTC), 32.0, }}, @@ -4276,7 +4277,7 @@ byCpu Name: "cpu", Tags: map[string]string{"cpu": "cpu0", "host": "serverA"}, Columns: []string{"time", "mean"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 0.7823116704593873, }}, @@ -4285,7 +4286,7 @@ byCpu Name: "cpu", Tags: map[string]string{"cpu": "cpu1", "host": "serverA"}, Columns: []string{"time", "mean"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 0.7676074281820646, }}, @@ -4294,7 +4295,7 @@ byCpu Name: "cpu", Tags: map[string]string{"cpu": "cpu-total", "host": "serverA"}, Columns: []string{"time", "mean"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 1.0, }}, @@ -4325,7 +4326,7 @@ stream Name: "errors", Tags: map[string]string{"service": "cartA"}, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 47.0, }}, @@ -4334,7 +4335,7 @@ stream Name: "errors", Tags: map[string]string{"service": "login"}, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 45.0, }}, @@ -4343,7 +4344,7 @@ stream Name: "errors", Tags: map[string]string{"service": "front"}, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 11, 0, time.UTC), 32.0, }}, @@ -4352,7 +4353,7 @@ stream Name: "disk", Tags: map[string]string{"service": "sda"}, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 810.0, }}, @@ -4381,7 +4382,7 @@ stream Name: "request_latency", Tags: map[string]string{"dc": "A"}, Columns: []string{"time", "auth.server01.value", "auth.server02.value", "cart.server01.value", "cart.server02.value", "log.server01.value", "log.server02.value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 700.0, 702.0, @@ -4395,7 +4396,7 @@ stream Name: "request_latency", Tags: map[string]string{"dc": "B"}, Columns: []string{"time", "auth.server01.value", "auth.server02.value", "cart.server01.value", "cart.server02.value", "log.server01.value", "log.server02.value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 750.0, 752.0, @@ -4430,7 +4431,7 @@ stream Name: "request_latency", Tags: map[string]string{"dc": "A"}, Columns: []string{"time", "auth.server01", "auth.server02", "cart.server01", "cart.server02", "log.server01", "log.server02"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 700.0, 702.0, @@ -4444,7 +4445,7 @@ stream Name: "request_latency", Tags: map[string]string{"dc": "B"}, Columns: []string{"time", "auth.server01", "auth.server02", "cart.server01", "cart.server02", "log.server01", "log.server02"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 750.0, 752.0, @@ -4482,7 +4483,7 @@ stream Name: "request_latency", Tags: map[string]string{"dc": "A", "second.service": "log", "first.service": "auth"}, Columns: []string{"time", "ratio"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 7.0 / 6.0, }}, @@ -4491,7 +4492,7 @@ stream Name: "request_latency", Tags: map[string]string{"dc": "A", "second.service": "cart", "first.service": "auth"}, Columns: []string{"time", "ratio"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 7.0 / 8.0, }}, @@ -4500,7 +4501,7 @@ stream Name: "request_latency", Tags: map[string]string{"dc": "A", "second.service": "cart", "first.service": "log"}, Columns: []string{"time", "ratio"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 6.0 / 8.0, }}, @@ -4509,7 +4510,7 @@ stream Name: "request_latency", Tags: map[string]string{"dc": "B", "second.service": "log", "first.service": "auth"}, Columns: []string{"time", "ratio"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 7.5 / 6.5, }}, @@ -4518,7 +4519,7 @@ stream Name: "request_latency", Tags: map[string]string{"dc": "B", "second.service": "cart", "first.service": "auth"}, Columns: []string{"time", "ratio"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 7.5 / 8.5, }}, @@ -4527,7 +4528,7 @@ stream Name: "request_latency", Tags: map[string]string{"dc": "B", "second.service": "cart", "first.service": "log"}, Columns: []string{"time", "ratio"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 6.5 / 8.5, }}, @@ -4560,7 +4561,7 @@ stream Name: "request_latency", Tags: map[string]string{"dc": "A", "other.service": "log", "auth.service": "auth"}, Columns: []string{"time", "ratio"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 7.0 / 6.0, }}, @@ -4569,7 +4570,7 @@ stream Name: "request_latency", Tags: map[string]string{"dc": "A", "other.service": "cart", "auth.service": "auth"}, Columns: []string{"time", "ratio"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 7.0 / 8.0, }}, @@ -4578,7 +4579,7 @@ stream Name: "request_latency", Tags: map[string]string{"dc": "B", "other.service": "log", "auth.service": "auth"}, Columns: []string{"time", "ratio"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 7.5 / 6.5, }}, @@ -4587,7 +4588,7 @@ stream Name: "request_latency", Tags: map[string]string{"dc": "B", "other.service": "cart", "auth.service": "auth"}, Columns: []string{"time", "ratio"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 7.5 / 8.5, }}, @@ -4620,7 +4621,7 @@ stream Name: "request_latency", Tags: map[string]string{"dc": "A", "first.service": "auth", "second.service": "log", "third.service": "cart"}, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 2100.0, }}, @@ -4629,7 +4630,7 @@ stream Name: "request_latency", Tags: map[string]string{"dc": "B", "first.service": "auth", "second.service": "log", "third.service": "cart"}, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 2250.0, }}, @@ -4679,7 +4680,7 @@ errorCounts Name: "error_view", Tags: map[string]string{"service": "cartA"}, Columns: []string{"time", "error_percent", "errors.sum", "views.sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 0.01, 47.0, @@ -4690,7 +4691,7 @@ errorCounts Name: "error_view", Tags: map[string]string{"service": "login"}, Columns: []string{"time", "error_percent", "errors.sum", "views.sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 0.01, 45.0, @@ -4701,7 +4702,7 @@ errorCounts Name: "error_view", Tags: map[string]string{"service": "front"}, Columns: []string{"time", "error_percent", "errors.sum", "views.sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 0.01, 32.0, @@ -4809,7 +4810,7 @@ errorCounts Name: "error_view", Tags: map[string]string{"service": "cartA"}, Columns: []string{"time", "error_percent", "errors#sum", "views#sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 0.01, 47.0, @@ -4820,7 +4821,7 @@ errorCounts Name: "error_view", Tags: map[string]string{"service": "login"}, Columns: []string{"time", "error_percent", "errors#sum", "views#sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 0.01, 45.0, @@ -4831,7 +4832,7 @@ errorCounts Name: "error_view", Tags: map[string]string{"service": "front"}, Columns: []string{"time", "error_percent", "errors#sum", "views#sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 0.01, 32.0, @@ -4883,7 +4884,7 @@ errorCounts Name: "error_view", Tags: map[string]string{"service": "cartA"}, Columns: []string{"time", "error_percent", "errorssum", "viewssum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 0.01, 47.0, @@ -4894,7 +4895,7 @@ errorCounts Name: "error_view", Tags: map[string]string{"service": "login"}, Columns: []string{"time", "error_percent", "errorssum", "viewssum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 0.01, 45.0, @@ -4905,7 +4906,7 @@ errorCounts Name: "error_view", Tags: map[string]string{"service": "front"}, Columns: []string{"time", "error_percent", "errorssum", "viewssum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 0.01, 32.0, @@ -5101,7 +5102,7 @@ errorCounts Name: "error_view", Tags: map[string]string{"service": "cartA"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 7.0, }}, @@ -5110,7 +5111,7 @@ errorCounts Name: "error_view", Tags: map[string]string{"service": "login"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 7.0, }}, @@ -5119,7 +5120,7 @@ errorCounts Name: "error_view", Tags: map[string]string{"service": "front"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 8.0, }}, @@ -5162,7 +5163,7 @@ errorCounts Name: "error_view", Tags: map[string]string{"service": "cartA"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 7.0, }}, @@ -5171,7 +5172,7 @@ errorCounts Name: "error_view", Tags: map[string]string{"service": "login"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 7.0, }}, @@ -5180,7 +5181,7 @@ errorCounts Name: "error_view", Tags: map[string]string{"service": "front"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 8.0, }}, @@ -5225,7 +5226,7 @@ cpu Name: "magic", Tags: nil, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 10.0, }}, @@ -5275,7 +5276,7 @@ errorsByServiceGlobal Name: "dc_error_percent", Tags: map[string]string{"dc": "A", "service": "cartA"}, Columns: []string{"time", "dc.sum", "service.sum", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 15.0, 47.0, @@ -5286,7 +5287,7 @@ errorsByServiceGlobal Name: "dc_error_percent", Tags: map[string]string{"dc": "B", "service": "cartA"}, Columns: []string{"time", "dc.sum", "service.sum", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 32.0, 47.0, @@ -5297,7 +5298,7 @@ errorsByServiceGlobal Name: "dc_error_percent", Tags: map[string]string{"dc": "A", "service": "login"}, Columns: []string{"time", "dc.sum", "service.sum", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 15.0, 45.0, @@ -5308,7 +5309,7 @@ errorsByServiceGlobal Name: "dc_error_percent", Tags: map[string]string{"dc": "B", "service": "login"}, Columns: []string{"time", "dc.sum", "service.sum", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 23.0, 45.0, @@ -5319,7 +5320,7 @@ errorsByServiceGlobal Name: "dc_error_percent", Tags: map[string]string{"dc": "C", "service": "login"}, Columns: []string{"time", "dc.sum", "service.sum", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 7.0, 45.0, @@ -5330,7 +5331,7 @@ errorsByServiceGlobal Name: "dc_error_percent", Tags: map[string]string{"dc": "A", "service": "front"}, Columns: []string{"time", "dc.sum", "service.sum", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 19.0, 32.0, @@ -5341,7 +5342,7 @@ errorsByServiceGlobal Name: "dc_error_percent", Tags: map[string]string{"dc": "B", "service": "front"}, Columns: []string{"time", "dc.sum", "service.sum", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 13.0, 32.0, @@ -5393,7 +5394,7 @@ errorsByServiceGlobal Name: "loc_error_percent", Tags: map[string]string{"dc": "A", "service": "cartA", "rack": "0"}, Columns: []string{"time", "loc.sum", "service.sum", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 10.0, 47.0, @@ -5404,7 +5405,7 @@ errorsByServiceGlobal Name: "loc_error_percent", Tags: map[string]string{"dc": "A", "service": "cartA", "rack": "1"}, Columns: []string{"time", "loc.sum", "service.sum", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 5.0, 47.0, @@ -5415,7 +5416,7 @@ errorsByServiceGlobal Name: "loc_error_percent", Tags: map[string]string{"dc": "B", "service": "cartA", "rack": "0"}, Columns: []string{"time", "loc.sum", "service.sum", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 14.0, 47.0, @@ -5426,7 +5427,7 @@ errorsByServiceGlobal Name: "loc_error_percent", Tags: map[string]string{"dc": "B", "service": "cartA", "rack": "1"}, Columns: []string{"time", "loc.sum", "service.sum", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 18.0, 47.0, @@ -5437,7 +5438,7 @@ errorsByServiceGlobal Name: "loc_error_percent", Tags: map[string]string{"dc": "A", "service": "login", "rack": "0"}, Columns: []string{"time", "loc.sum", "service.sum", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 5.0, 45.0, @@ -5448,7 +5449,7 @@ errorsByServiceGlobal Name: "loc_error_percent", Tags: map[string]string{"dc": "A", "service": "login", "rack": "1"}, Columns: []string{"time", "loc.sum", "service.sum", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 10.0, 45.0, @@ -5459,7 +5460,7 @@ errorsByServiceGlobal Name: "loc_error_percent", Tags: map[string]string{"dc": "B", "service": "login", "rack": "0"}, Columns: []string{"time", "loc.sum", "service.sum", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 3.0, 45.0, @@ -5470,7 +5471,7 @@ errorsByServiceGlobal Name: "loc_error_percent", Tags: map[string]string{"dc": "B", "service": "login", "rack": "1"}, Columns: []string{"time", "loc.sum", "service.sum", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 20.0, 45.0, @@ -5481,7 +5482,7 @@ errorsByServiceGlobal Name: "loc_error_percent", Tags: map[string]string{"dc": "C", "service": "login", "rack": "0"}, Columns: []string{"time", "loc.sum", "service.sum", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 7.0, 45.0, @@ -5492,7 +5493,7 @@ errorsByServiceGlobal Name: "loc_error_percent", Tags: map[string]string{"dc": "A", "service": "front", "rack": "0"}, Columns: []string{"time", "loc.sum", "service.sum", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 9.0, 32.0, @@ -5503,7 +5504,7 @@ errorsByServiceGlobal Name: "loc_error_percent", Tags: map[string]string{"dc": "A", "service": "front", "rack": "1"}, Columns: []string{"time", "loc.sum", "service.sum", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 10.0, 32.0, @@ -5514,7 +5515,7 @@ errorsByServiceGlobal Name: "loc_error_percent", Tags: map[string]string{"dc": "B", "service": "front", "rack": "0"}, Columns: []string{"time", "loc.sum", "service.sum", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 4.0, 32.0, @@ -5525,7 +5526,7 @@ errorsByServiceGlobal Name: "loc_error_percent", Tags: map[string]string{"dc": "B", "service": "front", "rack": "1"}, Columns: []string{"time", "loc.sum", "service.sum", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 9.0, 32.0, @@ -5568,7 +5569,7 @@ building Name: "power_floor_percentage", Tags: map[string]string{"building": "shack", "floor": "1"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 7.0 / 30.0, }}, @@ -5577,7 +5578,7 @@ building Name: "power_floor_percentage", Tags: map[string]string{"building": "shack", "floor": "2"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 11.0 / 30.0, }}, @@ -5586,7 +5587,7 @@ building Name: "power_floor_percentage", Tags: map[string]string{"building": "shack", "floor": "3"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 12.0 / 30.0, }}, @@ -5595,7 +5596,7 @@ building Name: "power_floor_percentage", Tags: map[string]string{"building": "hut", "floor": "1"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 19.0 / 40.0, }}, @@ -5604,7 +5605,7 @@ building Name: "power_floor_percentage", Tags: map[string]string{"building": "hut", "floor": "2"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 21.0 / 40.0, }}, @@ -5822,7 +5823,7 @@ cpuT Name: "cpu_all", Tags: nil, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 20.0, }}, @@ -5866,7 +5867,7 @@ cpuT Name: "cpu_all", Tags: map[string]string{"cpu": "0"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 1, 0, time.UTC), 98.0, }}, @@ -5875,7 +5876,7 @@ cpuT Name: "cpu_all", Tags: map[string]string{"cpu": "1"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 2, 0, time.UTC), 92.0, }}, @@ -5884,7 +5885,7 @@ cpuT Name: "cpu_all", Tags: map[string]string{"cpu": "total"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 2, 0, time.UTC), 92.0, }}, @@ -5900,7 +5901,7 @@ cpuT Name: "cpu_all", Tags: map[string]string{"cpu": "0"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 5, 0, time.UTC), 92.0, }}, @@ -5909,7 +5910,7 @@ cpuT Name: "cpu_all", Tags: map[string]string{"cpu": "1"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 5, 0, time.UTC), 92.0, }}, @@ -5918,7 +5919,7 @@ cpuT Name: "cpu_all", Tags: map[string]string{"cpu": "total"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 4, 0, time.UTC), 93.0, }}, @@ -5934,7 +5935,7 @@ cpuT Name: "cpu_all", Tags: map[string]string{"cpu": "0"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 11, 0, time.UTC), 96.0, }}, @@ -5943,7 +5944,7 @@ cpuT Name: "cpu_all", Tags: map[string]string{"cpu": "1"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 9, 0, time.UTC), 93.0, }}, @@ -5952,7 +5953,7 @@ cpuT Name: "cpu_all", Tags: map[string]string{"cpu": "total"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 11, 0, time.UTC), 96.0, }}, @@ -5967,7 +5968,7 @@ cpuT Name: "cpu_all", Tags: map[string]string{"cpu": "0"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 12, 0, time.UTC), 95.0, }}, @@ -5976,7 +5977,7 @@ cpuT Name: "cpu_all", Tags: map[string]string{"cpu": "1"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 12, 0, time.UTC), 95.0, }}, @@ -5985,7 +5986,7 @@ cpuT Name: "cpu_all", Tags: map[string]string{"cpu": "total"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 11, 0, time.UTC), 96.0, }}, @@ -6020,7 +6021,7 @@ stream ` endTime := time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC) testCases := []testCase{ - testCase{ + { Method: "sum", ER: models.Result{ Series: models.Rows{ @@ -6028,7 +6029,7 @@ stream Name: "cpu", Tags: models.Tags{"host": "serverA"}, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 940.0, }}, @@ -6036,7 +6037,7 @@ stream }, }, }, - testCase{ + { Method: "count", ER: models.Result{ Series: models.Rows{ @@ -6044,7 +6045,7 @@ stream Name: "cpu", Tags: models.Tags{"host": "serverA"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 10.0, }}, @@ -6052,7 +6053,7 @@ stream }, }, }, - testCase{ + { Method: "distinct", ER: models.Result{ Series: models.Rows{ @@ -6090,7 +6091,7 @@ stream }, }, }, - testCase{ + { Method: "mean", ER: models.Result{ Series: models.Rows{ @@ -6098,7 +6099,7 @@ stream Name: "cpu", Tags: models.Tags{"host": "serverA"}, Columns: []string{"time", "mean"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 94.0, }}, @@ -6106,7 +6107,7 @@ stream }, }, }, - testCase{ + { Method: "median", ER: models.Result{ Series: models.Rows{ @@ -6114,7 +6115,7 @@ stream Name: "cpu", Tags: models.Tags{"host": "serverA"}, Columns: []string{"time", "median"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 94.0, }}, @@ -6122,7 +6123,7 @@ stream }, }, }, - testCase{ + { Method: "mode", ER: models.Result{ Series: models.Rows{ @@ -6130,7 +6131,7 @@ stream Name: "cpu", Tags: models.Tags{"host": "serverA"}, Columns: []string{"time", "mode"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 95.0, }}, @@ -6138,7 +6139,7 @@ stream }, }, }, - testCase{ + { Method: "min", UsePointTimes: true, ER: models.Result{ @@ -6147,7 +6148,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "min"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 1, 0, time.UTC), 91.0, }}, @@ -6155,7 +6156,7 @@ stream }, }, }, - testCase{ + { Method: "min", ER: models.Result{ Series: models.Rows{ @@ -6163,7 +6164,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "min"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 91.0, }}, @@ -6171,7 +6172,7 @@ stream }, }, }, - testCase{ + { Method: "max", UsePointTimes: true, ER: models.Result{ @@ -6180,7 +6181,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "max"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 98.0, }}, @@ -6188,7 +6189,7 @@ stream }, }, }, - testCase{ + { Method: "max", ER: models.Result{ Series: models.Rows{ @@ -6196,7 +6197,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "max"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 98.0, }}, @@ -6204,7 +6205,7 @@ stream }, }, }, - testCase{ + { Method: "spread", ER: models.Result{ Series: models.Rows{ @@ -6212,7 +6213,7 @@ stream Name: "cpu", Tags: models.Tags{"host": "serverA"}, Columns: []string{"time", "spread"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 7.0, }}, @@ -6220,7 +6221,7 @@ stream }, }, }, - testCase{ + { Method: "stddev", ER: models.Result{ Series: models.Rows{ @@ -6228,7 +6229,7 @@ stream Name: "cpu", Tags: models.Tags{"host": "serverA"}, Columns: []string{"time", "stddev"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 2.160246899469287, }}, @@ -6236,7 +6237,7 @@ stream }, }, }, - testCase{ + { Method: "first", UsePointTimes: true, ER: models.Result{ @@ -6245,7 +6246,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "first"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 98.0, }}, @@ -6253,7 +6254,7 @@ stream }, }, }, - testCase{ + { Method: "first", ER: models.Result{ Series: models.Rows{ @@ -6261,7 +6262,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "first"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 98.0, }}, @@ -6269,7 +6270,7 @@ stream }, }, }, - testCase{ + { Method: "last", UsePointTimes: true, ER: models.Result{ @@ -6278,7 +6279,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "last"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 9, 0, time.UTC), 95.0, }}, @@ -6286,7 +6287,7 @@ stream }, }, }, - testCase{ + { Method: "last", ER: models.Result{ Series: models.Rows{ @@ -6294,7 +6295,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "last"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 95.0, }}, @@ -6302,7 +6303,7 @@ stream }, }, }, - testCase{ + { Method: "percentile", Args: "'value', 50.0", ER: models.Result{ @@ -6311,7 +6312,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "percentile"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 93.0, }}, @@ -6319,7 +6320,7 @@ stream }, }, }, - testCase{ + { Method: "top", UsePointTimes: true, Args: "2, 'value'", @@ -6345,7 +6346,7 @@ stream }, }, }, - testCase{ + { Method: "top", Args: "2, 'value'", ER: models.Result{ @@ -6370,7 +6371,7 @@ stream }, }, }, - testCase{ + { Method: "bottom", UsePointTimes: true, Args: "3, 'value'", @@ -6401,7 +6402,7 @@ stream }, }, }, - testCase{ + { Method: "bottom", Args: "3, 'value'", ER: models.Result{ @@ -6482,7 +6483,7 @@ stream ` endTime := time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC) testCases := []testCase{ - testCase{ + { Method: "sum", ER: models.Result{ Series: models.Rows{ @@ -6490,7 +6491,7 @@ stream Name: "cpu", Tags: models.Tags{"host": "serverA"}, Columns: []string{"time", "sum"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 940.0, }}, @@ -6498,7 +6499,7 @@ stream }, }, }, - testCase{ + { Method: "count", ER: models.Result{ Series: models.Rows{ @@ -6506,7 +6507,7 @@ stream Name: "cpu", Tags: models.Tags{"host": "serverA"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 10.0, }}, @@ -6514,7 +6515,7 @@ stream }, }, }, - testCase{ + { Method: "distinct", ER: models.Result{ Series: models.Rows{ @@ -6552,7 +6553,7 @@ stream }, }, }, - testCase{ + { Method: "mean", ER: models.Result{ Series: models.Rows{ @@ -6560,7 +6561,7 @@ stream Name: "cpu", Tags: models.Tags{"host": "serverA"}, Columns: []string{"time", "mean"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 94.0, }}, @@ -6568,7 +6569,7 @@ stream }, }, }, - testCase{ + { Method: "median", ER: models.Result{ Series: models.Rows{ @@ -6576,7 +6577,7 @@ stream Name: "cpu", Tags: models.Tags{"host": "serverA"}, Columns: []string{"time", "median"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 94.0, }}, @@ -6584,7 +6585,7 @@ stream }, }, }, - testCase{ + { Method: "mode", ER: models.Result{ Series: models.Rows{ @@ -6592,7 +6593,7 @@ stream Name: "cpu", Tags: models.Tags{"host": "serverA"}, Columns: []string{"time", "mode"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 95.0, }}, @@ -6600,7 +6601,7 @@ stream }, }, }, - testCase{ + { Method: "min", UsePointTimes: true, ER: models.Result{ @@ -6609,7 +6610,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "min"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 1, 0, time.UTC), 91.0, }}, @@ -6617,7 +6618,7 @@ stream }, }, }, - testCase{ + { Method: "min", ER: models.Result{ Series: models.Rows{ @@ -6625,7 +6626,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "min"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 91.0, }}, @@ -6633,7 +6634,7 @@ stream }, }, }, - testCase{ + { Method: "max", UsePointTimes: true, ER: models.Result{ @@ -6642,7 +6643,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "max"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 98.0, }}, @@ -6650,7 +6651,7 @@ stream }, }, }, - testCase{ + { Method: "max", ER: models.Result{ Series: models.Rows{ @@ -6658,7 +6659,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "max"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 98.0, }}, @@ -6666,7 +6667,7 @@ stream }, }, }, - testCase{ + { Method: "spread", ER: models.Result{ Series: models.Rows{ @@ -6674,7 +6675,7 @@ stream Name: "cpu", Tags: models.Tags{"host": "serverA"}, Columns: []string{"time", "spread"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 7.0, }}, @@ -6682,7 +6683,7 @@ stream }, }, }, - testCase{ + { Method: "stddev", ER: models.Result{ Series: models.Rows{ @@ -6690,7 +6691,7 @@ stream Name: "cpu", Tags: models.Tags{"host": "serverA"}, Columns: []string{"time", "stddev"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 2.160246899469287, }}, @@ -6698,7 +6699,7 @@ stream }, }, }, - testCase{ + { Method: "first", UsePointTimes: true, ER: models.Result{ @@ -6707,7 +6708,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "first"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 98.0, }}, @@ -6715,7 +6716,7 @@ stream }, }, }, - testCase{ + { Method: "first", ER: models.Result{ Series: models.Rows{ @@ -6723,7 +6724,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "first"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 98.0, }}, @@ -6731,7 +6732,7 @@ stream }, }, }, - testCase{ + { Method: "last", UsePointTimes: true, ER: models.Result{ @@ -6740,7 +6741,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "last"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 9, 0, time.UTC), 95.0, }}, @@ -6748,7 +6749,7 @@ stream }, }, }, - testCase{ + { Method: "last", ER: models.Result{ Series: models.Rows{ @@ -6756,7 +6757,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "last"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 95.0, }}, @@ -6764,7 +6765,7 @@ stream }, }, }, - testCase{ + { Method: "percentile", Args: "'value', 50.0", ER: models.Result{ @@ -6773,7 +6774,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "percentile"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 93.0, }}, @@ -6781,7 +6782,7 @@ stream }, }, }, - testCase{ + { Method: "top", UsePointTimes: true, Args: "2, 'value'", @@ -6807,7 +6808,7 @@ stream }, }, }, - testCase{ + { Method: "top", Args: "2, 'value'", ER: models.Result{ @@ -6832,7 +6833,7 @@ stream }, }, }, - testCase{ + { Method: "bottom", UsePointTimes: true, Args: "3, 'value'", @@ -6863,7 +6864,7 @@ stream }, }, }, - testCase{ + { Method: "bottom", Args: "3, 'value'", ER: models.Result{ @@ -6941,7 +6942,7 @@ stream ` endTime := time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC) testCases := []testCase{ - testCase{ + { Method: "count", ER: models.Result{ Series: models.Rows{ @@ -6949,7 +6950,7 @@ stream Name: "cpu", Tags: models.Tags{"host": "serverA"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 10.0, }}, @@ -6957,7 +6958,7 @@ stream }, }, }, - testCase{ + { Method: "distinct", ER: models.Result{ Series: models.Rows{ @@ -6995,7 +6996,7 @@ stream }, }, }, - testCase{ + { Method: "first", UsePointTimes: true, ER: models.Result{ @@ -7004,7 +7005,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "first"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), "98", }}, @@ -7012,7 +7013,7 @@ stream }, }, }, - testCase{ + { Method: "first", ER: models.Result{ Series: models.Rows{ @@ -7020,7 +7021,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "first"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, "98", }}, @@ -7028,7 +7029,7 @@ stream }, }, }, - testCase{ + { Method: "last", UsePointTimes: true, ER: models.Result{ @@ -7037,7 +7038,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "last"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 9, 0, time.UTC), "95", }}, @@ -7045,7 +7046,7 @@ stream }, }, }, - testCase{ + { Method: "last", ER: models.Result{ Series: models.Rows{ @@ -7053,7 +7054,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "last"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, "95", }}, @@ -7110,7 +7111,7 @@ stream ` endTime := time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC) testCases := []testCase{ - testCase{ + { Method: "count", ER: models.Result{ Series: models.Rows{ @@ -7118,7 +7119,7 @@ stream Name: "cpu", Tags: models.Tags{"host": "serverA"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, 10.0, }}, @@ -7126,7 +7127,7 @@ stream }, }, }, - testCase{ + { Method: "distinct", ER: models.Result{ Series: models.Rows{ @@ -7148,7 +7149,7 @@ stream }, }, }, - testCase{ + { Method: "first", UsePointTimes: true, ER: models.Result{ @@ -7157,7 +7158,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "first"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), false, }}, @@ -7165,7 +7166,7 @@ stream }, }, }, - testCase{ + { Method: "first", ER: models.Result{ Series: models.Rows{ @@ -7173,7 +7174,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "first"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, false, }}, @@ -7181,7 +7182,7 @@ stream }, }, }, - testCase{ + { Method: "last", UsePointTimes: true, ER: models.Result{ @@ -7190,7 +7191,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "last"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 9, 0, time.UTC), true, }}, @@ -7198,7 +7199,7 @@ stream }, }, }, - testCase{ + { Method: "last", ER: models.Result{ Series: models.Rows{ @@ -7206,7 +7207,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "last"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ endTime, true, }}, @@ -7396,7 +7397,7 @@ stream Name: "cpu", Tags: nil, Columns: []string{"time", "customField"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 42.0, }}, @@ -7432,7 +7433,7 @@ func TestStream_Alert(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 10.0, }}, @@ -7481,7 +7482,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "level": "CRITICAL", "id": "kapacitor/cpu/serverA"}, Columns: []string{"time", "count", "id", "level", "msg"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 10.0, "kapacitor/cpu/serverA", @@ -7526,7 +7527,7 @@ func TestStream_Alert_NoRecoveries(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 7.0, }}, @@ -7549,7 +7550,7 @@ func TestStream_Alert_NoRecoveries(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 2, 0, time.UTC), 6.0, }}, @@ -7572,7 +7573,7 @@ func TestStream_Alert_NoRecoveries(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 3, 0, time.UTC), 7.0, }}, @@ -7595,7 +7596,7 @@ func TestStream_Alert_NoRecoveries(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 4, 0, time.UTC), 7.0, }}, @@ -7618,7 +7619,7 @@ func TestStream_Alert_NoRecoveries(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 5, 0, time.UTC), 8.0, }}, @@ -7641,7 +7642,7 @@ func TestStream_Alert_NoRecoveries(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 7, 0, time.UTC), 6.0, }}, @@ -7682,7 +7683,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 7, 0, time.UTC), 6.0, }}, @@ -7724,7 +7725,7 @@ func TestStream_Alert_WithReset_0(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 45.0, }}, @@ -7748,7 +7749,7 @@ func TestStream_Alert_WithReset_0(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 1, 0, time.UTC), 40.0, }}, @@ -7772,7 +7773,7 @@ func TestStream_Alert_WithReset_0(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 2, 0, time.UTC), 30.0, }}, @@ -7796,7 +7797,7 @@ func TestStream_Alert_WithReset_0(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 3, 0, time.UTC), 9.0, }}, @@ -7820,7 +7821,7 @@ func TestStream_Alert_WithReset_0(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 4, 0, time.UTC), 45.0, }}, @@ -7844,7 +7845,7 @@ func TestStream_Alert_WithReset_0(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 5, 0, time.UTC), 61.0, }}, @@ -7868,7 +7869,7 @@ func TestStream_Alert_WithReset_0(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 6, 0, time.UTC), 30.0, }}, @@ -7892,7 +7893,7 @@ func TestStream_Alert_WithReset_0(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 7, 0, time.UTC), 19.0, }}, @@ -7916,7 +7917,7 @@ func TestStream_Alert_WithReset_0(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 8, 0, time.UTC), 45.0, }}, @@ -7940,7 +7941,7 @@ func TestStream_Alert_WithReset_0(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 9, 0, time.UTC), 61.0, }}, @@ -7964,7 +7965,7 @@ func TestStream_Alert_WithReset_0(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 81.0, }}, @@ -7988,7 +7989,7 @@ func TestStream_Alert_WithReset_0(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 11, 0, time.UTC), 29.0, }}, @@ -8041,7 +8042,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "level": "OK", "id": "kapacitor/cpu/serverA", "type": "usage"}, Columns: []string{"time", "id", "level", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 11, 0, time.UTC), "kapacitor/cpu/serverA", "OK", @@ -8085,7 +8086,7 @@ func TestStream_Alert_WithReset_1(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 45.0, }}, @@ -8109,7 +8110,7 @@ func TestStream_Alert_WithReset_1(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 1, 0, time.UTC), 40.0, }}, @@ -8133,7 +8134,7 @@ func TestStream_Alert_WithReset_1(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 2, 0, time.UTC), 30.0, }}, @@ -8157,7 +8158,7 @@ func TestStream_Alert_WithReset_1(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 3, 0, time.UTC), 29.0, }}, @@ -8181,7 +8182,7 @@ func TestStream_Alert_WithReset_1(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 4, 0, time.UTC), 45.0, }}, @@ -8205,7 +8206,7 @@ func TestStream_Alert_WithReset_1(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 5, 0, time.UTC), 61.0, }}, @@ -8229,7 +8230,7 @@ func TestStream_Alert_WithReset_1(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 6, 0, time.UTC), 49.0, }}, @@ -8253,7 +8254,7 @@ func TestStream_Alert_WithReset_1(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 7, 0, time.UTC), 29.0, }}, @@ -8277,7 +8278,7 @@ func TestStream_Alert_WithReset_1(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 8, 0, time.UTC), 45.0, }}, @@ -8301,7 +8302,7 @@ func TestStream_Alert_WithReset_1(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 9, 0, time.UTC), 61.0, }}, @@ -8325,7 +8326,7 @@ func TestStream_Alert_WithReset_1(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 81.0, }}, @@ -8349,7 +8350,7 @@ func TestStream_Alert_WithReset_1(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 11, 0, time.UTC), 69.0, }}, @@ -8373,7 +8374,7 @@ func TestStream_Alert_WithReset_1(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 12, 0, time.UTC), 50.0, }}, @@ -8397,7 +8398,7 @@ func TestStream_Alert_WithReset_1(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 13, 0, time.UTC), 41.0, }}, @@ -8421,7 +8422,7 @@ func TestStream_Alert_WithReset_1(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "usage"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 14, 0, time.UTC), 25.0, }}, @@ -8474,7 +8475,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "level": "OK", "id": "kapacitor/cpu/serverA", "type": "usage"}, Columns: []string{"time", "id", "level", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 14, 0, time.UTC), "kapacitor/cpu/serverA", "OK", @@ -8519,7 +8520,7 @@ func TestStream_AlertDuration(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC), 9.0, }}, @@ -8543,7 +8544,7 @@ func TestStream_AlertDuration(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 2, 0, time.UTC), 8.0, }}, @@ -8567,7 +8568,7 @@ func TestStream_AlertDuration(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 4, 0, time.UTC), 6.0, }}, @@ -8591,7 +8592,7 @@ func TestStream_AlertDuration(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 5, 0, time.UTC), 8.0, }}, @@ -8615,7 +8616,7 @@ func TestStream_AlertDuration(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 8, 0, time.UTC), 3.0, }}, @@ -8656,7 +8657,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "duration", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 8, 0, time.UTC), float64(3 * time.Second), 3.0, @@ -9084,7 +9085,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 10.0, }}, @@ -10123,7 +10124,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 10.0, }}, @@ -10194,7 +10195,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 10.0, }}, @@ -10620,7 +10621,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 10.0, }}, @@ -10691,7 +10692,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA"}, Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 10.0, }}, @@ -11145,7 +11146,7 @@ func TestStream_AlertSigma(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "sigma", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 7, 0, time.UTC), 2.469916402324427, 16.0, @@ -11170,7 +11171,7 @@ func TestStream_AlertSigma(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "sigma", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 8, 0, time.UTC), 0.3053477916297622, 93.4, @@ -11233,7 +11234,7 @@ func TestStream_AlertComplexWhere(t *testing.T) { Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "value"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 7, 0, time.UTC), 16.0, }}, @@ -11680,7 +11681,7 @@ func TestStream_Autoscale(t *testing.T) { "resource": "serviceA", }, Columns: []string{"time", "new", "old"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 4, 0, time.UTC), 2.0, 1000.0, @@ -11695,7 +11696,7 @@ func TestStream_Autoscale(t *testing.T) { "resource": "serviceB", }, Columns: []string{"time", "new", "old"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 4, 0, time.UTC), 20.0, 1000.0, @@ -11714,7 +11715,7 @@ func TestStream_Autoscale(t *testing.T) { "resource": "serviceA", }, Columns: []string{"time", "new", "old"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 4, 0, time.UTC), 3.0, 500.0, @@ -11729,7 +11730,7 @@ func TestStream_Autoscale(t *testing.T) { "resource": "serviceB", }, Columns: []string{"time", "new", "old"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 4, 0, time.UTC), 20.0, 500.0, @@ -11785,7 +11786,7 @@ func TestStream_Autoscale(t *testing.T) { "deployment": "serviceA", }, Columns: []string{"time", "new", "old"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 4, 0, time.UTC), 2.0, 1000.0, @@ -11797,7 +11798,7 @@ func TestStream_Autoscale(t *testing.T) { "deployment": "serviceB", }, Columns: []string{"time", "new", "old"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 4, 0, time.UTC), 20.0, 1000.0, @@ -11813,7 +11814,7 @@ func TestStream_Autoscale(t *testing.T) { "deployment": "serviceA", }, Columns: []string{"time", "new", "old"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 4, 0, time.UTC), 3.0, 500.0, @@ -11825,7 +11826,7 @@ func TestStream_Autoscale(t *testing.T) { "deployment": "serviceB", }, Columns: []string{"time", "new", "old"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 4, 0, time.UTC), 20.0, 500.0, @@ -11875,12 +11876,12 @@ func TestStream_Autoscale(t *testing.T) { }, } expUpdatesByService := map[string][]int{ - "serviceA": []int{2, 1, 1000, 2}, - "serviceB": []int{20, 1, 1000, 20}, + "serviceA": {2, 1, 1000, 2}, + "serviceB": {20, 1, 1000, 20}, } expMinMaxUpdatesByService := map[string][]int{ - "serviceA": []int{3, 500, 3}, - "serviceB": []int{20, 3, 500, 20}, + "serviceA": {3, 500, 3}, + "serviceB": {20, 3, 500, 20}, } var scriptTmpl = ` @@ -11993,7 +11994,7 @@ stream { Name: "cpu", Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 4.0, }}, @@ -12125,7 +12126,7 @@ stream { Name: "cpu", Columns: []string{"time", "count"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 4.0, }}, @@ -12677,7 +12678,7 @@ stream Name: "cpu", Tags: map[string]string{"host": "serverA", "type": "idle"}, Columns: []string{"time", "another", "last"}, - Values: [][]interface{}{[]interface{}{ + Values: [][]interface{}{{ time.Date(1971, 1, 1, 0, 0, 10, 0, time.UTC), 5.0, 95.3, @@ -12818,21 +12819,21 @@ stream // Expected Stats es := map[string]map[string]interface{}{ - "stream0": map[string]interface{}{ + "stream0": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "from1": map[string]interface{}{ + "from1": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "derivative2": map[string]interface{}{ + "derivative2": { "emitted": int64(0), "working_cardinality": int64(9), "avg_exec_time_ns": int64(0), @@ -12856,21 +12857,21 @@ stream // Expected Stats es := map[string]map[string]interface{}{ - "stream0": map[string]interface{}{ + "stream0": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "from1": map[string]interface{}{ + "from1": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "where2": map[string]interface{}{ + "where2": { "emitted": int64(0), "working_cardinality": int64(9), "avg_exec_time_ns": int64(0), @@ -12894,21 +12895,21 @@ stream // Expected Stats es := map[string]map[string]interface{}{ - "stream0": map[string]interface{}{ + "stream0": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "from1": map[string]interface{}{ + "from1": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "sample2": map[string]interface{}{ + "sample2": { "emitted": int64(0), "working_cardinality": int64(9), "avg_exec_time_ns": int64(0), @@ -12934,21 +12935,21 @@ stream // Expected Stats es := map[string]map[string]interface{}{ - "stream0": map[string]interface{}{ + "stream0": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "from1": map[string]interface{}{ + "from1": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "window2": map[string]interface{}{ + "window2": { "emitted": int64(0), "working_cardinality": int64(9), "avg_exec_time_ns": int64(0), @@ -12973,21 +12974,21 @@ stream // Expected Stats es := map[string]map[string]interface{}{ - "stream0": map[string]interface{}{ + "stream0": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "from1": map[string]interface{}{ + "from1": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "max2": map[string]interface{}{ + "max2": { "emitted": int64(0), "working_cardinality": int64(9), "avg_exec_time_ns": int64(0), @@ -13015,28 +13016,28 @@ stream // Expected Stats es := map[string]map[string]interface{}{ - "stream0": map[string]interface{}{ + "stream0": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "from1": map[string]interface{}{ + "from1": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "window2": map[string]interface{}{ + "window2": { "emitted": int64(81), "working_cardinality": int64(9), "avg_exec_time_ns": int64(0), "errors": int64(0), "collected": int64(90), }, - "max3": map[string]interface{}{ + "max3": { "emitted": int64(0), "working_cardinality": int64(9), "avg_exec_time_ns": int64(0), @@ -13061,21 +13062,21 @@ stream // Expected Stats es := map[string]map[string]interface{}{ - "stream0": map[string]interface{}{ + "stream0": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "from1": map[string]interface{}{ + "from1": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "eval2": map[string]interface{}{ + "eval2": { "emitted": int64(0), "working_cardinality": int64(9), "avg_exec_time_ns": int64(0), @@ -13100,21 +13101,21 @@ stream // Expected Stats es := map[string]map[string]interface{}{ - "stream0": map[string]interface{}{ + "stream0": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "from1": map[string]interface{}{ + "from1": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "flatten2": map[string]interface{}{ + "flatten2": { "emitted": int64(0), "working_cardinality": int64(9), "avg_exec_time_ns": int64(0), @@ -13140,28 +13141,28 @@ stream // Expected Stats es := map[string]map[string]interface{}{ - "stream0": map[string]interface{}{ + "stream0": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "from1": map[string]interface{}{ + "from1": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "window2": map[string]interface{}{ + "window2": { "emitted": int64(9), "working_cardinality": int64(1), "avg_exec_time_ns": int64(0), "errors": int64(0), "collected": int64(90), }, - "groupby3": map[string]interface{}{ + "groupby3": { "emitted": int64(0), "working_cardinality": int64(9), "avg_exec_time_ns": int64(0), @@ -13185,21 +13186,21 @@ stream // Expected Stats es := map[string]map[string]interface{}{ - "stream0": map[string]interface{}{ + "stream0": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "from1": map[string]interface{}{ + "from1": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "alert2": map[string]interface{}{ + "alert2": { "emitted": int64(0), "working_cardinality": int64(9), "avg_exec_time_ns": int64(0), @@ -13229,21 +13230,21 @@ stream // Expected Stats es := map[string]map[string]interface{}{ - "stream0": map[string]interface{}{ + "stream0": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "from1": map[string]interface{}{ + "from1": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "http_out2": map[string]interface{}{ + "http_out2": { "emitted": int64(0), "working_cardinality": int64(9), "avg_exec_time_ns": int64(0), @@ -13269,21 +13270,21 @@ stream // Expected Stats es := map[string]map[string]interface{}{ - "stream0": map[string]interface{}{ + "stream0": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "from1": map[string]interface{}{ + "from1": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "k8s_autoscale2": map[string]interface{}{ + "k8s_autoscale2": { "emitted": int64(0), "working_cardinality": int64(9), "avg_exec_time_ns": int64(0), @@ -13345,28 +13346,28 @@ s2|join(s1) // Expected Stats es := map[string]map[string]interface{}{ - "stream0": map[string]interface{}{ + "stream0": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(180), }, - "from1": map[string]interface{}{ + "from1": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "from2": map[string]interface{}{ + "from2": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "join4": map[string]interface{}{ + "join4": { "emitted": int64(0), "working_cardinality": int64(10), "avg_exec_time_ns": int64(0), @@ -13391,21 +13392,21 @@ var s1 = stream // Expected Stats es := map[string]map[string]interface{}{ - "stream0": map[string]interface{}{ + "stream0": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "from1": map[string]interface{}{ + "from1": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "combine2": map[string]interface{}{ + "combine2": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(9), @@ -13434,49 +13435,49 @@ stream // Expected Stats es := map[string]map[string]interface{}{ - "stream0": map[string]interface{}{ + "stream0": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "from1": map[string]interface{}{ + "from1": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(0), "collected": int64(90), "emitted": int64(90), }, - "where2": map[string]interface{}{ + "where2": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(9), "collected": int64(90), "emitted": int64(90), }, - "eval3": map[string]interface{}{ + "eval3": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(9), "collected": int64(90), "emitted": int64(90), }, - "where4": map[string]interface{}{ + "where4": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(9), "collected": int64(90), "emitted": int64(30), }, - "derivative5": map[string]interface{}{ + "derivative5": { "avg_exec_time_ns": int64(0), "errors": int64(0), "working_cardinality": int64(3), "collected": int64(30), "emitted": int64(27), }, - "alert6": map[string]interface{}{ + "alert6": { "emitted": int64(0), "working_cardinality": int64(3), "avg_exec_time_ns": int64(0), diff --git a/pipeline/tick/alert.go b/pipeline/tick/alert.go index 9f0f827a9..f9a4a724e 100644 --- a/pipeline/tick/alert.go +++ b/pipeline/tick/alert.go @@ -264,7 +264,7 @@ func (n *AlertNode) Build(a *pipeline.AlertNode) (ast.Node, error) { Dot("recipients", args(h.RecipientsList)...) } - for _ = range a.TalkHandlers { + for range a.TalkHandlers { n.Dot("talk") } diff --git a/pipeline/udf_test.go b/pipeline/udf_test.go index ee2b12672..30dcd1e98 100644 --- a/pipeline/udf_test.go +++ b/pipeline/udf_test.go @@ -153,27 +153,27 @@ func TestUDFNode_UnmarshalJSON(t *testing.T) { }`, want: &UDFNode{ options: map[string]*agent.OptionInfo{ - "mph": &agent.OptionInfo{ + "mph": { ValueTypes: []agent.ValueType{ agent.ValueType_INT, }, }, - "gigawatts": &agent.OptionInfo{ + "gigawatts": { ValueTypes: []agent.ValueType{ agent.ValueType_DOUBLE, }, }, - "nearClockTower": &agent.OptionInfo{ + "nearClockTower": { ValueTypes: []agent.ValueType{ agent.ValueType_BOOL, }, }, - "martySays": &agent.OptionInfo{ + "martySays": { ValueTypes: []agent.ValueType{ agent.ValueType_STRING, }, }, - "future": &agent.OptionInfo{ + "future": { ValueTypes: []agent.ValueType{ agent.ValueType_DURATION, agent.ValueType_STRING, @@ -251,27 +251,27 @@ func TestUDFNode_UnmarshalJSON(t *testing.T) { t.Run(tt.name, func(t *testing.T) { u := &UDFNode{ options: map[string]*agent.OptionInfo{ - "mph": &agent.OptionInfo{ + "mph": { ValueTypes: []agent.ValueType{ agent.ValueType_INT, }, }, - "gigawatts": &agent.OptionInfo{ + "gigawatts": { ValueTypes: []agent.ValueType{ agent.ValueType_DOUBLE, }, }, - "nearClockTower": &agent.OptionInfo{ + "nearClockTower": { ValueTypes: []agent.ValueType{ agent.ValueType_BOOL, }, }, - "martySays": &agent.OptionInfo{ + "martySays": { ValueTypes: []agent.ValueType{ agent.ValueType_STRING, }, }, - "future": &agent.OptionInfo{ + "future": { ValueTypes: []agent.ValueType{ agent.ValueType_DURATION, agent.ValueType_STRING, diff --git a/server/config.go b/server/config.go index f44b53896..80d416ef7 100644 --- a/server/config.go +++ b/server/config.go @@ -3,7 +3,6 @@ package server import ( "encoding" "fmt" - "github.com/influxdata/kapacitor/services/removed" "os" "os/user" "path/filepath" @@ -44,6 +43,7 @@ import ( "github.com/influxdata/kapacitor/services/pagerduty" "github.com/influxdata/kapacitor/services/pagerduty2" "github.com/influxdata/kapacitor/services/pushover" + "github.com/influxdata/kapacitor/services/removed" "github.com/influxdata/kapacitor/services/replay" "github.com/influxdata/kapacitor/services/reporting" "github.com/influxdata/kapacitor/services/scraper" diff --git a/server/server.go b/server/server.go index 3bc1fa6d4..9cea3c728 100644 --- a/server/server.go +++ b/server/server.go @@ -4,7 +4,6 @@ package server import ( "crypto/tls" "fmt" - "github.com/influxdata/kapacitor/services/removed" "io/ioutil" "os" "path/filepath" @@ -13,8 +12,6 @@ import ( "sync" "time" - "go.uber.org/zap" - "github.com/influxdata/influxdb/query" "github.com/influxdata/influxdb/services/collectd" "github.com/influxdata/influxdb/services/graphite" @@ -57,6 +54,7 @@ import ( "github.com/influxdata/kapacitor/services/pagerduty" "github.com/influxdata/kapacitor/services/pagerduty2" "github.com/influxdata/kapacitor/services/pushover" + "github.com/influxdata/kapacitor/services/removed" "github.com/influxdata/kapacitor/services/replay" "github.com/influxdata/kapacitor/services/reporting" "github.com/influxdata/kapacitor/services/scraper" @@ -85,6 +83,7 @@ import ( "github.com/influxdata/kapacitor/uuid" "github.com/influxdata/kapacitor/waiter" "github.com/pkg/errors" + "go.uber.org/zap" "go.uber.org/zap/zapcore" ) diff --git a/server/server_test.go b/server/server_test.go index 9efc28d8f..eb2c691bd 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -5,8 +5,6 @@ import ( "context" "encoding/json" "fmt" - "github.com/influxdata/kapacitor/services/removed" - "github.com/influxdata/kapacitor/services/removed/removedtest" "io" "io/ioutil" "math/rand" @@ -59,6 +57,8 @@ import ( "github.com/influxdata/kapacitor/services/pagerduty/pagerdutytest" "github.com/influxdata/kapacitor/services/pagerduty2/pagerduty2test" "github.com/influxdata/kapacitor/services/pushover/pushovertest" + "github.com/influxdata/kapacitor/services/removed" + "github.com/influxdata/kapacitor/services/removed/removedtest" "github.com/influxdata/kapacitor/services/sensu/sensutest" "github.com/influxdata/kapacitor/services/servicenow" "github.com/influxdata/kapacitor/services/servicenow/servicenowtest" @@ -8025,7 +8025,7 @@ func TestServer_AlertHandlers(t *testing.T) { ts.Close() got := ts.Requests() if len(got) != 0 { - fmt.Errorf("unexpected hipchat request, hipchat support has been removed:\ngot\n%+v\n", got) + return fmt.Errorf("unexpected hipchat request, hipchat support has been removed:\ngot\n%+v\n", got) } return nil diff --git a/services/auth/service.go b/services/auth/service.go index 0dc333b4c..3cfbb68bd 100644 --- a/services/auth/service.go +++ b/services/auth/service.go @@ -330,9 +330,9 @@ func (s *Service) GrantSubscriptionAccess(token, db, rp string) error { Name: username, Admin: false, Privileges: map[string][]Privilege{ - writeResource: []Privilege{WritePrivilege}, - pingResource: []Privilege{AllPrivileges}, - dbResource: []Privilege{WritePrivilege}, + writeResource: {WritePrivilege}, + pingResource: {AllPrivileges}, + dbResource: {WritePrivilege}, }, } if err := s.users.Create(user); err != nil { diff --git a/services/diagnostic/handlers.go b/services/diagnostic/handlers.go index f6c01976c..774156f8f 100644 --- a/services/diagnostic/handlers.go +++ b/services/diagnostic/handlers.go @@ -4,7 +4,6 @@ import ( "bytes" "errors" "fmt" - "github.com/influxdata/kapacitor/services/removed" "log" "runtime" "strconv" @@ -31,6 +30,7 @@ import ( "github.com/influxdata/kapacitor/services/pagerduty" "github.com/influxdata/kapacitor/services/pagerduty2" "github.com/influxdata/kapacitor/services/pushover" + "github.com/influxdata/kapacitor/services/removed" "github.com/influxdata/kapacitor/services/sensu" "github.com/influxdata/kapacitor/services/servicenow" "github.com/influxdata/kapacitor/services/sideload" @@ -398,23 +398,6 @@ func (h *AlertaHandler) Error(msg string, err error) { h.l.Error(msg, Error(err)) } -//// HipChat handler -//type HipChatHandler struct { -// l Logger -//} -// -//func (h *HipChatHandler) WithContext(ctx ...keyvalue.T) hipchat.Diagnostic { -// fields := logFieldsFromContext(ctx) -// -// return &HipChatHandler{ -// l: h.l.With(fields...), -// } -//} -// -//func (h *HipChatHandler) Error(msg string, err error) { -// h.l.Error(msg, Error(err)) -//} - // Kafka handler type KafkaHandler struct { l Logger diff --git a/services/httpd/mux.go b/services/httpd/mux.go index 92d0f4492..8be4a1c7f 100644 --- a/services/httpd/mux.go +++ b/services/httpd/mux.go @@ -204,7 +204,7 @@ func (mux *ServeMux) Patterns() []string { defer mux.mu.Unlock() patterns := make([]string, len(mux.m)) i := 0 - for p, _ := range mux.m { + for p := range mux.m { patterns[i] = p i++ } diff --git a/services/influxdb/config.go b/services/influxdb/config.go index e503805fd..49f81cb36 100644 --- a/services/influxdb/config.go +++ b/services/influxdb/config.go @@ -76,7 +76,7 @@ func (c *Config) Init() { c.Name = "default" c.URLs = []string{"http://localhost:8086"} c.ExcludedSubscriptions = map[string][]string{ - stats.DefaultDatabse: []string{stats.DefaultRetentionPolicy}, + stats.DefaultDatabse: {stats.DefaultRetentionPolicy}, } c.UDPBuffer = udp.DefaultBuffer c.StartUpTimeout = toml.Duration(DefaultStartUpTimeout) diff --git a/services/influxdb/service.go b/services/influxdb/service.go index b508515b4..2e24fcf5f 100644 --- a/services/influxdb/service.go +++ b/services/influxdb/service.go @@ -738,7 +738,7 @@ func (c *influxdbCluster) watchSubs() { c.subSyncTicker = time.NewTicker(c.subscriptionSyncInterval) ticker := c.subSyncTicker go func() { - for _ = range ticker.C { + for range ticker.C { c.LinkSubscriptions() } }() diff --git a/services/removed/removed.go b/services/removed/removed.go index d3cd8b287..d14c967fc 100644 --- a/services/removed/removed.go +++ b/services/removed/removed.go @@ -2,13 +2,14 @@ package removed import ( "fmt" + "strings" + "github.com/influxdata/kapacitor/alert" "github.com/influxdata/kapacitor/keyvalue" - "strings" ) var ServiceNames = map[string]struct{}{ - HipChatName: struct{}{}, + HipChatName: {}, } const HipChatName = "hipchat"