| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | package elasticsearch |
| 4 | |
| 5 | import ( |
| 6 | "context" |
| 7 | "net/http" |
| 8 | "net/http/httptest" |
| 9 | "os" |
| 10 | "testing" |
| 11 | |
| 12 | "github.com/stretchr/testify/assert" |
| 13 | "github.com/stretchr/testify/require" |
| 14 | |
| 15 | "github.com/netdata/netdata/go/plugins/pkg/tlscfg" |
| 16 | "github.com/netdata/netdata/go/plugins/pkg/web" |
| 17 | "github.com/netdata/netdata/go/plugins/plugin/go.d/pkg/collecttest" |
| 18 | ) |
| 19 | |
| 20 | var ( |
| 21 | dataConfigJSON, _ = os.ReadFile("testdata/config.json") |
| 22 | dataConfigYAML, _ = os.ReadFile("testdata/config.yaml") |
| 23 | |
| 24 | dataVer842NodesLocalStats, _ = os.ReadFile("testdata/v8.4.2/nodes_local_stats.json") |
| 25 | dataVer842NodesStats, _ = os.ReadFile("testdata/v8.4.2/nodes_stats.json") |
| 26 | dataVer842ClusterHealth, _ = os.ReadFile("testdata/v8.4.2/cluster_health.json") |
| 27 | dataVer842ClusterStats, _ = os.ReadFile("testdata/v8.4.2/cluster_stats.json") |
| 28 | dataVer842CatIndicesStats, _ = os.ReadFile("testdata/v8.4.2/cat_indices_stats.json") |
| 29 | dataVer842Info, _ = os.ReadFile("testdata/v8.4.2/info.json") |
| 30 | ) |
| 31 | |
| 32 | func Test_testDataIsValid(t *testing.T) { |
| 33 | for name, data := range map[string][]byte{ |
| 34 | "dataConfigJSON": dataConfigJSON, |
| 35 | "dataConfigYAML": dataConfigYAML, |
| 36 | "dataVer842NodesLocalStats": dataVer842NodesLocalStats, |
| 37 | "dataVer842NodesStats": dataVer842NodesStats, |
| 38 | "dataVer842ClusterHealth": dataVer842ClusterHealth, |
| 39 | "dataVer842ClusterStats": dataVer842ClusterStats, |
| 40 | "dataVer842CatIndicesStats": dataVer842CatIndicesStats, |
| 41 | "dataVer842Info": dataVer842Info, |
| 42 | } { |
| 43 | require.NotNil(t, data, name) |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | func TestCollector_ConfigurationSerialize(t *testing.T) { |
| 48 | collecttest.TestConfigurationSerialize(t, &Collector{}, dataConfigJSON, dataConfigYAML) |
| 49 | } |
| 50 | |
| 51 | func TestCollector_Init(t *testing.T) { |
| 52 | tests := map[string]struct { |
| 53 | config Config |
| 54 | wantFail bool |
| 55 | }{ |
| 56 | "default": { |
| 57 | config: New().Config, |
| 58 | }, |
| 59 | "all stats": { |
| 60 | config: Config{ |
| 61 | HTTPConfig: web.HTTPConfig{ |
| 62 | RequestConfig: web.RequestConfig{URL: "http://127.0.0.1:38001"}, |
| 63 | }, |
| 64 | DoNodeStats: true, |
| 65 | DoClusterHealth: true, |
| 66 | DoClusterStats: true, |
| 67 | DoIndicesStats: true, |
| 68 | }, |
| 69 | }, |
| 70 | "only node_stats": { |
| 71 | config: Config{ |
| 72 | HTTPConfig: web.HTTPConfig{ |
| 73 | RequestConfig: web.RequestConfig{URL: "http://127.0.0.1:38001"}, |
| 74 | }, |
| 75 | DoNodeStats: true, |
| 76 | DoClusterHealth: false, |
| 77 | DoClusterStats: false, |
| 78 | DoIndicesStats: false, |
| 79 | }, |
| 80 | }, |
| 81 | "URL not set": { |
| 82 | wantFail: true, |
| 83 | config: Config{ |
| 84 | HTTPConfig: web.HTTPConfig{ |
| 85 | RequestConfig: web.RequestConfig{URL: ""}, |
| 86 | }}, |
| 87 | }, |
| 88 | "invalid TLSCA": { |
| 89 | wantFail: true, |
| 90 | config: Config{ |
| 91 | HTTPConfig: web.HTTPConfig{ |
| 92 | ClientConfig: web.ClientConfig{ |
| 93 | TLSConfig: tlscfg.TLSConfig{TLSCA: "testdata/tls"}, |
| 94 | }, |
| 95 | }}, |
| 96 | }, |
| 97 | "all API calls are disabled": { |
| 98 | wantFail: true, |
| 99 | config: Config{ |
| 100 | HTTPConfig: web.HTTPConfig{ |
| 101 | RequestConfig: web.RequestConfig{URL: "http://127.0.0.1:38001"}, |
| 102 | }, |
| 103 | DoNodeStats: false, |
| 104 | DoClusterHealth: false, |
| 105 | DoClusterStats: false, |
| 106 | DoIndicesStats: false, |
| 107 | }, |
| 108 | }, |
| 109 | } |
| 110 | |
| 111 | for name, test := range tests { |
| 112 | t.Run(name, func(t *testing.T) { |
| 113 | collr := New() |
| 114 | collr.Config = test.config |
| 115 | |
| 116 | if test.wantFail { |
| 117 | assert.Error(t, collr.Init(context.Background())) |
| 118 | } else { |
| 119 | assert.NoError(t, collr.Init(context.Background())) |
| 120 | } |
| 121 | }) |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | func TestCollector_Check(t *testing.T) { |
| 126 | tests := map[string]struct { |
| 127 | prepare func(*testing.T) (collr *Collector, cleanup func()) |
| 128 | wantFail bool |
| 129 | }{ |
| 130 | "valid data": {prepare: prepareElasticsearchValidData}, |
| 131 | "invalid data": {prepare: prepareElasticsearchInvalidData, wantFail: true}, |
| 132 | "404": {prepare: prepareElasticsearch404, wantFail: true}, |
| 133 | "connection refused": {prepare: prepareElasticsearchConnectionRefused, wantFail: true}, |
| 134 | } |
| 135 | |
| 136 | for name, test := range tests { |
| 137 | t.Run(name, func(t *testing.T) { |
| 138 | collr, cleanup := test.prepare(t) |
| 139 | defer cleanup() |
| 140 | |
| 141 | if test.wantFail { |
| 142 | assert.Error(t, collr.Check(context.Background())) |
| 143 | } else { |
| 144 | assert.NoError(t, collr.Check(context.Background())) |
| 145 | } |
| 146 | }) |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | func TestCollector_Charts(t *testing.T) { |
| 151 | assert.NotNil(t, New().Charts()) |
| 152 | } |
| 153 | |
| 154 | func TestCollector_Cleanup(t *testing.T) { |
| 155 | assert.NotPanics(t, func() { New().Cleanup(context.Background()) }) |
| 156 | } |
| 157 | |
| 158 | func TestCollector_Collect(t *testing.T) { |
| 159 | tests := map[string]struct { |
| 160 | prepare func() *Collector |
| 161 | wantCollected map[string]int64 |
| 162 | wantCharts int |
| 163 | }{ |
| 164 | "v842: all nodes stats": { |
| 165 | prepare: func() *Collector { |
| 166 | collr := New() |
| 167 | collr.ClusterMode = true |
| 168 | collr.DoNodeStats = true |
| 169 | collr.DoClusterHealth = false |
| 170 | collr.DoClusterStats = false |
| 171 | collr.DoIndicesStats = false |
| 172 | return collr |
| 173 | }, |
| 174 | wantCharts: len(nodeChartsTmpl) * 3, |
| 175 | wantCollected: map[string]int64{ |
| 176 | "node_Klg1CjgMTouentQcJlRGuA_breakers_accounting_tripped": 0, |
| 177 | "node_Klg1CjgMTouentQcJlRGuA_breakers_fielddata_tripped": 0, |
| 178 | "node_Klg1CjgMTouentQcJlRGuA_breakers_in_flight_requests_tripped": 0, |
| 179 | "node_Klg1CjgMTouentQcJlRGuA_breakers_model_inference_tripped": 0, |
| 180 | "node_Klg1CjgMTouentQcJlRGuA_breakers_parent_tripped": 0, |
| 181 | "node_Klg1CjgMTouentQcJlRGuA_breakers_request_tripped": 0, |
| 182 | "node_Klg1CjgMTouentQcJlRGuA_http_current_open": 75, |
| 183 | "node_Klg1CjgMTouentQcJlRGuA_indices_fielddata_evictions": 0, |
| 184 | "node_Klg1CjgMTouentQcJlRGuA_indices_fielddata_memory_size_in_bytes": 600, |
| 185 | "node_Klg1CjgMTouentQcJlRGuA_indices_flush_total": 35130, |
| 186 | "node_Klg1CjgMTouentQcJlRGuA_indices_flush_total_time_in_millis": 22204637, |
| 187 | "node_Klg1CjgMTouentQcJlRGuA_indices_indexing_index_current": 0, |
| 188 | "node_Klg1CjgMTouentQcJlRGuA_indices_indexing_index_time_in_millis": 1100012973, |
| 189 | "node_Klg1CjgMTouentQcJlRGuA_indices_indexing_index_total": 3667364815, |
| 190 | "node_Klg1CjgMTouentQcJlRGuA_indices_refresh_total": 7720800, |
| 191 | "node_Klg1CjgMTouentQcJlRGuA_indices_refresh_total_time_in_millis": 94297737, |
| 192 | "node_Klg1CjgMTouentQcJlRGuA_indices_search_fetch_current": 0, |
| 193 | "node_Klg1CjgMTouentQcJlRGuA_indices_search_fetch_time_in_millis": 21316723, |
| 194 | "node_Klg1CjgMTouentQcJlRGuA_indices_search_fetch_total": 42642621, |
| 195 | "node_Klg1CjgMTouentQcJlRGuA_indices_search_query_current": 0, |
| 196 | "node_Klg1CjgMTouentQcJlRGuA_indices_search_query_time_in_millis": 51262303, |
| 197 | "node_Klg1CjgMTouentQcJlRGuA_indices_search_query_total": 166820275, |
| 198 | "node_Klg1CjgMTouentQcJlRGuA_indices_segments_count": 320, |
| 199 | "node_Klg1CjgMTouentQcJlRGuA_indices_segments_doc_values_memory_in_bytes": 0, |
| 200 | "node_Klg1CjgMTouentQcJlRGuA_indices_segments_fixed_bit_set_memory_in_bytes": 1904, |
| 201 | "node_Klg1CjgMTouentQcJlRGuA_indices_segments_index_writer_memory_in_bytes": 262022568, |
| 202 | "node_Klg1CjgMTouentQcJlRGuA_indices_segments_memory_in_bytes": 0, |
| 203 | "node_Klg1CjgMTouentQcJlRGuA_indices_segments_norms_memory_in_bytes": 0, |
| 204 | "node_Klg1CjgMTouentQcJlRGuA_indices_segments_points_memory_in_bytes": 0, |
| 205 | "node_Klg1CjgMTouentQcJlRGuA_indices_segments_stored_fields_memory_in_bytes": 0, |
| 206 | "node_Klg1CjgMTouentQcJlRGuA_indices_segments_term_vectors_memory_in_bytes": 0, |
| 207 | "node_Klg1CjgMTouentQcJlRGuA_indices_segments_terms_memory_in_bytes": 0, |
| 208 | "node_Klg1CjgMTouentQcJlRGuA_indices_segments_version_map_memory_in_bytes": 49200018, |
| 209 | "node_Klg1CjgMTouentQcJlRGuA_indices_translog_operations": 352376, |
| 210 | "node_Klg1CjgMTouentQcJlRGuA_indices_translog_size_in_bytes": 447695989, |
| 211 | "node_Klg1CjgMTouentQcJlRGuA_indices_translog_uncommitted_operations": 352376, |
| 212 | "node_Klg1CjgMTouentQcJlRGuA_indices_translog_uncommitted_size_in_bytes": 447695989, |
| 213 | "node_Klg1CjgMTouentQcJlRGuA_jvm_buffer_pools_direct_count": 94, |
| 214 | "node_Klg1CjgMTouentQcJlRGuA_jvm_buffer_pools_direct_total_capacity_in_bytes": 4654848, |
| 215 | "node_Klg1CjgMTouentQcJlRGuA_jvm_buffer_pools_direct_used_in_bytes": 4654850, |
| 216 | "node_Klg1CjgMTouentQcJlRGuA_jvm_buffer_pools_mapped_count": 858, |
| 217 | "node_Klg1CjgMTouentQcJlRGuA_jvm_buffer_pools_mapped_total_capacity_in_bytes": 103114998135, |
| 218 | "node_Klg1CjgMTouentQcJlRGuA_jvm_buffer_pools_mapped_used_in_bytes": 103114998135, |
| 219 | "node_Klg1CjgMTouentQcJlRGuA_jvm_gc_collectors_old_collection_count": 0, |
| 220 | "node_Klg1CjgMTouentQcJlRGuA_jvm_gc_collectors_old_collection_time_in_millis": 0, |
| 221 | "node_Klg1CjgMTouentQcJlRGuA_jvm_gc_collectors_young_collection_count": 78652, |
| 222 | "node_Klg1CjgMTouentQcJlRGuA_jvm_gc_collectors_young_collection_time_in_millis": 6014274, |
| 223 | "node_Klg1CjgMTouentQcJlRGuA_jvm_mem_heap_committed_in_bytes": 7864320000, |
| 224 | "node_Klg1CjgMTouentQcJlRGuA_jvm_mem_heap_used_in_bytes": 5059735552, |
| 225 | "node_Klg1CjgMTouentQcJlRGuA_jvm_mem_heap_used_percent": 64, |
| 226 | "node_Klg1CjgMTouentQcJlRGuA_process_max_file_descriptors": 1048576, |
| 227 | "node_Klg1CjgMTouentQcJlRGuA_process_open_file_descriptors": 1156, |
| 228 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_analyze_queue": 0, |
| 229 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_analyze_rejected": 0, |
| 230 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_fetch_shard_started_queue": 0, |
| 231 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_fetch_shard_started_rejected": 0, |
| 232 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_fetch_shard_store_queue": 0, |
| 233 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_fetch_shard_store_rejected": 0, |
| 234 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_flush_queue": 0, |
| 235 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_flush_rejected": 0, |
| 236 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_force_merge_queue": 0, |
| 237 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_force_merge_rejected": 0, |
| 238 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_generic_queue": 0, |
| 239 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_generic_rejected": 0, |
| 240 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_get_queue": 0, |
| 241 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_get_rejected": 0, |
| 242 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_listener_queue": 0, |
| 243 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_listener_rejected": 0, |
| 244 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_management_queue": 0, |
| 245 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_management_rejected": 0, |
| 246 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_refresh_queue": 0, |
| 247 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_refresh_rejected": 0, |
| 248 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_search_queue": 0, |
| 249 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_search_rejected": 0, |
| 250 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_search_throttled_queue": 0, |
| 251 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_search_throttled_rejected": 0, |
| 252 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_snapshot_queue": 0, |
| 253 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_snapshot_rejected": 0, |
| 254 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_warmer_queue": 0, |
| 255 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_warmer_rejected": 0, |
| 256 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_write_queue": 0, |
| 257 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_write_rejected": 0, |
| 258 | "node_Klg1CjgMTouentQcJlRGuA_transport_rx_count": 1300324276, |
| 259 | "node_Klg1CjgMTouentQcJlRGuA_transport_rx_size_in_bytes": 1789333458217, |
| 260 | "node_Klg1CjgMTouentQcJlRGuA_transport_tx_count": 1300324275, |
| 261 | "node_Klg1CjgMTouentQcJlRGuA_transport_tx_size_in_bytes": 2927487680282, |
| 262 | "node_k_AifYMWQTykjUq3pgE_-w_breakers_accounting_tripped": 0, |
| 263 | "node_k_AifYMWQTykjUq3pgE_-w_breakers_fielddata_tripped": 0, |
| 264 | "node_k_AifYMWQTykjUq3pgE_-w_breakers_in_flight_requests_tripped": 0, |
| 265 | "node_k_AifYMWQTykjUq3pgE_-w_breakers_model_inference_tripped": 0, |
| 266 | "node_k_AifYMWQTykjUq3pgE_-w_breakers_parent_tripped": 0, |
| 267 | "node_k_AifYMWQTykjUq3pgE_-w_breakers_request_tripped": 0, |
| 268 | "node_k_AifYMWQTykjUq3pgE_-w_http_current_open": 14, |
| 269 | "node_k_AifYMWQTykjUq3pgE_-w_indices_fielddata_evictions": 0, |
| 270 | "node_k_AifYMWQTykjUq3pgE_-w_indices_fielddata_memory_size_in_bytes": 0, |
| 271 | "node_k_AifYMWQTykjUq3pgE_-w_indices_flush_total": 0, |
| 272 | "node_k_AifYMWQTykjUq3pgE_-w_indices_flush_total_time_in_millis": 0, |
| 273 | "node_k_AifYMWQTykjUq3pgE_-w_indices_indexing_index_current": 0, |
| 274 | "node_k_AifYMWQTykjUq3pgE_-w_indices_indexing_index_time_in_millis": 0, |
| 275 | "node_k_AifYMWQTykjUq3pgE_-w_indices_indexing_index_total": 0, |
| 276 | "node_k_AifYMWQTykjUq3pgE_-w_indices_refresh_total": 0, |
| 277 | "node_k_AifYMWQTykjUq3pgE_-w_indices_refresh_total_time_in_millis": 0, |
| 278 | "node_k_AifYMWQTykjUq3pgE_-w_indices_search_fetch_current": 0, |
| 279 | "node_k_AifYMWQTykjUq3pgE_-w_indices_search_fetch_time_in_millis": 0, |
| 280 | "node_k_AifYMWQTykjUq3pgE_-w_indices_search_fetch_total": 0, |
| 281 | "node_k_AifYMWQTykjUq3pgE_-w_indices_search_query_current": 0, |
| 282 | "node_k_AifYMWQTykjUq3pgE_-w_indices_search_query_time_in_millis": 0, |
| 283 | "node_k_AifYMWQTykjUq3pgE_-w_indices_search_query_total": 0, |
| 284 | "node_k_AifYMWQTykjUq3pgE_-w_indices_segments_count": 0, |
| 285 | "node_k_AifYMWQTykjUq3pgE_-w_indices_segments_doc_values_memory_in_bytes": 0, |
| 286 | "node_k_AifYMWQTykjUq3pgE_-w_indices_segments_fixed_bit_set_memory_in_bytes": 0, |
| 287 | "node_k_AifYMWQTykjUq3pgE_-w_indices_segments_index_writer_memory_in_bytes": 0, |
| 288 | "node_k_AifYMWQTykjUq3pgE_-w_indices_segments_memory_in_bytes": 0, |
| 289 | "node_k_AifYMWQTykjUq3pgE_-w_indices_segments_norms_memory_in_bytes": 0, |
| 290 | "node_k_AifYMWQTykjUq3pgE_-w_indices_segments_points_memory_in_bytes": 0, |
| 291 | "node_k_AifYMWQTykjUq3pgE_-w_indices_segments_stored_fields_memory_in_bytes": 0, |
| 292 | "node_k_AifYMWQTykjUq3pgE_-w_indices_segments_term_vectors_memory_in_bytes": 0, |
| 293 | "node_k_AifYMWQTykjUq3pgE_-w_indices_segments_terms_memory_in_bytes": 0, |
| 294 | "node_k_AifYMWQTykjUq3pgE_-w_indices_segments_version_map_memory_in_bytes": 0, |
| 295 | "node_k_AifYMWQTykjUq3pgE_-w_indices_translog_operations": 0, |
| 296 | "node_k_AifYMWQTykjUq3pgE_-w_indices_translog_size_in_bytes": 0, |
| 297 | "node_k_AifYMWQTykjUq3pgE_-w_indices_translog_uncommitted_operations": 0, |
| 298 | "node_k_AifYMWQTykjUq3pgE_-w_indices_translog_uncommitted_size_in_bytes": 0, |
| 299 | "node_k_AifYMWQTykjUq3pgE_-w_jvm_buffer_pools_direct_count": 19, |
| 300 | "node_k_AifYMWQTykjUq3pgE_-w_jvm_buffer_pools_direct_total_capacity_in_bytes": 2142214, |
| 301 | "node_k_AifYMWQTykjUq3pgE_-w_jvm_buffer_pools_direct_used_in_bytes": 2142216, |
| 302 | "node_k_AifYMWQTykjUq3pgE_-w_jvm_buffer_pools_mapped_count": 0, |
| 303 | "node_k_AifYMWQTykjUq3pgE_-w_jvm_buffer_pools_mapped_total_capacity_in_bytes": 0, |
| 304 | "node_k_AifYMWQTykjUq3pgE_-w_jvm_buffer_pools_mapped_used_in_bytes": 0, |
| 305 | "node_k_AifYMWQTykjUq3pgE_-w_jvm_gc_collectors_old_collection_count": 0, |
| 306 | "node_k_AifYMWQTykjUq3pgE_-w_jvm_gc_collectors_old_collection_time_in_millis": 0, |
| 307 | "node_k_AifYMWQTykjUq3pgE_-w_jvm_gc_collectors_young_collection_count": 342994, |
| 308 | "node_k_AifYMWQTykjUq3pgE_-w_jvm_gc_collectors_young_collection_time_in_millis": 768917, |
| 309 | "node_k_AifYMWQTykjUq3pgE_-w_jvm_mem_heap_committed_in_bytes": 281018368, |
| 310 | "node_k_AifYMWQTykjUq3pgE_-w_jvm_mem_heap_used_in_bytes": 178362704, |
| 311 | "node_k_AifYMWQTykjUq3pgE_-w_jvm_mem_heap_used_percent": 63, |
| 312 | "node_k_AifYMWQTykjUq3pgE_-w_process_max_file_descriptors": 1048576, |
| 313 | "node_k_AifYMWQTykjUq3pgE_-w_process_open_file_descriptors": 557, |
| 314 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_analyze_queue": 0, |
| 315 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_analyze_rejected": 0, |
| 316 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_fetch_shard_started_queue": 0, |
| 317 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_fetch_shard_started_rejected": 0, |
| 318 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_fetch_shard_store_queue": 0, |
| 319 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_fetch_shard_store_rejected": 0, |
| 320 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_flush_queue": 0, |
| 321 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_flush_rejected": 0, |
| 322 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_force_merge_queue": 0, |
| 323 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_force_merge_rejected": 0, |
| 324 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_generic_queue": 0, |
| 325 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_generic_rejected": 0, |
| 326 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_get_queue": 0, |
| 327 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_get_rejected": 0, |
| 328 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_listener_queue": 0, |
| 329 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_listener_rejected": 0, |
| 330 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_management_queue": 0, |
| 331 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_management_rejected": 0, |
| 332 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_refresh_queue": 0, |
| 333 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_refresh_rejected": 0, |
| 334 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_search_queue": 0, |
| 335 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_search_rejected": 0, |
| 336 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_search_throttled_queue": 0, |
| 337 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_search_throttled_rejected": 0, |
| 338 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_snapshot_queue": 0, |
| 339 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_snapshot_rejected": 0, |
| 340 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_warmer_queue": 0, |
| 341 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_warmer_rejected": 0, |
| 342 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_write_queue": 0, |
| 343 | "node_k_AifYMWQTykjUq3pgE_-w_thread_pool_write_rejected": 0, |
| 344 | "node_k_AifYMWQTykjUq3pgE_-w_transport_rx_count": 107632996, |
| 345 | "node_k_AifYMWQTykjUq3pgE_-w_transport_rx_size_in_bytes": 180620082152, |
| 346 | "node_k_AifYMWQTykjUq3pgE_-w_transport_tx_count": 107633007, |
| 347 | "node_k_AifYMWQTykjUq3pgE_-w_transport_tx_size_in_bytes": 420999501235, |
| 348 | "node_tk_U7GMCRkCG4FoOvusrng_breakers_accounting_tripped": 0, |
| 349 | "node_tk_U7GMCRkCG4FoOvusrng_breakers_fielddata_tripped": 0, |
| 350 | "node_tk_U7GMCRkCG4FoOvusrng_breakers_in_flight_requests_tripped": 0, |
| 351 | "node_tk_U7GMCRkCG4FoOvusrng_breakers_model_inference_tripped": 0, |
| 352 | "node_tk_U7GMCRkCG4FoOvusrng_breakers_parent_tripped": 93, |
| 353 | "node_tk_U7GMCRkCG4FoOvusrng_breakers_request_tripped": 1, |
| 354 | "node_tk_U7GMCRkCG4FoOvusrng_http_current_open": 84, |
| 355 | "node_tk_U7GMCRkCG4FoOvusrng_indices_fielddata_evictions": 0, |
| 356 | "node_tk_U7GMCRkCG4FoOvusrng_indices_fielddata_memory_size_in_bytes": 0, |
| 357 | "node_tk_U7GMCRkCG4FoOvusrng_indices_flush_total": 67895, |
| 358 | "node_tk_U7GMCRkCG4FoOvusrng_indices_flush_total_time_in_millis": 81917283, |
| 359 | "node_tk_U7GMCRkCG4FoOvusrng_indices_indexing_index_current": 0, |
| 360 | "node_tk_U7GMCRkCG4FoOvusrng_indices_indexing_index_time_in_millis": 1244633519, |
| 361 | "node_tk_U7GMCRkCG4FoOvusrng_indices_indexing_index_total": 6550378755, |
| 362 | "node_tk_U7GMCRkCG4FoOvusrng_indices_refresh_total": 12359783, |
| 363 | "node_tk_U7GMCRkCG4FoOvusrng_indices_refresh_total_time_in_millis": 300152615, |
| 364 | "node_tk_U7GMCRkCG4FoOvusrng_indices_search_fetch_current": 0, |
| 365 | "node_tk_U7GMCRkCG4FoOvusrng_indices_search_fetch_time_in_millis": 24517851, |
| 366 | "node_tk_U7GMCRkCG4FoOvusrng_indices_search_fetch_total": 25105951, |
| 367 | "node_tk_U7GMCRkCG4FoOvusrng_indices_search_query_current": 0, |
| 368 | "node_tk_U7GMCRkCG4FoOvusrng_indices_search_query_time_in_millis": 158980385, |
| 369 | "node_tk_U7GMCRkCG4FoOvusrng_indices_search_query_total": 157912598, |
| 370 | "node_tk_U7GMCRkCG4FoOvusrng_indices_segments_count": 291, |
| 371 | "node_tk_U7GMCRkCG4FoOvusrng_indices_segments_doc_values_memory_in_bytes": 0, |
| 372 | "node_tk_U7GMCRkCG4FoOvusrng_indices_segments_fixed_bit_set_memory_in_bytes": 55672, |
| 373 | "node_tk_U7GMCRkCG4FoOvusrng_indices_segments_index_writer_memory_in_bytes": 57432664, |
| 374 | "node_tk_U7GMCRkCG4FoOvusrng_indices_segments_memory_in_bytes": 0, |
| 375 | "node_tk_U7GMCRkCG4FoOvusrng_indices_segments_norms_memory_in_bytes": 0, |
| 376 | "node_tk_U7GMCRkCG4FoOvusrng_indices_segments_points_memory_in_bytes": 0, |
| 377 | "node_tk_U7GMCRkCG4FoOvusrng_indices_segments_stored_fields_memory_in_bytes": 0, |
| 378 | "node_tk_U7GMCRkCG4FoOvusrng_indices_segments_term_vectors_memory_in_bytes": 0, |
| 379 | "node_tk_U7GMCRkCG4FoOvusrng_indices_segments_terms_memory_in_bytes": 0, |
| 380 | "node_tk_U7GMCRkCG4FoOvusrng_indices_segments_version_map_memory_in_bytes": 568, |
| 381 | "node_tk_U7GMCRkCG4FoOvusrng_indices_translog_operations": 1449698, |
| 382 | "node_tk_U7GMCRkCG4FoOvusrng_indices_translog_size_in_bytes": 1214204014, |
| 383 | "node_tk_U7GMCRkCG4FoOvusrng_indices_translog_uncommitted_operations": 1449698, |
| 384 | "node_tk_U7GMCRkCG4FoOvusrng_indices_translog_uncommitted_size_in_bytes": 1214204014, |
| 385 | "node_tk_U7GMCRkCG4FoOvusrng_jvm_buffer_pools_direct_count": 90, |
| 386 | "node_tk_U7GMCRkCG4FoOvusrng_jvm_buffer_pools_direct_total_capacity_in_bytes": 4571711, |
| 387 | "node_tk_U7GMCRkCG4FoOvusrng_jvm_buffer_pools_direct_used_in_bytes": 4571713, |
| 388 | "node_tk_U7GMCRkCG4FoOvusrng_jvm_buffer_pools_mapped_count": 831, |
| 389 | "node_tk_U7GMCRkCG4FoOvusrng_jvm_buffer_pools_mapped_total_capacity_in_bytes": 99844219805, |
| 390 | "node_tk_U7GMCRkCG4FoOvusrng_jvm_buffer_pools_mapped_used_in_bytes": 99844219805, |
| 391 | "node_tk_U7GMCRkCG4FoOvusrng_jvm_gc_collectors_old_collection_count": 1, |
| 392 | "node_tk_U7GMCRkCG4FoOvusrng_jvm_gc_collectors_old_collection_time_in_millis": 796, |
| 393 | "node_tk_U7GMCRkCG4FoOvusrng_jvm_gc_collectors_young_collection_count": 139959, |
| 394 | "node_tk_U7GMCRkCG4FoOvusrng_jvm_gc_collectors_young_collection_time_in_millis": 3581668, |
| 395 | "node_tk_U7GMCRkCG4FoOvusrng_jvm_mem_heap_committed_in_bytes": 7864320000, |
| 396 | "node_tk_U7GMCRkCG4FoOvusrng_jvm_mem_heap_used_in_bytes": 1884124192, |
| 397 | "node_tk_U7GMCRkCG4FoOvusrng_jvm_mem_heap_used_percent": 23, |
| 398 | "node_tk_U7GMCRkCG4FoOvusrng_process_max_file_descriptors": 1048576, |
| 399 | "node_tk_U7GMCRkCG4FoOvusrng_process_open_file_descriptors": 1180, |
| 400 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_analyze_queue": 0, |
| 401 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_analyze_rejected": 0, |
| 402 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_fetch_shard_started_queue": 0, |
| 403 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_fetch_shard_started_rejected": 0, |
| 404 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_fetch_shard_store_queue": 0, |
| 405 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_fetch_shard_store_rejected": 0, |
| 406 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_flush_queue": 0, |
| 407 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_flush_rejected": 0, |
| 408 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_force_merge_queue": 0, |
| 409 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_force_merge_rejected": 0, |
| 410 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_generic_queue": 0, |
| 411 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_generic_rejected": 0, |
| 412 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_get_queue": 0, |
| 413 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_get_rejected": 0, |
| 414 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_listener_queue": 0, |
| 415 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_listener_rejected": 0, |
| 416 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_management_queue": 0, |
| 417 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_management_rejected": 0, |
| 418 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_refresh_queue": 0, |
| 419 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_refresh_rejected": 0, |
| 420 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_search_queue": 0, |
| 421 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_search_rejected": 0, |
| 422 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_search_throttled_queue": 0, |
| 423 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_search_throttled_rejected": 0, |
| 424 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_snapshot_queue": 0, |
| 425 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_snapshot_rejected": 0, |
| 426 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_warmer_queue": 0, |
| 427 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_warmer_rejected": 0, |
| 428 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_write_queue": 0, |
| 429 | "node_tk_U7GMCRkCG4FoOvusrng_thread_pool_write_rejected": 0, |
| 430 | "node_tk_U7GMCRkCG4FoOvusrng_transport_rx_count": 2167879292, |
| 431 | "node_tk_U7GMCRkCG4FoOvusrng_transport_rx_size_in_bytes": 4905919297323, |
| 432 | "node_tk_U7GMCRkCG4FoOvusrng_transport_tx_count": 2167879293, |
| 433 | "node_tk_U7GMCRkCG4FoOvusrng_transport_tx_size_in_bytes": 2964638852652, |
| 434 | }, |
| 435 | }, |
| 436 | "v842: local node stats": { |
| 437 | prepare: func() *Collector { |
| 438 | collr := New() |
| 439 | collr.DoNodeStats = true |
| 440 | collr.DoClusterHealth = false |
| 441 | collr.DoClusterStats = false |
| 442 | collr.DoIndicesStats = false |
| 443 | return collr |
| 444 | }, |
| 445 | wantCharts: len(nodeChartsTmpl), |
| 446 | wantCollected: map[string]int64{ |
| 447 | "node_Klg1CjgMTouentQcJlRGuA_breakers_accounting_tripped": 0, |
| 448 | "node_Klg1CjgMTouentQcJlRGuA_breakers_fielddata_tripped": 0, |
| 449 | "node_Klg1CjgMTouentQcJlRGuA_breakers_in_flight_requests_tripped": 0, |
| 450 | "node_Klg1CjgMTouentQcJlRGuA_breakers_model_inference_tripped": 0, |
| 451 | "node_Klg1CjgMTouentQcJlRGuA_breakers_parent_tripped": 0, |
| 452 | "node_Klg1CjgMTouentQcJlRGuA_breakers_request_tripped": 0, |
| 453 | "node_Klg1CjgMTouentQcJlRGuA_http_current_open": 73, |
| 454 | "node_Klg1CjgMTouentQcJlRGuA_indices_fielddata_evictions": 0, |
| 455 | "node_Klg1CjgMTouentQcJlRGuA_indices_fielddata_memory_size_in_bytes": 600, |
| 456 | "node_Klg1CjgMTouentQcJlRGuA_indices_flush_total": 35134, |
| 457 | "node_Klg1CjgMTouentQcJlRGuA_indices_flush_total_time_in_millis": 22213090, |
| 458 | "node_Klg1CjgMTouentQcJlRGuA_indices_indexing_index_current": 1, |
| 459 | "node_Klg1CjgMTouentQcJlRGuA_indices_indexing_index_time_in_millis": 1100149051, |
| 460 | "node_Klg1CjgMTouentQcJlRGuA_indices_indexing_index_total": 3667793202, |
| 461 | "node_Klg1CjgMTouentQcJlRGuA_indices_refresh_total": 7721472, |
| 462 | "node_Klg1CjgMTouentQcJlRGuA_indices_refresh_total_time_in_millis": 94304142, |
| 463 | "node_Klg1CjgMTouentQcJlRGuA_indices_search_fetch_current": 0, |
| 464 | "node_Klg1CjgMTouentQcJlRGuA_indices_search_fetch_time_in_millis": 21316820, |
| 465 | "node_Klg1CjgMTouentQcJlRGuA_indices_search_fetch_total": 42645288, |
| 466 | "node_Klg1CjgMTouentQcJlRGuA_indices_search_query_current": 0, |
| 467 | "node_Klg1CjgMTouentQcJlRGuA_indices_search_query_time_in_millis": 51265805, |
| 468 | "node_Klg1CjgMTouentQcJlRGuA_indices_search_query_total": 166823028, |
| 469 | "node_Klg1CjgMTouentQcJlRGuA_indices_segments_count": 307, |
| 470 | "node_Klg1CjgMTouentQcJlRGuA_indices_segments_doc_values_memory_in_bytes": 0, |
| 471 | "node_Klg1CjgMTouentQcJlRGuA_indices_segments_fixed_bit_set_memory_in_bytes": 2008, |
| 472 | "node_Klg1CjgMTouentQcJlRGuA_indices_segments_index_writer_memory_in_bytes": 240481008, |
| 473 | "node_Klg1CjgMTouentQcJlRGuA_indices_segments_memory_in_bytes": 0, |
| 474 | "node_Klg1CjgMTouentQcJlRGuA_indices_segments_norms_memory_in_bytes": 0, |
| 475 | "node_Klg1CjgMTouentQcJlRGuA_indices_segments_points_memory_in_bytes": 0, |
| 476 | "node_Klg1CjgMTouentQcJlRGuA_indices_segments_stored_fields_memory_in_bytes": 0, |
| 477 | "node_Klg1CjgMTouentQcJlRGuA_indices_segments_term_vectors_memory_in_bytes": 0, |
| 478 | "node_Klg1CjgMTouentQcJlRGuA_indices_segments_terms_memory_in_bytes": 0, |
| 479 | "node_Klg1CjgMTouentQcJlRGuA_indices_segments_version_map_memory_in_bytes": 44339216, |
| 480 | "node_Klg1CjgMTouentQcJlRGuA_indices_translog_operations": 362831, |
| 481 | "node_Klg1CjgMTouentQcJlRGuA_indices_translog_size_in_bytes": 453491882, |
| 482 | "node_Klg1CjgMTouentQcJlRGuA_indices_translog_uncommitted_operations": 362831, |
| 483 | "node_Klg1CjgMTouentQcJlRGuA_indices_translog_uncommitted_size_in_bytes": 453491882, |
| 484 | "node_Klg1CjgMTouentQcJlRGuA_jvm_buffer_pools_direct_count": 94, |
| 485 | "node_Klg1CjgMTouentQcJlRGuA_jvm_buffer_pools_direct_total_capacity_in_bytes": 4654848, |
| 486 | "node_Klg1CjgMTouentQcJlRGuA_jvm_buffer_pools_direct_used_in_bytes": 4654850, |
| 487 | "node_Klg1CjgMTouentQcJlRGuA_jvm_buffer_pools_mapped_count": 844, |
| 488 | "node_Klg1CjgMTouentQcJlRGuA_jvm_buffer_pools_mapped_total_capacity_in_bytes": 103411995802, |
| 489 | "node_Klg1CjgMTouentQcJlRGuA_jvm_buffer_pools_mapped_used_in_bytes": 103411995802, |
| 490 | "node_Klg1CjgMTouentQcJlRGuA_jvm_gc_collectors_old_collection_count": 0, |
| 491 | "node_Klg1CjgMTouentQcJlRGuA_jvm_gc_collectors_old_collection_time_in_millis": 0, |
| 492 | "node_Klg1CjgMTouentQcJlRGuA_jvm_gc_collectors_young_collection_count": 78661, |
| 493 | "node_Klg1CjgMTouentQcJlRGuA_jvm_gc_collectors_young_collection_time_in_millis": 6014901, |
| 494 | "node_Klg1CjgMTouentQcJlRGuA_jvm_mem_heap_committed_in_bytes": 7864320000, |
| 495 | "node_Klg1CjgMTouentQcJlRGuA_jvm_mem_heap_used_in_bytes": 4337402488, |
| 496 | "node_Klg1CjgMTouentQcJlRGuA_jvm_mem_heap_used_percent": 55, |
| 497 | "node_Klg1CjgMTouentQcJlRGuA_process_max_file_descriptors": 1048576, |
| 498 | "node_Klg1CjgMTouentQcJlRGuA_process_open_file_descriptors": 1149, |
| 499 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_analyze_queue": 0, |
| 500 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_analyze_rejected": 0, |
| 501 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_fetch_shard_started_queue": 0, |
| 502 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_fetch_shard_started_rejected": 0, |
| 503 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_fetch_shard_store_queue": 0, |
| 504 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_fetch_shard_store_rejected": 0, |
| 505 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_flush_queue": 0, |
| 506 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_flush_rejected": 0, |
| 507 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_force_merge_queue": 0, |
| 508 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_force_merge_rejected": 0, |
| 509 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_generic_queue": 0, |
| 510 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_generic_rejected": 0, |
| 511 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_get_queue": 0, |
| 512 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_get_rejected": 0, |
| 513 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_listener_queue": 0, |
| 514 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_listener_rejected": 0, |
| 515 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_management_queue": 0, |
| 516 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_management_rejected": 0, |
| 517 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_refresh_queue": 0, |
| 518 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_refresh_rejected": 0, |
| 519 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_search_queue": 0, |
| 520 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_search_rejected": 0, |
| 521 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_search_throttled_queue": 0, |
| 522 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_search_throttled_rejected": 0, |
| 523 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_snapshot_queue": 0, |
| 524 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_snapshot_rejected": 0, |
| 525 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_warmer_queue": 0, |
| 526 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_warmer_rejected": 0, |
| 527 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_write_queue": 0, |
| 528 | "node_Klg1CjgMTouentQcJlRGuA_thread_pool_write_rejected": 0, |
| 529 | "node_Klg1CjgMTouentQcJlRGuA_transport_rx_count": 1300468666, |
| 530 | "node_Klg1CjgMTouentQcJlRGuA_transport_rx_size_in_bytes": 1789647854011, |
| 531 | "node_Klg1CjgMTouentQcJlRGuA_transport_tx_count": 1300468665, |
| 532 | "node_Klg1CjgMTouentQcJlRGuA_transport_tx_size_in_bytes": 2927853534431, |
| 533 | }, |
| 534 | }, |
| 535 | "v842: only cluster_health": { |
| 536 | prepare: func() *Collector { |
| 537 | collr := New() |
| 538 | collr.DoNodeStats = false |
| 539 | collr.DoClusterHealth = true |
| 540 | collr.DoClusterStats = false |
| 541 | collr.DoIndicesStats = false |
| 542 | return collr |
| 543 | }, |
| 544 | wantCharts: len(clusterHealthChartsTmpl), |
| 545 | wantCollected: map[string]int64{ |
| 546 | "cluster_active_primary_shards": 97, |
| 547 | "cluster_active_shards": 194, |
| 548 | "cluster_active_shards_percent_as_number": 100, |
| 549 | "cluster_delayed_unassigned_shards": 0, |
| 550 | "cluster_initializing_shards": 0, |
| 551 | "cluster_number_of_data_nodes": 2, |
| 552 | "cluster_number_of_in_flight_fetch": 0, |
| 553 | "cluster_number_of_nodes": 3, |
| 554 | "cluster_number_of_pending_tasks": 0, |
| 555 | "cluster_relocating_shards": 0, |
| 556 | "cluster_status_green": 1, |
| 557 | "cluster_status_red": 0, |
| 558 | "cluster_status_yellow": 0, |
| 559 | "cluster_unassigned_shards": 0, |
| 560 | }, |
| 561 | }, |
| 562 | "v842: only cluster_stats": { |
| 563 | prepare: func() *Collector { |
| 564 | collr := New() |
| 565 | collr.DoNodeStats = false |
| 566 | collr.DoClusterHealth = false |
| 567 | collr.DoClusterStats = true |
| 568 | collr.DoIndicesStats = false |
| 569 | return collr |
| 570 | }, |
| 571 | wantCharts: len(clusterStatsChartsTmpl), |
| 572 | wantCollected: map[string]int64{ |
| 573 | "cluster_indices_count": 97, |
| 574 | "cluster_indices_docs_count": 402750703, |
| 575 | "cluster_indices_query_cache_hit_count": 96838726, |
| 576 | "cluster_indices_query_cache_miss_count": 587768226, |
| 577 | "cluster_indices_shards_primaries": 97, |
| 578 | "cluster_indices_shards_replication": 1, |
| 579 | "cluster_indices_shards_total": 194, |
| 580 | "cluster_indices_store_size_in_bytes": 380826136962, |
| 581 | "cluster_nodes_count_coordinating_only": 0, |
| 582 | "cluster_nodes_count_data": 0, |
| 583 | "cluster_nodes_count_data_cold": 0, |
| 584 | "cluster_nodes_count_data_content": 2, |
| 585 | "cluster_nodes_count_data_frozen": 0, |
| 586 | "cluster_nodes_count_data_hot": 2, |
| 587 | "cluster_nodes_count_data_warm": 0, |
| 588 | "cluster_nodes_count_ingest": 2, |
| 589 | "cluster_nodes_count_master": 3, |
| 590 | "cluster_nodes_count_ml": 0, |
| 591 | "cluster_nodes_count_remote_cluster_client": 2, |
| 592 | "cluster_nodes_count_total": 3, |
| 593 | "cluster_nodes_count_transform": 2, |
| 594 | "cluster_nodes_count_voting_only": 1, |
| 595 | }, |
| 596 | }, |
| 597 | "v842: only indices_stats": { |
| 598 | prepare: func() *Collector { |
| 599 | collr := New() |
| 600 | collr.DoNodeStats = false |
| 601 | collr.DoClusterHealth = false |
| 602 | collr.DoClusterStats = false |
| 603 | collr.DoIndicesStats = true |
| 604 | return collr |
| 605 | }, |
| 606 | wantCharts: len(nodeIndexChartsTmpl) * 3, |
| 607 | wantCollected: map[string]int64{ |
| 608 | "node_index_my-index-000001_stats_docs_count": 1, |
| 609 | "node_index_my-index-000001_stats_health_green": 0, |
| 610 | "node_index_my-index-000001_stats_health_red": 0, |
| 611 | "node_index_my-index-000001_stats_health_yellow": 1, |
| 612 | "node_index_my-index-000001_stats_shards_count": 1, |
| 613 | "node_index_my-index-000001_stats_store_size_in_bytes": 208, |
| 614 | "node_index_my-index-000002_stats_docs_count": 1, |
| 615 | "node_index_my-index-000002_stats_health_green": 0, |
| 616 | "node_index_my-index-000002_stats_health_red": 0, |
| 617 | "node_index_my-index-000002_stats_health_yellow": 1, |
| 618 | "node_index_my-index-000002_stats_shards_count": 1, |
| 619 | "node_index_my-index-000002_stats_store_size_in_bytes": 208, |
| 620 | "node_index_my-index-000003_stats_docs_count": 1, |
| 621 | "node_index_my-index-000003_stats_health_green": 0, |
| 622 | "node_index_my-index-000003_stats_health_red": 0, |
| 623 | "node_index_my-index-000003_stats_health_yellow": 1, |
| 624 | "node_index_my-index-000003_stats_shards_count": 1, |
| 625 | "node_index_my-index-000003_stats_store_size_in_bytes": 208, |
| 626 | }, |
| 627 | }, |
| 628 | } |
| 629 | |
| 630 | for name, test := range tests { |
| 631 | t.Run(name, func(t *testing.T) { |
| 632 | collr, cleanup := prepareElasticsearch(t, test.prepare) |
| 633 | defer cleanup() |
| 634 | |
| 635 | var mx map[string]int64 |
| 636 | for range 10 { |
| 637 | mx = collr.Collect(context.Background()) |
| 638 | } |
| 639 | |
| 640 | assert.Equal(t, test.wantCollected, mx) |
| 641 | assert.Len(t, *collr.Charts(), test.wantCharts) |
| 642 | collecttest.TestMetricsHasAllChartsDims(t, collr.Charts(), mx) |
| 643 | }) |
| 644 | } |
| 645 | } |
| 646 | |
| 647 | func prepareElasticsearch(t *testing.T, createES func() *Collector) (collr *Collector, cleanup func()) { |
| 648 | t.Helper() |
| 649 | srv := prepareElasticsearchEndpoint() |
| 650 | |
| 651 | collr = createES() |
| 652 | collr.URL = srv.URL |
| 653 | require.NoError(t, collr.Init(context.Background())) |
| 654 | |
| 655 | return collr, srv.Close |
| 656 | } |
| 657 | |
| 658 | func prepareElasticsearchValidData(t *testing.T) (es *Collector, cleanup func()) { |
| 659 | return prepareElasticsearch(t, New) |
| 660 | } |
| 661 | |
| 662 | func prepareElasticsearchInvalidData(t *testing.T) (*Collector, func()) { |
| 663 | t.Helper() |
| 664 | srv := httptest.NewServer(http.HandlerFunc( |
| 665 | func(w http.ResponseWriter, r *http.Request) { |
| 666 | _, _ = w.Write([]byte("hello and\n goodbye")) |
| 667 | })) |
| 668 | collr := New() |
| 669 | collr.URL = srv.URL |
| 670 | require.NoError(t, collr.Init(context.Background())) |
| 671 | |
| 672 | return collr, srv.Close |
| 673 | } |
| 674 | |
| 675 | func prepareElasticsearch404(t *testing.T) (*Collector, func()) { |
| 676 | t.Helper() |
| 677 | srv := httptest.NewServer(http.HandlerFunc( |
| 678 | func(w http.ResponseWriter, r *http.Request) { |
| 679 | w.WriteHeader(http.StatusNotFound) |
| 680 | })) |
| 681 | collr := New() |
| 682 | collr.URL = srv.URL |
| 683 | require.NoError(t, collr.Init(context.Background())) |
| 684 | |
| 685 | return collr, srv.Close |
| 686 | } |
| 687 | |
| 688 | func prepareElasticsearchConnectionRefused(t *testing.T) (*Collector, func()) { |
| 689 | t.Helper() |
| 690 | collr := New() |
| 691 | collr.URL = "http://127.0.0.1:38001" |
| 692 | require.NoError(t, collr.Init(context.Background())) |
| 693 | |
| 694 | return collr, func() {} |
| 695 | } |
| 696 | |
| 697 | func prepareElasticsearchEndpoint() *httptest.Server { |
| 698 | return httptest.NewServer(http.HandlerFunc( |
| 699 | func(w http.ResponseWriter, r *http.Request) { |
| 700 | switch r.URL.Path { |
| 701 | case urlPathNodesStats: |
| 702 | _, _ = w.Write(dataVer842NodesStats) |
| 703 | case urlPathLocalNodeStats: |
| 704 | _, _ = w.Write(dataVer842NodesLocalStats) |
| 705 | case urlPathClusterHealth: |
| 706 | _, _ = w.Write(dataVer842ClusterHealth) |
| 707 | case urlPathClusterStats: |
| 708 | _, _ = w.Write(dataVer842ClusterStats) |
| 709 | case urlPathIndicesStats: |
| 710 | _, _ = w.Write(dataVer842CatIndicesStats) |
| 711 | case "/": |
| 712 | _, _ = w.Write(dataVer842Info) |
| 713 | default: |
| 714 | w.WriteHeader(http.StatusNotFound) |
| 715 | } |
| 716 | })) |
| 717 | } |