From d799011039d4511c52f5756965a694daa795938a Mon Sep 17 00:00:00 2001 From: Orne Brocaar Date: Thu, 9 Jul 2015 20:43:52 +0200 Subject: [PATCH] Implement breakers stats. --- plugins/elasticsearch/elasticsearch.go | 4 ++ plugins/elasticsearch/elasticsearch_test.go | 3 ++ plugins/elasticsearch/testdata_test.go | 41 +++++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/plugins/elasticsearch/elasticsearch.go b/plugins/elasticsearch/elasticsearch.go index e51d121cf..2703798e4 100644 --- a/plugins/elasticsearch/elasticsearch.go +++ b/plugins/elasticsearch/elasticsearch.go @@ -24,6 +24,7 @@ type node struct { FS interface{} `json:"fs"` Transport interface{} `json:"transport"` HTTP interface{} `json:"http"` + Breakers interface{} `json:"breakers"` } const sampleConfig = ` @@ -131,6 +132,9 @@ func (e *Elasticsearch) gatherUrl(url string, acc plugins.Accumulator) error { if err := e.parseInterface(acc, "http", tags, n.HTTP); err != nil { return err } + if err := e.parseInterface(acc, "breakers", tags, n.Breakers); err != nil { + return err + } } return nil diff --git a/plugins/elasticsearch/elasticsearch_test.go b/plugins/elasticsearch/elasticsearch_test.go index 306e1d9fe..6611bca01 100644 --- a/plugins/elasticsearch/elasticsearch_test.go +++ b/plugins/elasticsearch/elasticsearch_test.go @@ -85,4 +85,7 @@ func TestElasticsearch(t *testing.T) { for key, val := range httpExpected { assert.NoError(t, acc.ValidateTaggedValue(key, val, tags)) } + for key, val := range breakersExpected { + assert.NoError(t, acc.ValidateTaggedValue(key, val, tags)) + } } diff --git a/plugins/elasticsearch/testdata_test.go b/plugins/elasticsearch/testdata_test.go index 2c1233c4d..87bd15692 100644 --- a/plugins/elasticsearch/testdata_test.go +++ b/plugins/elasticsearch/testdata_test.go @@ -411,6 +411,32 @@ const statsResponse = ` "http": { "current_open": 3, "total_opened": 3 + }, + "breakers": { + "fielddata": { + "limit_size_in_bytes": 623326003, + "limit_size": "594.4mb", + "estimated_size_in_bytes": 0, + "estimated_size": "0b", + "overhead": 1.03, + "tripped": 0 + }, + "request": { + "limit_size_in_bytes": 415550668, + "limit_size": "396.2mb", + "estimated_size_in_bytes": 0, + "estimated_size": "0b", + "overhead": 1.0, + "tripped": 0 + }, + "parent": { + "limit_size_in_bytes": 727213670, + "limit_size": "693.5mb", + "estimated_size_in_bytes": 0, + "estimated_size": "0b", + "overhead": 1.0, + "tripped": 0 + } } } } @@ -691,3 +717,18 @@ var httpExpected = map[string]float64{ "http_current_open": 3, "http_total_opened": 3, } + +var breakersExpected = map[string]float64{ + "breakers_fielddata_estimated_size_in_bytes": 0, + "breakers_fielddata_overhead": 1.03, + "breakers_fielddata_tripped": 0, + "breakers_fielddata_limit_size_in_bytes": 623326003, + "breakers_request_estimated_size_in_bytes": 0, + "breakers_request_overhead": 1.0, + "breakers_request_tripped": 0, + "breakers_request_limit_size_in_bytes": 415550668, + "breakers_parent_overhead": 1.0, + "breakers_parent_tripped": 0, + "breakers_parent_limit_size_in_bytes": 727213670, + "breakers_parent_estimated_size_in_bytes": 0, +}