From d7cd4b72c1b4b7620ed8f359c1f08c80119fae5c Mon Sep 17 00:00:00 2001 From: Cyril Duez Date: Wed, 18 May 2016 17:26:33 +0200 Subject: [PATCH 01/12] Report rollbar events. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cyril Duez Signed-off-by: François de Metz --- .../rollbar_webhooks/rollbar_webhooks.go | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 plugins/inputs/rollbar_webhooks/rollbar_webhooks.go diff --git a/plugins/inputs/rollbar_webhooks/rollbar_webhooks.go b/plugins/inputs/rollbar_webhooks/rollbar_webhooks.go new file mode 100644 index 0000000000000..783fb0d758b7d --- /dev/null +++ b/plugins/inputs/rollbar_webhooks/rollbar_webhooks.go @@ -0,0 +1,105 @@ +package rollbar_webhooks + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "log" + "net/http" + "sync" + "time" + + "github.com/gorilla/mux" + "github.com/influxdata/telegraf" + "github.com/influxdata/telegraf/plugins/inputs" +) + +func init() { + inputs.Add("rollbar_webhooks", func() telegraf.Input { return NewRollbarWebhooks() }) +} + +type RollbarWebhooks struct { + ServiceAddress string + // Lock for the struct + sync.Mutex + // Events buffer to store events between Gather calls + events []Event +} + +func NewRollbarWebhooks() *RollbarWebhooks { + return &RollbarWebhooks{} +} + +func (rb *RollbarWebhooks) SampleConfig() string { + return ` + ## Address and port to host Webhook listener on + service_address = ":1618" +` +} + +func (rb *RollbarWebhooks) Description() string { + return "A Rollbar Webhook Event collector" +} + +func (rb *RollbarWebhooks) Gather(acc telegraf.Accumulator) error { + rb.Lock() + defer rb.Unlock() + for _, event := range rb.events { + fields := map[string]interface{}{ + "value": 1, + } + tags := map[string]string{ + "event": event.Name, + } + + acc.AddFields("rollbar_webhooks", fields, tags, time.Now()) + } + rb.events = make([]Event, 0) + return nil +} + +func (rb *RollbarWebhooks) Listen() { + r := mux.NewRouter() + r.HandleFunc("/", rb.eventHandler).Methods("POST") + err := http.ListenAndServe(fmt.Sprintf("%s", rb.ServiceAddress), r) + if err != nil { + log.Printf("Error starting server: %v", err) + } +} + +func (rb *RollbarWebhooks) Start(_ telegraf.Accumulator) error { + go rb.Listen() + log.Printf("Started the rollbar_webhooks service on %s\n", rb.ServiceAddress) + return nil +} + +func (rb *RollbarWebhooks) Stop() { + log.Println("Stopping the rbWebhooks service") +} + +type Event struct { + Name string `json:"event_name"` +} + +// Handles the / route +func (rb *RollbarWebhooks) eventHandler(w http.ResponseWriter, r *http.Request) { + defer r.Body.Close() + data, err := ioutil.ReadAll(r.Body) + if err != nil { + w.WriteHeader(http.StatusBadRequest) + return + } + + var e Event + err = json.Unmarshal(data, &e) + if err != nil { + w.WriteHeader(http.StatusBadRequest) + return + } + + rb.Lock() + rb.events = append(rb.events, e) + rb.Unlock() + + w.WriteHeader(http.StatusOK) +} From febfe3e30638da17fec00a2452d01300391156fa Mon Sep 17 00:00:00 2001 From: Cyril Duez Date: Thu, 19 May 2016 09:53:41 +0200 Subject: [PATCH 02/12] Fix indent with go fmt. --- .../rollbar_webhooks/rollbar_webhooks.go | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/plugins/inputs/rollbar_webhooks/rollbar_webhooks.go b/plugins/inputs/rollbar_webhooks/rollbar_webhooks.go index 783fb0d758b7d..81e5c0ba0667d 100644 --- a/plugins/inputs/rollbar_webhooks/rollbar_webhooks.go +++ b/plugins/inputs/rollbar_webhooks/rollbar_webhooks.go @@ -7,7 +7,7 @@ import ( "log" "net/http" "sync" - "time" + "time" "github.com/gorilla/mux" "github.com/influxdata/telegraf" @@ -42,15 +42,15 @@ func (rb *RollbarWebhooks) Description() string { } func (rb *RollbarWebhooks) Gather(acc telegraf.Accumulator) error { - rb.Lock() + rb.Lock() defer rb.Unlock() for _, event := range rb.events { - fields := map[string]interface{}{ - "value": 1, - } - tags := map[string]string{ - "event": event.Name, - } + fields := map[string]interface{}{ + "value": 1, + } + tags := map[string]string{ + "event": event.Name, + } acc.AddFields("rollbar_webhooks", fields, tags, time.Now()) } @@ -78,7 +78,7 @@ func (rb *RollbarWebhooks) Stop() { } type Event struct { - Name string `json:"event_name"` + Name string `json:"event_name"` } // Handles the / route @@ -90,8 +90,8 @@ func (rb *RollbarWebhooks) eventHandler(w http.ResponseWriter, r *http.Request) return } - var e Event - err = json.Unmarshal(data, &e) + var e Event + err = json.Unmarshal(data, &e) if err != nil { w.WriteHeader(http.StatusBadRequest) return From f4e6d5116115e7748279d0707634c1b2dea41866 Mon Sep 17 00:00:00 2001 From: Cyril Duez Date: Fri, 20 May 2016 14:50:40 +0200 Subject: [PATCH 03/12] Add test for rollbar webhooks. --- .../rollbar_webhooks_events_json_test.go | 69 +++++++++++++++++++ .../rollbar_webhooks/rollbar_webhooks_test.go | 40 +++++++++++ 2 files changed, 109 insertions(+) create mode 100644 plugins/inputs/rollbar_webhooks/rollbar_webhooks_events_json_test.go create mode 100644 plugins/inputs/rollbar_webhooks/rollbar_webhooks_test.go diff --git a/plugins/inputs/rollbar_webhooks/rollbar_webhooks_events_json_test.go b/plugins/inputs/rollbar_webhooks/rollbar_webhooks_events_json_test.go new file mode 100644 index 0000000000000..f6d3d83163e6a --- /dev/null +++ b/plugins/inputs/rollbar_webhooks/rollbar_webhooks_events_json_test.go @@ -0,0 +1,69 @@ +package rollbar_webhooks + +func NewItemJSON() string { + return ` + { + "event_name": "new_item", + "data": { + "item": { + "public_item_id": null, + "integrations_data": {}, + "last_activated_timestamp": 1382655421, + "unique_occurrences": null, + "id": 272716944, + "environment": "production", + "title": "testing aobg98wrwe", + "last_occurrence_id": 481761639, + "last_occurrence_timestamp": 1382655421, + "platform": 0, + "first_occurrence_timestamp": 1382655421, + "project_id": 90, + "resolved_in_version": null, + "status": 1, + "hash": "c595b2ae0af9b397bb6bdafd57104ac4d5f6b382", + "last_occurrence": { + "body": { + "message": { + "body": "testing aobg98wrwe" + } + }, + "uuid": "d2036647-e0b7-4cad-bc98-934831b9b6d1", + "language": "python", + "level": "error", + "timestamp": 1382655421, + "server": { + "host": "dev", + "argv": [ + "" + ] + }, + "environment": "production", + "framework": "unknown", + "notifier": { + "version": "0.5.12", + "name": "pyrollbar" + }, + "metadata": { + "access_token": "", + "debug": { + "routes": { + "start_time": 1382212080401, + "counters": { + "post_item": 3274122 + } + } + }, + "customer_timestamp": 1382655421, + "api_server_hostname": "web6" + } + }, + "framework": 0, + "total_occurrences": 1, + "level": 40, + "counter": 4, + "first_occurrence_id": 481761639, + "activating_occurrence_id": 481761639 + } + } + }` +} diff --git a/plugins/inputs/rollbar_webhooks/rollbar_webhooks_test.go b/plugins/inputs/rollbar_webhooks/rollbar_webhooks_test.go new file mode 100644 index 0000000000000..567e80a2d4bf5 --- /dev/null +++ b/plugins/inputs/rollbar_webhooks/rollbar_webhooks_test.go @@ -0,0 +1,40 @@ +package rollbar_webhooks + +import ( + "net/http" + "net/http/httptest" + "strings" + "testing" + + "github.com/influxdata/telegraf/testutil" +) + +func postWebhooks(rb *RollbarWebhooks, eventBody string) *httptest.ResponseRecorder { + req, _ := http.NewRequest("POST", "/", strings.NewReader(eventBody)) + w := httptest.NewRecorder() + + rb.eventHandler(w, req) + + return w +} + +func TestNewItem(t *testing.T) { + rb := NewRollbarWebhooks() + resp := postWebhooks(rb, NewItemJSON()) + if resp.Code != http.StatusOK { + t.Errorf("POST new_item returned HTTP status code %v.\nExpected %v", resp.Code, http.StatusOK) + } +} + +func TestGather(t *testing.T) { + var acc testutil.Accumulator + rb := NewRollbarWebhooks() + + postWebhooks(rb, NewItemJSON()) + rb.Gather(&acc) + + fields := map[string]interface{}{"value": 1} + tags := map[string]string{"event": "new_item"} + + acc.AssertContainsTaggedFields(t, "rollbar_webhooks", fields, tags) +} From 05fbd5693b60e7d11056a041006c2ce611874a70 Mon Sep 17 00:00:00 2001 From: Cyril Duez Date: Fri, 20 May 2016 15:46:53 +0200 Subject: [PATCH 04/12] Report more data from new_item event. --- .../rollbar_webhooks/rollbar_webhooks.go | 20 ++------- .../rollbar_webhooks_events.go | 43 +++++++++++++++++++ .../rollbar_webhooks/rollbar_webhooks_test.go | 12 +++++- 3 files changed, 57 insertions(+), 18 deletions(-) create mode 100644 plugins/inputs/rollbar_webhooks/rollbar_webhooks_events.go diff --git a/plugins/inputs/rollbar_webhooks/rollbar_webhooks.go b/plugins/inputs/rollbar_webhooks/rollbar_webhooks.go index 81e5c0ba0667d..9768d3345eb2b 100644 --- a/plugins/inputs/rollbar_webhooks/rollbar_webhooks.go +++ b/plugins/inputs/rollbar_webhooks/rollbar_webhooks.go @@ -45,14 +45,7 @@ func (rb *RollbarWebhooks) Gather(acc telegraf.Accumulator) error { rb.Lock() defer rb.Unlock() for _, event := range rb.events { - fields := map[string]interface{}{ - "value": 1, - } - tags := map[string]string{ - "event": event.Name, - } - - acc.AddFields("rollbar_webhooks", fields, tags, time.Now()) + acc.AddFields("rollbar_webhooks", event.Fields(), event.Tags(), time.Now()) } rb.events = make([]Event, 0) return nil @@ -77,11 +70,6 @@ func (rb *RollbarWebhooks) Stop() { log.Println("Stopping the rbWebhooks service") } -type Event struct { - Name string `json:"event_name"` -} - -// Handles the / route func (rb *RollbarWebhooks) eventHandler(w http.ResponseWriter, r *http.Request) { defer r.Body.Close() data, err := ioutil.ReadAll(r.Body) @@ -90,15 +78,15 @@ func (rb *RollbarWebhooks) eventHandler(w http.ResponseWriter, r *http.Request) return } - var e Event - err = json.Unmarshal(data, &e) + newItem := &NewItem{} + err = json.Unmarshal(data, newItem) if err != nil { w.WriteHeader(http.StatusBadRequest) return } rb.Lock() - rb.events = append(rb.events, e) + rb.events = append(rb.events, newItem) rb.Unlock() w.WriteHeader(http.StatusOK) diff --git a/plugins/inputs/rollbar_webhooks/rollbar_webhooks_events.go b/plugins/inputs/rollbar_webhooks/rollbar_webhooks_events.go new file mode 100644 index 0000000000000..f22480fff010a --- /dev/null +++ b/plugins/inputs/rollbar_webhooks/rollbar_webhooks_events.go @@ -0,0 +1,43 @@ +package rollbar_webhooks + +import "strconv" + +type Event interface { + Tags() map[string]string + Fields() map[string]interface{} +} + +type NewItemDataItemLastOccurence struct { + Language string `json:"language"` +} + +type NewItemDataItem struct { + Id int `json:"id"` + Environment string `json:"environment"` + ProjectId int `json:"project_id"` + LastOccurence NewItemDataItemLastOccurence `json:"last_occurrence"` +} + +type NewItemData struct { + Item NewItemDataItem `json:"item"` +} + +type NewItem struct { + EventName string `json:"event_name"` + Data NewItemData `json:"data"` +} + +func (ni *NewItem) Tags() map[string]string { + return map[string]string{ + "event": ni.EventName, + "environment": ni.Data.Item.Environment, + "project_id": strconv.Itoa(ni.Data.Item.ProjectId), + "language": ni.Data.Item.LastOccurence.Language, + } +} + +func (ni *NewItem) Fields() map[string]interface{} { + return map[string]interface{}{ + "id": ni.Data.Item.Id, + } +} diff --git a/plugins/inputs/rollbar_webhooks/rollbar_webhooks_test.go b/plugins/inputs/rollbar_webhooks/rollbar_webhooks_test.go index 567e80a2d4bf5..95bfee7ab4e97 100644 --- a/plugins/inputs/rollbar_webhooks/rollbar_webhooks_test.go +++ b/plugins/inputs/rollbar_webhooks/rollbar_webhooks_test.go @@ -33,8 +33,16 @@ func TestGather(t *testing.T) { postWebhooks(rb, NewItemJSON()) rb.Gather(&acc) - fields := map[string]interface{}{"value": 1} - tags := map[string]string{"event": "new_item"} + fields := map[string]interface{}{ + "id": 272716944, + } + + tags := map[string]string{ + "event": "new_item", + "environment": "production", + "project_id": "90", + "language": "python", + } acc.AssertContainsTaggedFields(t, "rollbar_webhooks", fields, tags) } From 78e6c3732e5aa915428bf30c924327ef02af85eb Mon Sep 17 00:00:00 2001 From: Cyril Duez Date: Fri, 20 May 2016 16:45:28 +0200 Subject: [PATCH 05/12] Handle new deploy webhook. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cyril Duez Signed-off-by: François de Metz --- .../rollbar_webhooks/rollbar_webhooks.go | 32 ++++++++++++++-- .../rollbar_webhooks_events.go | 33 +++++++++++++++++ .../rollbar_webhooks_events_json_test.go | 27 ++++++++++++++ .../rollbar_webhooks/rollbar_webhooks_test.go | 37 ++++++++++++++++--- 4 files changed, 120 insertions(+), 9 deletions(-) diff --git a/plugins/inputs/rollbar_webhooks/rollbar_webhooks.go b/plugins/inputs/rollbar_webhooks/rollbar_webhooks.go index 9768d3345eb2b..a311542fc2d65 100644 --- a/plugins/inputs/rollbar_webhooks/rollbar_webhooks.go +++ b/plugins/inputs/rollbar_webhooks/rollbar_webhooks.go @@ -2,6 +2,7 @@ package rollbar_webhooks import ( "encoding/json" + "errors" "fmt" "io/ioutil" "log" @@ -78,16 +79,41 @@ func (rb *RollbarWebhooks) eventHandler(w http.ResponseWriter, r *http.Request) return } - newItem := &NewItem{} - err = json.Unmarshal(data, newItem) + dummyEvent := &DummyEvent{} + err = json.Unmarshal(data, dummyEvent) if err != nil { w.WriteHeader(http.StatusBadRequest) return } + event, err := NewEvent(dummyEvent, data) + if err != nil { + w.WriteHeader(http.StatusOK) + return + } + rb.Lock() - rb.events = append(rb.events, newItem) + rb.events = append(rb.events, event) rb.Unlock() w.WriteHeader(http.StatusOK) } + +func generateEvent(event Event, data []byte) (Event, error) { + err := json.Unmarshal(data, event) + if err != nil { + return nil, err + } + return event, nil +} + +func NewEvent(dummyEvent *DummyEvent, data []byte) (Event, error) { + switch dummyEvent.EventName { + case "new_item": + return generateEvent(&NewItem{}, data) + case "deploy": + return generateEvent(&Deploy{}, data) + default: + return nil, errors.New("Not implemented type: " + dummyEvent.EventName) + } +} diff --git a/plugins/inputs/rollbar_webhooks/rollbar_webhooks_events.go b/plugins/inputs/rollbar_webhooks/rollbar_webhooks_events.go index f22480fff010a..4dabea7a2718c 100644 --- a/plugins/inputs/rollbar_webhooks/rollbar_webhooks_events.go +++ b/plugins/inputs/rollbar_webhooks/rollbar_webhooks_events.go @@ -7,6 +7,10 @@ type Event interface { Fields() map[string]interface{} } +type DummyEvent struct { + EventName string `json:"event_name"` +} + type NewItemDataItemLastOccurence struct { Language string `json:"language"` } @@ -41,3 +45,32 @@ func (ni *NewItem) Fields() map[string]interface{} { "id": ni.Data.Item.Id, } } + +type DeployDataDeploy struct { + Id int `json:"id"` + Environment string `json:"environment"` + ProjectId int `json:"project_id"` +} + +type DeployData struct { + Deploy DeployDataDeploy `json:"deploy"` +} + +type Deploy struct { + EventName string `json:"event_name"` + Data DeployData `json:"data"` +} + +func (ni *Deploy) Tags() map[string]string { + return map[string]string{ + "event": ni.EventName, + "environment": ni.Data.Deploy.Environment, + "project_id": strconv.Itoa(ni.Data.Deploy.ProjectId), + } +} + +func (ni *Deploy) Fields() map[string]interface{} { + return map[string]interface{}{ + "id": ni.Data.Deploy.Id, + } +} diff --git a/plugins/inputs/rollbar_webhooks/rollbar_webhooks_events_json_test.go b/plugins/inputs/rollbar_webhooks/rollbar_webhooks_events_json_test.go index f6d3d83163e6a..99a6db8ff45db 100644 --- a/plugins/inputs/rollbar_webhooks/rollbar_webhooks_events_json_test.go +++ b/plugins/inputs/rollbar_webhooks/rollbar_webhooks_events_json_test.go @@ -67,3 +67,30 @@ func NewItemJSON() string { } }` } + +func DeployJSON() string { + return ` + { + "event_name": "deploy", + "data": { + "deploy": { + "comment": "deploying webs", + "user_id": 1, + "finish_time": 1382656039, + "start_time": 1382656038, + "id": 187585, + "environment": "production", + "project_id": 90, + "local_username": "brian", + "revision": "e4b9b7db860b2e5ac799f8c06b9498b71ab270bb" + } + } + }` +} + +func UnknowJSON() string { + return ` + { + "event_name": "roger" + }` +} diff --git a/plugins/inputs/rollbar_webhooks/rollbar_webhooks_test.go b/plugins/inputs/rollbar_webhooks/rollbar_webhooks_test.go index 95bfee7ab4e97..7e3d4ad8146fe 100644 --- a/plugins/inputs/rollbar_webhooks/rollbar_webhooks_test.go +++ b/plugins/inputs/rollbar_webhooks/rollbar_webhooks_test.go @@ -12,6 +12,7 @@ import ( func postWebhooks(rb *RollbarWebhooks, eventBody string) *httptest.ResponseRecorder { req, _ := http.NewRequest("POST", "/", strings.NewReader(eventBody)) w := httptest.NewRecorder() + w.Code = 500 rb.eventHandler(w, req) @@ -19,30 +20,54 @@ func postWebhooks(rb *RollbarWebhooks, eventBody string) *httptest.ResponseRecor } func TestNewItem(t *testing.T) { + var acc testutil.Accumulator rb := NewRollbarWebhooks() resp := postWebhooks(rb, NewItemJSON()) if resp.Code != http.StatusOK { t.Errorf("POST new_item returned HTTP status code %v.\nExpected %v", resp.Code, http.StatusOK) } + rb.Gather(&acc) + + fields := map[string]interface{}{ + "id": 272716944, + } + + tags := map[string]string{ + "event": "new_item", + "environment": "production", + "project_id": "90", + "language": "python", + } + + acc.AssertContainsTaggedFields(t, "rollbar_webhooks", fields, tags) } -func TestGather(t *testing.T) { +func TestDeploy(t *testing.T) { var acc testutil.Accumulator rb := NewRollbarWebhooks() - - postWebhooks(rb, NewItemJSON()) + resp := postWebhooks(rb, DeployJSON()) + if resp.Code != http.StatusOK { + t.Errorf("POST deploy returned HTTP status code %v.\nExpected %v", resp.Code, http.StatusOK) + } rb.Gather(&acc) fields := map[string]interface{}{ - "id": 272716944, + "id": 187585, } tags := map[string]string{ - "event": "new_item", + "event": "deploy", "environment": "production", "project_id": "90", - "language": "python", } acc.AssertContainsTaggedFields(t, "rollbar_webhooks", fields, tags) } + +func TestUnknowItem(t *testing.T) { + rb := NewRollbarWebhooks() + resp := postWebhooks(rb, UnknowJSON()) + if resp.Code != http.StatusOK { + t.Errorf("POST unknow returned HTTP status code %v.\nExpected %v", resp.Code, http.StatusOK) + } +} From f1fe1626febbce715287a05c62c1833878545819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20de=20Metz?= Date: Fri, 20 May 2016 17:01:04 +0200 Subject: [PATCH 06/12] Update default port. --- plugins/inputs/rollbar_webhooks/rollbar_webhooks.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/inputs/rollbar_webhooks/rollbar_webhooks.go b/plugins/inputs/rollbar_webhooks/rollbar_webhooks.go index a311542fc2d65..5e7dc88479436 100644 --- a/plugins/inputs/rollbar_webhooks/rollbar_webhooks.go +++ b/plugins/inputs/rollbar_webhooks/rollbar_webhooks.go @@ -34,7 +34,7 @@ func NewRollbarWebhooks() *RollbarWebhooks { func (rb *RollbarWebhooks) SampleConfig() string { return ` ## Address and port to host Webhook listener on - service_address = ":1618" + service_address = ":1619" ` } From 48926acfaf0300c015744738cf37251c6026cac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20de=20Metz?= Date: Fri, 20 May 2016 17:51:37 +0200 Subject: [PATCH 07/12] Add readme. --- plugins/inputs/rollbar_webhooks/README.md | 46 +++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 plugins/inputs/rollbar_webhooks/README.md diff --git a/plugins/inputs/rollbar_webhooks/README.md b/plugins/inputs/rollbar_webhooks/README.md new file mode 100644 index 0000000000000..930584d563dd3 --- /dev/null +++ b/plugins/inputs/rollbar_webhooks/README.md @@ -0,0 +1,46 @@ +# rollbar_webhooks + +This is a Telegraf service plugin that listens for events kicked off by Rollbar Webhooks service and persists data from them into configured outputs. To set up the listener first generate the proper configuration: +```sh +$ telegraf -sample-config -input-filter rollbar_webhooks -output-filter influxdb > config.conf.new +``` +Change the config file to point to the InfluxDB server you are using and adjust the settings to match your environment. Once that is complete: +```sh +$ cp config.conf.new /etc/telegraf/telegraf.conf +$ sudo service telegraf start +``` +Once the server is running you should configure your Rollbar's Webhooks to point at the `rollbar_webhooks` service. To do this go to `rollbar.com/` and click `Settings > Notifications > Webhook`. In the resulting page set `URL` to `http://:1619`, and click on `Enable Webhook Integration`. + +## Events + +The titles of the following sections are links to the full payloads and details for each event. The body contains what information from the event is persisted. The format is as follows: +``` +# TAGS +* 'tagKey' = `tagValue` type +# FIELDS +* 'fieldKey' = `fieldValue` type +``` +The tag values and field values show the place on the incoming JSON object where the data is sourced from. + +See [webhook doc](https://rollbar.com/docs/webhooks/) + +#### `new_item` event + +**Tags:** +* 'event' = `event.event_name` string +* 'environment' = `event.data.item.environment` string +* 'project_id = `event.data.item.project_id` int +* 'language' = `event.data.item.last_occurence.language` string + +**Fields:** +* 'id' = `event.data.item.id` int + +#### `deploy` event + +**Tags:** +* 'event' = `event.event_name` string +* 'environment' = `event.data.deploy.environment` string +* 'project_id = `event.data.deploy.project_id` int + +**Fields:** +* 'id' = `event.data.item.id` int From 270f52110fd661060fbdcd35fdb5b11887ab3600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20de=20Metz?= Date: Fri, 20 May 2016 18:14:10 +0200 Subject: [PATCH 08/12] Add rollbar_webhooks to the readme. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3b969639eb20f..8eb081871b49e 100644 --- a/README.md +++ b/README.md @@ -232,6 +232,7 @@ Telegraf can also collect metrics via the following service plugins: * [kafka_consumer](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/kafka_consumer) * [nats_consumer](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/nats_consumer) * [github_webhooks](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/github_webhooks) +* [rollbar_webhooks](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/rollbar_webhooks) We'll be adding support for many more over the coming months. Read on if you want to add support for another service or third-party API. From 5a295372081f7859be36579ed3339dab135a242e Mon Sep 17 00:00:00 2001 From: Cyril Duez Date: Mon, 23 May 2016 15:17:13 +0200 Subject: [PATCH 09/12] Add rollbar_webhooks to plugins list. --- plugins/inputs/all/all.go | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/inputs/all/all.go b/plugins/inputs/all/all.go index df739a6b39150..1cb771b2dd59d 100644 --- a/plugins/inputs/all/all.go +++ b/plugins/inputs/all/all.go @@ -52,6 +52,7 @@ import ( _ "github.com/influxdata/telegraf/plugins/inputs/redis" _ "github.com/influxdata/telegraf/plugins/inputs/rethinkdb" _ "github.com/influxdata/telegraf/plugins/inputs/riak" + _ "github.com/influxdata/telegraf/plugins/inputs/rollbar_webhooks" _ "github.com/influxdata/telegraf/plugins/inputs/sensors" _ "github.com/influxdata/telegraf/plugins/inputs/snmp" _ "github.com/influxdata/telegraf/plugins/inputs/sqlserver" From ac656e58f5957d491e71cfdc9ee350026a95a32d Mon Sep 17 00:00:00 2001 From: Cyril Duez Date: Mon, 23 May 2016 15:48:07 +0200 Subject: [PATCH 10/12] Add tag level for new_item event. --- plugins/inputs/rollbar_webhooks/rollbar_webhooks_events.go | 2 ++ plugins/inputs/rollbar_webhooks/rollbar_webhooks_test.go | 1 + 2 files changed, 3 insertions(+) diff --git a/plugins/inputs/rollbar_webhooks/rollbar_webhooks_events.go b/plugins/inputs/rollbar_webhooks/rollbar_webhooks_events.go index 4dabea7a2718c..8cccec336e62a 100644 --- a/plugins/inputs/rollbar_webhooks/rollbar_webhooks_events.go +++ b/plugins/inputs/rollbar_webhooks/rollbar_webhooks_events.go @@ -13,6 +13,7 @@ type DummyEvent struct { type NewItemDataItemLastOccurence struct { Language string `json:"language"` + Level string `json:"level"` } type NewItemDataItem struct { @@ -37,6 +38,7 @@ func (ni *NewItem) Tags() map[string]string { "environment": ni.Data.Item.Environment, "project_id": strconv.Itoa(ni.Data.Item.ProjectId), "language": ni.Data.Item.LastOccurence.Language, + "level": ni.Data.Item.LastOccurence.Level, } } diff --git a/plugins/inputs/rollbar_webhooks/rollbar_webhooks_test.go b/plugins/inputs/rollbar_webhooks/rollbar_webhooks_test.go index 7e3d4ad8146fe..e0b183a8c2e63 100644 --- a/plugins/inputs/rollbar_webhooks/rollbar_webhooks_test.go +++ b/plugins/inputs/rollbar_webhooks/rollbar_webhooks_test.go @@ -37,6 +37,7 @@ func TestNewItem(t *testing.T) { "environment": "production", "project_id": "90", "language": "python", + "level": "error", } acc.AssertContainsTaggedFields(t, "rollbar_webhooks", fields, tags) From b5ccee027983c9607019b5f5871ea4c51be6585e Mon Sep 17 00:00:00 2001 From: Cyril Duez Date: Mon, 23 May 2016 16:09:38 +0200 Subject: [PATCH 11/12] Update readme. --- plugins/inputs/rollbar_webhooks/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/inputs/rollbar_webhooks/README.md b/plugins/inputs/rollbar_webhooks/README.md index 930584d563dd3..d6938df28ce7c 100644 --- a/plugins/inputs/rollbar_webhooks/README.md +++ b/plugins/inputs/rollbar_webhooks/README.md @@ -31,6 +31,7 @@ See [webhook doc](https://rollbar.com/docs/webhooks/) * 'environment' = `event.data.item.environment` string * 'project_id = `event.data.item.project_id` int * 'language' = `event.data.item.last_occurence.language` string +* 'level' = `event.data.item.last_occurence.level` string **Fields:** * 'id' = `event.data.item.id` int From 5c5300667419c47b2a651b01bc905ee75091bde1 Mon Sep 17 00:00:00 2001 From: Cyril Duez Date: Mon, 23 May 2016 16:44:26 +0200 Subject: [PATCH 12/12] Update changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb0261f79c37a..c2acd033cf7d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ to "stdout". ### Features - [#1138](https://github.com/influxdata/telegraf/pull/1138): nstat input plugin. Thanks @Maksadbek! +- [#1247](https://github.com/influxdata/telegraf/pull/1247): rollbar input plugin. Thanks @francois2metz and @cduez! - [#1139](https://github.com/influxdata/telegraf/pull/1139): instrumental output plugin. Thanks @jasonroelofs! - [#1172](https://github.com/influxdata/telegraf/pull/1172): Ceph storage stats. Thanks @robinpercy! - [#1233](https://github.com/influxdata/telegraf/pull/1233): Updated golint gopsutil dependency.