From ac54b7cdd19cd0d019570cd783aca2b1f6b58fc0 Mon Sep 17 00:00:00 2001 From: Orne Brocaar Date: Thu, 9 Jul 2015 20:18:24 +0200 Subject: [PATCH] Implement thread-pool stats. --- plugins/elasticsearch/elasticsearch.go | 4 + plugins/elasticsearch/elasticsearch_test.go | 4 + plugins/elasticsearch/testdata_test.go | 243 ++++++++++++++++++++ 3 files changed, 251 insertions(+) diff --git a/plugins/elasticsearch/elasticsearch.go b/plugins/elasticsearch/elasticsearch.go index e4c43d5d4..de1efc767 100644 --- a/plugins/elasticsearch/elasticsearch.go +++ b/plugins/elasticsearch/elasticsearch.go @@ -19,6 +19,7 @@ type node struct { Os interface{} `json:"os"` Process interface{} `json:"process"` JVM interface{} `json:"jvm"` + ThreadPool interface{} `json:"thread_pool"` } const sampleConfig = ` @@ -111,6 +112,9 @@ func (e *Elasticsearch) gatherUrl(url string, acc plugins.Accumulator) error { if err := e.parseInterface(acc, "jvm", tags, n.JVM); err != nil { return err } + if err := e.parseInterface(acc, "thread_pool", tags, n.ThreadPool); err != nil { + return err + } } return nil diff --git a/plugins/elasticsearch/elasticsearch_test.go b/plugins/elasticsearch/elasticsearch_test.go index 9e0bd724b..e8febf042 100644 --- a/plugins/elasticsearch/elasticsearch_test.go +++ b/plugins/elasticsearch/elasticsearch_test.go @@ -66,4 +66,8 @@ func TestElasticsearch(t *testing.T) { for key, val := range jvmExpected { assert.NoError(t, acc.ValidateTaggedValue(key, val, tags)) } + + for key, val := range threadPoolExpected { + assert.NoError(t, acc.ValidateTaggedValue(key, val, tags)) + } } diff --git a/plugins/elasticsearch/testdata_test.go b/plugins/elasticsearch/testdata_test.go index f94d3c0eb..5562c17e8 100644 --- a/plugins/elasticsearch/testdata_test.go +++ b/plugins/elasticsearch/testdata_test.go @@ -229,6 +229,144 @@ const statsResponse = ` "total_capacity_in_bytes": 0 } } + }, + "thread_pool": { + "percolate": { + "threads": 123, + "queue": 23, + "active": 13, + "rejected": 235, + "largest": 23, + "completed": 33 + }, + "fetch_shard_started": { + "threads": 3, + "queue": 1, + "active": 5, + "rejected": 6, + "largest": 4, + "completed": 54 + }, + "listener": { + "threads": 1, + "queue": 2, + "active": 4, + "rejected": 8, + "largest": 1, + "completed": 1 + }, + "index": { + "threads": 6, + "queue": 8, + "active": 4, + "rejected": 2, + "largest": 3, + "completed": 6 + }, + "refresh": { + "threads": 23, + "queue": 7, + "active": 3, + "rejected": 4, + "largest": 8, + "completed": 3 + }, + "suggest": { + "threads": 2, + "queue": 7, + "active": 2, + "rejected": 1, + "largest": 8, + "completed": 3 + }, + "generic": { + "threads": 1, + "queue": 4, + "active": 6, + "rejected": 3, + "largest": 2, + "completed": 27 + }, + "warmer": { + "threads": 2, + "queue": 7, + "active": 3, + "rejected": 2, + "largest": 3, + "completed": 1 + }, + "search": { + "threads": 5, + "queue": 7, + "active": 2, + "rejected": 7, + "largest": 2, + "completed": 4 + }, + "flush": { + "threads": 3, + "queue": 8, + "active": 0, + "rejected": 1, + "largest": 5, + "completed": 3 + }, + "optimize": { + "threads": 3, + "queue": 4, + "active": 1, + "rejected": 2, + "largest": 7, + "completed": 3 + }, + "fetch_shard_store": { + "threads": 1, + "queue": 7, + "active": 4, + "rejected": 2, + "largest": 4, + "completed": 1 + }, + "management": { + "threads": 2, + "queue": 3, + "active": 1, + "rejected": 6, + "largest": 2, + "completed": 22 + }, + "get": { + "threads": 1, + "queue": 8, + "active": 4, + "rejected": 3, + "largest": 2, + "completed": 1 + }, + "merge": { + "threads": 6, + "queue": 4, + "active": 5, + "rejected": 2, + "largest": 5, + "completed": 1 + }, + "bulk": { + "threads": 4, + "queue": 5, + "active": 7, + "rejected": 3, + "largest": 1, + "completed": 4 + }, + "snapshot": { + "threads": 8, + "queue": 5, + "active": 6, + "rejected": 2, + "largest": 1, + "completed": 0 + } } } } @@ -371,3 +509,108 @@ var jvmExpected = map[string]float64{ "jvm_buffer_pools_mapped_used_in_bytes": 0, "jvm_buffer_pools_mapped_total_capacity_in_bytes": 0, } + +var threadPoolExpected = map[string]float64{ + "thread_pool_merge_threads": 6, + "thread_pool_merge_queue": 4, + "thread_pool_merge_active": 5, + "thread_pool_merge_rejected": 2, + "thread_pool_merge_largest": 5, + "thread_pool_merge_completed": 1, + "thread_pool_bulk_threads": 4, + "thread_pool_bulk_queue": 5, + "thread_pool_bulk_active": 7, + "thread_pool_bulk_rejected": 3, + "thread_pool_bulk_largest": 1, + "thread_pool_bulk_completed": 4, + "thread_pool_warmer_threads": 2, + "thread_pool_warmer_queue": 7, + "thread_pool_warmer_active": 3, + "thread_pool_warmer_rejected": 2, + "thread_pool_warmer_largest": 3, + "thread_pool_warmer_completed": 1, + "thread_pool_get_largest": 2, + "thread_pool_get_completed": 1, + "thread_pool_get_threads": 1, + "thread_pool_get_queue": 8, + "thread_pool_get_active": 4, + "thread_pool_get_rejected": 3, + "thread_pool_index_threads": 6, + "thread_pool_index_queue": 8, + "thread_pool_index_active": 4, + "thread_pool_index_rejected": 2, + "thread_pool_index_largest": 3, + "thread_pool_index_completed": 6, + "thread_pool_suggest_threads": 2, + "thread_pool_suggest_queue": 7, + "thread_pool_suggest_active": 2, + "thread_pool_suggest_rejected": 1, + "thread_pool_suggest_largest": 8, + "thread_pool_suggest_completed": 3, + "thread_pool_fetch_shard_store_queue": 7, + "thread_pool_fetch_shard_store_active": 4, + "thread_pool_fetch_shard_store_rejected": 2, + "thread_pool_fetch_shard_store_largest": 4, + "thread_pool_fetch_shard_store_completed": 1, + "thread_pool_fetch_shard_store_threads": 1, + "thread_pool_management_threads": 2, + "thread_pool_management_queue": 3, + "thread_pool_management_active": 1, + "thread_pool_management_rejected": 6, + "thread_pool_management_largest": 2, + "thread_pool_management_completed": 22, + "thread_pool_percolate_queue": 23, + "thread_pool_percolate_active": 13, + "thread_pool_percolate_rejected": 235, + "thread_pool_percolate_largest": 23, + "thread_pool_percolate_completed": 33, + "thread_pool_percolate_threads": 123, + "thread_pool_listener_active": 4, + "thread_pool_listener_rejected": 8, + "thread_pool_listener_largest": 1, + "thread_pool_listener_completed": 1, + "thread_pool_listener_threads": 1, + "thread_pool_listener_queue": 2, + "thread_pool_search_rejected": 7, + "thread_pool_search_largest": 2, + "thread_pool_search_completed": 4, + "thread_pool_search_threads": 5, + "thread_pool_search_queue": 7, + "thread_pool_search_active": 2, + "thread_pool_fetch_shard_started_threads": 3, + "thread_pool_fetch_shard_started_queue": 1, + "thread_pool_fetch_shard_started_active": 5, + "thread_pool_fetch_shard_started_rejected": 6, + "thread_pool_fetch_shard_started_largest": 4, + "thread_pool_fetch_shard_started_completed": 54, + "thread_pool_refresh_rejected": 4, + "thread_pool_refresh_largest": 8, + "thread_pool_refresh_completed": 3, + "thread_pool_refresh_threads": 23, + "thread_pool_refresh_queue": 7, + "thread_pool_refresh_active": 3, + "thread_pool_optimize_threads": 3, + "thread_pool_optimize_queue": 4, + "thread_pool_optimize_active": 1, + "thread_pool_optimize_rejected": 2, + "thread_pool_optimize_largest": 7, + "thread_pool_optimize_completed": 3, + "thread_pool_snapshot_largest": 1, + "thread_pool_snapshot_completed": 0, + "thread_pool_snapshot_threads": 8, + "thread_pool_snapshot_queue": 5, + "thread_pool_snapshot_active": 6, + "thread_pool_snapshot_rejected": 2, + "thread_pool_generic_threads": 1, + "thread_pool_generic_queue": 4, + "thread_pool_generic_active": 6, + "thread_pool_generic_rejected": 3, + "thread_pool_generic_largest": 2, + "thread_pool_generic_completed": 27, + "thread_pool_flush_threads": 3, + "thread_pool_flush_queue": 8, + "thread_pool_flush_active": 0, + "thread_pool_flush_rejected": 1, + "thread_pool_flush_largest": 5, + "thread_pool_flush_completed": 3, +}