summaryrefslogtreecommitdiffstats
path: root/src/go/collectors/go.d.plugin/modules/elasticsearch/elasticsearch_test.go
blob: dc4817336fa1d6176565f471f8a03a0bd0accb6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
// SPDX-License-Identifier: GPL-3.0-or-later

package elasticsearch

import (
	"github.com/netdata/netdata/go/go.d.plugin/agent/module"
	"net/http"
	"net/http/httptest"
	"os"
	"testing"

	"github.com/netdata/netdata/go/go.d.plugin/pkg/tlscfg"
	"github.com/netdata/netdata/go/go.d.plugin/pkg/web"

	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
)

var (
	dataConfigJSON, _ = os.ReadFile("testdata/config.json")
	dataConfigYAML, _ = os.ReadFile("testdata/config.yaml")

	dataVer842NodesLocalStats, _ = os.ReadFile("testdata/v8.4.2/nodes_local_stats.json")
	dataVer842NodesStats, _      = os.ReadFile("testdata/v8.4.2/nodes_stats.json")
	dataVer842ClusterHealth, _   = os.ReadFile("testdata/v8.4.2/cluster_health.json")
	dataVer842ClusterStats, _    = os.ReadFile("testdata/v8.4.2/cluster_stats.json")
	dataVer842CatIndicesStats, _ = os.ReadFile("testdata/v8.4.2/cat_indices_stats.json")
	dataVer842Info, _            = os.ReadFile("testdata/v8.4.2/info.json")
)

func Test_testDataIsValid(t *testing.T) {
	for name, data := range map[string][]byte{
		"dataConfigJSON":            dataConfigJSON,
		"dataConfigYAML":            dataConfigYAML,
		"dataVer842NodesLocalStats": dataVer842NodesLocalStats,
		"dataVer842NodesStats":      dataVer842NodesStats,
		"dataVer842ClusterHealth":   dataVer842ClusterHealth,
		"dataVer842ClusterStats":    dataVer842ClusterStats,
		"dataVer842CatIndicesStats": dataVer842CatIndicesStats,
		"dataVer842Info":            dataVer842Info,
	} {
		require.NotNil(t, data, name)
	}
}

func TestElasticsearch_ConfigurationSerialize(t *testing.T) {
	module.TestConfigurationSerialize(t, &Elasticsearch{}, dataConfigJSON, dataConfigYAML)
}

func TestElasticsearch_Init(t *testing.T) {
	tests := map[string]struct {
		config   Config
		wantFail bool
	}{
		"default": {
			config: New().Config,
		},
		"all stats": {
			config: Config{
				HTTP: web.HTTP{
					Request: web.Request{URL: "http://127.0.0.1:38001"},
				},
				DoNodeStats:     true,
				DoClusterHealth: true,
				DoClusterStats:  true,
				DoIndicesStats:  true,
			},
		},
		"only node_stats": {
			config: Config{
				HTTP: web.HTTP{
					Request: web.Request{URL: "http://127.0.0.1:38001"},
				},
				DoNodeStats:     true,
				DoClusterHealth: false,
				DoClusterStats:  false,
				DoIndicesStats:  false,
			},
		},
		"URL not set": {
			wantFail: true,
			config: Config{
				HTTP: web.HTTP{
					Request: web.Request{URL: ""},
				}},
		},
		"invalid TLSCA": {
			wantFail: true,
			config: Config{
				HTTP: web.HTTP{
					Client: web.Client{
						TLSConfig: tlscfg.TLSConfig{TLSCA: "testdata/tls"},
					},
				}},
		},
		"all API calls are disabled": {
			wantFail: true,
			config: Config{
				HTTP: web.HTTP{
					Request: web.Request{URL: "http://127.0.0.1:38001"},
				},
				DoNodeStats:     false,
				DoClusterHealth: false,
				DoClusterStats:  false,
				DoIndicesStats:  false,
			},
		},
	}

	for name, test := range tests {
		t.Run(name, func(t *testing.T) {
			es := New()
			es.Config = test.config

			if test.wantFail {
				assert.Error(t, es.Init())
			} else {
				assert.NoError(t, es.Init())
			}
		})
	}
}

func TestElasticsearch_Check(t *testing.T) {
	tests := map[string]struct {
		prepare  func(*testing.T) (es *Elasticsearch, cleanup func())
		wantFail bool
	}{
		"valid data":         {prepare: prepareElasticsearchValidData},
		"invalid data":       {prepare: prepareElasticsearchInvalidData, wantFail: true},
		"404":                {prepare: prepareElasticsearch404, wantFail: true},
		"connection refused": {prepare: prepareElasticsearchConnectionRefused, wantFail: true},
	}

	for name, test := range tests {
		t.Run(name, func(t *testing.T) {
			es, cleanup := test.prepare(t)
			defer cleanup()

			if test.wantFail {
				assert.Error(t, es.Check())
			} else {
				assert.NoError(t, es.Check())
			}
		})
	}
}

func TestElasticsearch_Charts(t *testing.T) {
	assert.NotNil(t, New().Charts())
}

func TestElasticsearch_Cleanup(t *testing.T) {
	assert.NotPanics(t, New().Cleanup)
}

func TestElasticsearch_Collect(t *testing.T) {
	tests := map[string]struct {
		prepare       func() *Elasticsearch
		wantCollected map[string]int64
		wantCharts    int
	}{
		"v842: all nodes stats": {
			prepare: func() *Elasticsearch {
				es := New()
				es.ClusterMode = true
				es.DoNodeStats = true
				es.DoClusterHealth = false
				es.DoClusterStats = false
				es.DoIndicesStats = false
				return es
			},
			wantCharts: len(nodeChartsTmpl) * 3,
			wantCollected: map[string]int64{
				"node_Klg1CjgMTouentQcJlRGuA_breakers_accounting_tripped":                       0,
				"node_Klg1CjgMTouentQcJlRGuA_breakers_fielddata_tripped":                        0,
				"node_Klg1CjgMTouentQcJlRGuA_breakers_in_flight_requests_tripped":               0,
				"node_Klg1CjgMTouentQcJlRGuA_breakers_model_inference_tripped":                  0,
				"node_Klg1CjgMTouentQcJlRGuA_breakers_parent_tripped":                           0,
				"node_Klg1CjgMTouentQcJlRGuA_breakers_request_tripped":                          0,
				"node_Klg1CjgMTouentQcJlRGuA_http_current_open":                                 75,
				"node_Klg1CjgMTouentQcJlRGuA_indices_fielddata_evictions":                       0,
				"node_Klg1CjgMTouentQcJlRGuA_indices_fielddata_memory_size_in_bytes":            600,
				"node_Klg1CjgMTouentQcJlRGuA_indices_flush_total":                               35130,
				"node_Klg1CjgMTouentQcJlRGuA_indices_flush_total_time_in_millis":                22204637,
				"node_Klg1CjgMTouentQcJlRGuA_indices_indexing_index_current":                    0,
				"node_Klg1CjgMTouentQcJlRGuA_indices_indexing_index_time_in_millis":             1100012973,
				"node_Klg1CjgMTouentQcJlRGuA_indices_indexing_index_total":                      3667364815,
				"node_Klg1CjgMTouentQcJlRGuA_indices_refresh_total":                             7720800,
				"node_Klg1CjgMTouentQcJlRGuA_indices_refresh_total_time_in_millis":              94297737,
				"node_Klg1CjgMTouentQcJlRGuA_indices_search_fetch_current":                      0,
				"node_Klg1CjgMTouentQcJlRGuA_indices_search_fetch_time_in_millis":               21316723,
				"node_Klg1CjgMTouentQcJlRGuA_indices_search_fetch_total":                        42642621,
				"node_Klg1CjgMTouentQcJlRGuA_indices_search_query_current":                      0,
				"node_Klg1CjgMTouentQcJlRGuA_indices_search_query_time_in_millis":               51262303,
				"node_Klg1CjgMTouentQcJlRGuA_indices_search_query_total":                        166820275,
				"node_Klg1CjgMTouentQcJlRGuA_indices_segments_count":                            320,
				"node_Klg1CjgMTouentQcJlRGuA_indices_segments_doc_values_memory_in_bytes":       0,
				"node_Klg1CjgMTouentQcJlRGuA_indices_segments_fixed_bit_set_memory_in_bytes":    1904,
				"node_Klg1CjgMTouentQcJlRGuA_indices_segments_index_writer_memory_in_bytes":     262022568,
				"node_Klg1CjgMTouentQcJlRGuA_indices_segments_memory_in_bytes":                  0,
				"node_Klg1CjgMTouentQcJlRGuA_indices_segments_norms_memory_in_bytes":            0,
				"node_Klg1CjgMTouentQcJlRGuA_indices_segments_points_memory_in_bytes":           0,
				"node_Klg1CjgMTouentQcJlRGuA_indices_segments_stored_fields_memory_in_bytes":    0,
				"node_Klg1CjgMTouentQcJlRGuA_indices_segments_term_vectors_memory_in_bytes":     0,
				"node_Klg1CjgMTouentQcJlRGuA_indices_segments_terms_memory_in_bytes":            0,
				"node_Klg1CjgMTouentQcJlRGuA_indices_segments_version_map_memory_in_bytes":      49200018,
				"node_Klg1CjgMTouentQcJlRGuA_indices_translog_operations":                       352376,
				"node_Klg1CjgMTouentQcJlRGuA_indices_translog_size_in_bytes":                    447695989,
				"node_Klg1CjgMTouentQcJlRGuA_indices_translog_uncommitted_operations":           352376,
				"node_Klg1CjgMTouentQcJlRGuA_indices_translog_uncommitted_size_in_bytes":        447695989,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_buffer_pools_direct_count":                     94,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_buffer_pools_direct_total_capacity_in_bytes":   4654848,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_buffer_pools_direct_used_in_bytes":             4654850,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_buffer_pools_mapped_count":                     858,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_buffer_pools_mapped_total_capacity_in_bytes":   103114998135,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_buffer_pools_mapped_used_in_bytes":             103114998135,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_gc_collectors_old_collection_count":            0,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_gc_collectors_old_collection_time_in_millis":   0,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_gc_collectors_young_collection_count":          78652,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_gc_collectors_young_collection_time_in_millis": 6014274,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_mem_heap_committed_in_bytes":                   7864320000,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_mem_heap_used_in_bytes":                        5059735552,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_mem_heap_used_percent":                         64,
				"node_Klg1CjgMTouentQcJlRGuA_process_max_file_descriptors":                      1048576,
				"node_Klg1CjgMTouentQcJlRGuA_process_open_file_descriptors":                     1156,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_analyze_queue":                         0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_analyze_rejected":                      0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_fetch_shard_started_queue":             0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_fetch_shard_started_rejected":          0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_fetch_shard_store_queue":               0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_fetch_shard_store_rejected":            0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_flush_queue":                           0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_flush_rejected":                        0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_force_merge_queue":                     0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_force_merge_rejected":                  0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_generic_queue":                         0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_generic_rejected":                      0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_get_queue":                             0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_get_rejected":                          0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_listener_queue":                        0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_listener_rejected":                     0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_management_queue":                      0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_management_rejected":                   0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_refresh_queue":                         0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_refresh_rejected":                      0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_search_queue":                          0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_search_rejected":                       0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_search_throttled_queue":                0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_search_throttled_rejected":             0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_snapshot_queue":                        0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_snapshot_rejected":                     0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_warmer_queue":                          0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_warmer_rejected":                       0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_write_queue":                           0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_write_rejected":                        0,
				"node_Klg1CjgMTouentQcJlRGuA_transport_rx_count":                                1300324276,
				"node_Klg1CjgMTouentQcJlRGuA_transport_rx_size_in_bytes":                        1789333458217,
				"node_Klg1CjgMTouentQcJlRGuA_transport_tx_count":                                1300324275,
				"node_Klg1CjgMTouentQcJlRGuA_transport_tx_size_in_bytes":                        2927487680282,
				"node_k_AifYMWQTykjUq3pgE_-w_breakers_accounting_tripped":                       0,
				"node_k_AifYMWQTykjUq3pgE_-w_breakers_fielddata_tripped":                        0,
				"node_k_AifYMWQTykjUq3pgE_-w_breakers_in_flight_requests_tripped":               0,
				"node_k_AifYMWQTykjUq3pgE_-w_breakers_model_inference_tripped":                  0,
				"node_k_AifYMWQTykjUq3pgE_-w_breakers_parent_tripped":                           0,
				"node_k_AifYMWQTykjUq3pgE_-w_breakers_request_tripped":                          0,
				"node_k_AifYMWQTykjUq3pgE_-w_http_current_open":                                 14,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_fielddata_evictions":                       0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_fielddata_memory_size_in_bytes":            0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_flush_total":                               0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_flush_total_time_in_millis":                0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_indexing_index_current":                    0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_indexing_index_time_in_millis":             0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_indexing_index_total":                      0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_refresh_total":                             0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_refresh_total_time_in_millis":              0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_search_fetch_current":                      0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_search_fetch_time_in_millis":               0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_search_fetch_total":                        0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_search_query_current":                      0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_search_query_time_in_millis":               0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_search_query_total":                        0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_segments_count":                            0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_segments_doc_values_memory_in_bytes":       0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_segments_fixed_bit_set_memory_in_bytes":    0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_segments_index_writer_memory_in_bytes":     0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_segments_memory_in_bytes":                  0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_segments_norms_memory_in_bytes":            0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_segments_points_memory_in_bytes":           0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_segments_stored_fields_memory_in_bytes":    0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_segments_term_vectors_memory_in_bytes":     0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_segments_terms_memory_in_bytes":            0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_segments_version_map_memory_in_bytes":      0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_translog_operations":                       0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_translog_size_in_bytes":                    0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_translog_uncommitted_operations":           0,
				"node_k_AifYMWQTykjUq3pgE_-w_indices_translog_uncommitted_size_in_bytes":        0,
				"node_k_AifYMWQTykjUq3pgE_-w_jvm_buffer_pools_direct_count":                     19,
				"node_k_AifYMWQTykjUq3pgE_-w_jvm_buffer_pools_direct_total_capacity_in_bytes":   2142214,
				"node_k_AifYMWQTykjUq3pgE_-w_jvm_buffer_pools_direct_used_in_bytes":             2142216,
				"node_k_AifYMWQTykjUq3pgE_-w_jvm_buffer_pools_mapped_count":                     0,
				"node_k_AifYMWQTykjUq3pgE_-w_jvm_buffer_pools_mapped_total_capacity_in_bytes":   0,
				"node_k_AifYMWQTykjUq3pgE_-w_jvm_buffer_pools_mapped_used_in_bytes":             0,
				"node_k_AifYMWQTykjUq3pgE_-w_jvm_gc_collectors_old_collection_count":            0,
				"node_k_AifYMWQTykjUq3pgE_-w_jvm_gc_collectors_old_collection_time_in_millis":   0,
				"node_k_AifYMWQTykjUq3pgE_-w_jvm_gc_collectors_young_collection_count":          342994,
				"node_k_AifYMWQTykjUq3pgE_-w_jvm_gc_collectors_young_collection_time_in_millis": 768917,
				"node_k_AifYMWQTykjUq3pgE_-w_jvm_mem_heap_committed_in_bytes":                   281018368,
				"node_k_AifYMWQTykjUq3pgE_-w_jvm_mem_heap_used_in_bytes":                        178362704,
				"node_k_AifYMWQTykjUq3pgE_-w_jvm_mem_heap_used_percent":                         63,
				"node_k_AifYMWQTykjUq3pgE_-w_process_max_file_descriptors":                      1048576,
				"node_k_AifYMWQTykjUq3pgE_-w_process_open_file_descriptors":                     557,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_analyze_queue":                         0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_analyze_rejected":                      0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_fetch_shard_started_queue":             0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_fetch_shard_started_rejected":          0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_fetch_shard_store_queue":               0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_fetch_shard_store_rejected":            0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_flush_queue":                           0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_flush_rejected":                        0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_force_merge_queue":                     0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_force_merge_rejected":                  0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_generic_queue":                         0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_generic_rejected":                      0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_get_queue":                             0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_get_rejected":                          0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_listener_queue":                        0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_listener_rejected":                     0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_management_queue":                      0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_management_rejected":                   0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_refresh_queue":                         0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_refresh_rejected":                      0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_search_queue":                          0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_search_rejected":                       0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_search_throttled_queue":                0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_search_throttled_rejected":             0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_snapshot_queue":                        0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_snapshot_rejected":                     0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_warmer_queue":                          0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_warmer_rejected":                       0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_write_queue":                           0,
				"node_k_AifYMWQTykjUq3pgE_-w_thread_pool_write_rejected":                        0,
				"node_k_AifYMWQTykjUq3pgE_-w_transport_rx_count":                                107632996,
				"node_k_AifYMWQTykjUq3pgE_-w_transport_rx_size_in_bytes":                        180620082152,
				"node_k_AifYMWQTykjUq3pgE_-w_transport_tx_count":                                107633007,
				"node_k_AifYMWQTykjUq3pgE_-w_transport_tx_size_in_bytes":                        420999501235,
				"node_tk_U7GMCRkCG4FoOvusrng_breakers_accounting_tripped":                       0,
				"node_tk_U7GMCRkCG4FoOvusrng_breakers_fielddata_tripped":                        0,
				"node_tk_U7GMCRkCG4FoOvusrng_breakers_in_flight_requests_tripped":               0,
				"node_tk_U7GMCRkCG4FoOvusrng_breakers_model_inference_tripped":                  0,
				"node_tk_U7GMCRkCG4FoOvusrng_breakers_parent_tripped":                           93,
				"node_tk_U7GMCRkCG4FoOvusrng_breakers_request_tripped":                          1,
				"node_tk_U7GMCRkCG4FoOvusrng_http_current_open":                                 84,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_fielddata_evictions":                       0,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_fielddata_memory_size_in_bytes":            0,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_flush_total":                               67895,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_flush_total_time_in_millis":                81917283,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_indexing_index_current":                    0,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_indexing_index_time_in_millis":             1244633519,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_indexing_index_total":                      6550378755,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_refresh_total":                             12359783,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_refresh_total_time_in_millis":              300152615,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_search_fetch_current":                      0,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_search_fetch_time_in_millis":               24517851,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_search_fetch_total":                        25105951,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_search_query_current":                      0,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_search_query_time_in_millis":               158980385,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_search_query_total":                        157912598,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_segments_count":                            291,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_segments_doc_values_memory_in_bytes":       0,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_segments_fixed_bit_set_memory_in_bytes":    55672,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_segments_index_writer_memory_in_bytes":     57432664,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_segments_memory_in_bytes":                  0,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_segments_norms_memory_in_bytes":            0,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_segments_points_memory_in_bytes":           0,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_segments_stored_fields_memory_in_bytes":    0,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_segments_term_vectors_memory_in_bytes":     0,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_segments_terms_memory_in_bytes":            0,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_segments_version_map_memory_in_bytes":      568,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_translog_operations":                       1449698,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_translog_size_in_bytes":                    1214204014,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_translog_uncommitted_operations":           1449698,
				"node_tk_U7GMCRkCG4FoOvusrng_indices_translog_uncommitted_size_in_bytes":        1214204014,
				"node_tk_U7GMCRkCG4FoOvusrng_jvm_buffer_pools_direct_count":                     90,
				"node_tk_U7GMCRkCG4FoOvusrng_jvm_buffer_pools_direct_total_capacity_in_bytes":   4571711,
				"node_tk_U7GMCRkCG4FoOvusrng_jvm_buffer_pools_direct_used_in_bytes":             4571713,
				"node_tk_U7GMCRkCG4FoOvusrng_jvm_buffer_pools_mapped_count":                     831,
				"node_tk_U7GMCRkCG4FoOvusrng_jvm_buffer_pools_mapped_total_capacity_in_bytes":   99844219805,
				"node_tk_U7GMCRkCG4FoOvusrng_jvm_buffer_pools_mapped_used_in_bytes":             99844219805,
				"node_tk_U7GMCRkCG4FoOvusrng_jvm_gc_collectors_old_collection_count":            1,
				"node_tk_U7GMCRkCG4FoOvusrng_jvm_gc_collectors_old_collection_time_in_millis":   796,
				"node_tk_U7GMCRkCG4FoOvusrng_jvm_gc_collectors_young_collection_count":          139959,
				"node_tk_U7GMCRkCG4FoOvusrng_jvm_gc_collectors_young_collection_time_in_millis": 3581668,
				"node_tk_U7GMCRkCG4FoOvusrng_jvm_mem_heap_committed_in_bytes":                   7864320000,
				"node_tk_U7GMCRkCG4FoOvusrng_jvm_mem_heap_used_in_bytes":                        1884124192,
				"node_tk_U7GMCRkCG4FoOvusrng_jvm_mem_heap_used_percent":                         23,
				"node_tk_U7GMCRkCG4FoOvusrng_process_max_file_descriptors":                      1048576,
				"node_tk_U7GMCRkCG4FoOvusrng_process_open_file_descriptors":                     1180,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_analyze_queue":                         0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_analyze_rejected":                      0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_fetch_shard_started_queue":             0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_fetch_shard_started_rejected":          0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_fetch_shard_store_queue":               0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_fetch_shard_store_rejected":            0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_flush_queue":                           0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_flush_rejected":                        0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_force_merge_queue":                     0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_force_merge_rejected":                  0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_generic_queue":                         0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_generic_rejected":                      0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_get_queue":                             0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_get_rejected":                          0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_listener_queue":                        0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_listener_rejected":                     0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_management_queue":                      0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_management_rejected":                   0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_refresh_queue":                         0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_refresh_rejected":                      0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_search_queue":                          0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_search_rejected":                       0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_search_throttled_queue":                0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_search_throttled_rejected":             0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_snapshot_queue":                        0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_snapshot_rejected":                     0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_warmer_queue":                          0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_warmer_rejected":                       0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_write_queue":                           0,
				"node_tk_U7GMCRkCG4FoOvusrng_thread_pool_write_rejected":                        0,
				"node_tk_U7GMCRkCG4FoOvusrng_transport_rx_count":                                2167879292,
				"node_tk_U7GMCRkCG4FoOvusrng_transport_rx_size_in_bytes":                        4905919297323,
				"node_tk_U7GMCRkCG4FoOvusrng_transport_tx_count":                                2167879293,
				"node_tk_U7GMCRkCG4FoOvusrng_transport_tx_size_in_bytes":                        2964638852652,
			},
		},
		"v842: local node stats": {
			prepare: func() *Elasticsearch {
				es := New()
				es.DoNodeStats = true
				es.DoClusterHealth = false
				es.DoClusterStats = false
				es.DoIndicesStats = false
				return es
			},
			wantCharts: len(nodeChartsTmpl),
			wantCollected: map[string]int64{
				"node_Klg1CjgMTouentQcJlRGuA_breakers_accounting_tripped":                       0,
				"node_Klg1CjgMTouentQcJlRGuA_breakers_fielddata_tripped":                        0,
				"node_Klg1CjgMTouentQcJlRGuA_breakers_in_flight_requests_tripped":               0,
				"node_Klg1CjgMTouentQcJlRGuA_breakers_model_inference_tripped":                  0,
				"node_Klg1CjgMTouentQcJlRGuA_breakers_parent_tripped":                           0,
				"node_Klg1CjgMTouentQcJlRGuA_breakers_request_tripped":                          0,
				"node_Klg1CjgMTouentQcJlRGuA_http_current_open":                                 73,
				"node_Klg1CjgMTouentQcJlRGuA_indices_fielddata_evictions":                       0,
				"node_Klg1CjgMTouentQcJlRGuA_indices_fielddata_memory_size_in_bytes":            600,
				"node_Klg1CjgMTouentQcJlRGuA_indices_flush_total":                               35134,
				"node_Klg1CjgMTouentQcJlRGuA_indices_flush_total_time_in_millis":                22213090,
				"node_Klg1CjgMTouentQcJlRGuA_indices_indexing_index_current":                    1,
				"node_Klg1CjgMTouentQcJlRGuA_indices_indexing_index_time_in_millis":             1100149051,
				"node_Klg1CjgMTouentQcJlRGuA_indices_indexing_index_total":                      3667793202,
				"node_Klg1CjgMTouentQcJlRGuA_indices_refresh_total":                             7721472,
				"node_Klg1CjgMTouentQcJlRGuA_indices_refresh_total_time_in_millis":              94304142,
				"node_Klg1CjgMTouentQcJlRGuA_indices_search_fetch_current":                      0,
				"node_Klg1CjgMTouentQcJlRGuA_indices_search_fetch_time_in_millis":               21316820,
				"node_Klg1CjgMTouentQcJlRGuA_indices_search_fetch_total":                        42645288,
				"node_Klg1CjgMTouentQcJlRGuA_indices_search_query_current":                      0,
				"node_Klg1CjgMTouentQcJlRGuA_indices_search_query_time_in_millis":               51265805,
				"node_Klg1CjgMTouentQcJlRGuA_indices_search_query_total":                        166823028,
				"node_Klg1CjgMTouentQcJlRGuA_indices_segments_count":                            307,
				"node_Klg1CjgMTouentQcJlRGuA_indices_segments_doc_values_memory_in_bytes":       0,
				"node_Klg1CjgMTouentQcJlRGuA_indices_segments_fixed_bit_set_memory_in_bytes":    2008,
				"node_Klg1CjgMTouentQcJlRGuA_indices_segments_index_writer_memory_in_bytes":     240481008,
				"node_Klg1CjgMTouentQcJlRGuA_indices_segments_memory_in_bytes":                  0,
				"node_Klg1CjgMTouentQcJlRGuA_indices_segments_norms_memory_in_bytes":            0,
				"node_Klg1CjgMTouentQcJlRGuA_indices_segments_points_memory_in_bytes":           0,
				"node_Klg1CjgMTouentQcJlRGuA_indices_segments_stored_fields_memory_in_bytes":    0,
				"node_Klg1CjgMTouentQcJlRGuA_indices_segments_term_vectors_memory_in_bytes":     0,
				"node_Klg1CjgMTouentQcJlRGuA_indices_segments_terms_memory_in_bytes":            0,
				"node_Klg1CjgMTouentQcJlRGuA_indices_segments_version_map_memory_in_bytes":      44339216,
				"node_Klg1CjgMTouentQcJlRGuA_indices_translog_operations":                       362831,
				"node_Klg1CjgMTouentQcJlRGuA_indices_translog_size_in_bytes":                    453491882,
				"node_Klg1CjgMTouentQcJlRGuA_indices_translog_uncommitted_operations":           362831,
				"node_Klg1CjgMTouentQcJlRGuA_indices_translog_uncommitted_size_in_bytes":        453491882,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_buffer_pools_direct_count":                     94,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_buffer_pools_direct_total_capacity_in_bytes":   4654848,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_buffer_pools_direct_used_in_bytes":             4654850,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_buffer_pools_mapped_count":                     844,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_buffer_pools_mapped_total_capacity_in_bytes":   103411995802,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_buffer_pools_mapped_used_in_bytes":             103411995802,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_gc_collectors_old_collection_count":            0,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_gc_collectors_old_collection_time_in_millis":   0,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_gc_collectors_young_collection_count":          78661,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_gc_collectors_young_collection_time_in_millis": 6014901,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_mem_heap_committed_in_bytes":                   7864320000,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_mem_heap_used_in_bytes":                        4337402488,
				"node_Klg1CjgMTouentQcJlRGuA_jvm_mem_heap_used_percent":                         55,
				"node_Klg1CjgMTouentQcJlRGuA_process_max_file_descriptors":                      1048576,
				"node_Klg1CjgMTouentQcJlRGuA_process_open_file_descriptors":                     1149,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_analyze_queue":                         0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_analyze_rejected":                      0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_fetch_shard_started_queue":             0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_fetch_shard_started_rejected":          0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_fetch_shard_store_queue":               0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_fetch_shard_store_rejected":            0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_flush_queue":                           0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_flush_rejected":                        0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_force_merge_queue":                     0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_force_merge_rejected":                  0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_generic_queue":                         0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_generic_rejected":                      0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_get_queue":                             0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_get_rejected":                          0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_listener_queue":                        0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_listener_rejected":                     0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_management_queue":                      0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_management_rejected":                   0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_refresh_queue":                         0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_refresh_rejected":                      0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_search_queue":                          0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_search_rejected":                       0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_search_throttled_queue":                0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_search_throttled_rejected":             0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_snapshot_queue":                        0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_snapshot_rejected":                     0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_warmer_queue":                          0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_warmer_rejected":                       0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_write_queue":                           0,
				"node_Klg1CjgMTouentQcJlRGuA_thread_pool_write_rejected":                        0,
				"node_Klg1CjgMTouentQcJlRGuA_transport_rx_count":                                1300468666,
				"node_Klg1CjgMTouentQcJlRGuA_transport_rx_size_in_bytes":                        1789647854011,
				"node_Klg1CjgMTouentQcJlRGuA_transport_tx_count":                                1300468665,
				"node_Klg1CjgMTouentQcJlRGuA_transport_tx_size_in_bytes":                        2927853534431,
			},
		},
		"v842: only cluster_health": {
			prepare: func() *Elasticsearch {
				es := New()
				es.DoNodeStats = false
				es.DoClusterHealth = true
				es.DoClusterStats = false
				es.DoIndicesStats = false
				return es
			},
			wantCharts: len(clusterHealthChartsTmpl),
			wantCollected: map[string]int64{
				"cluster_active_primary_shards":           97,
				"cluster_active_shards":                   194,
				"cluster_active_shards_percent_as_number": 100,
				"cluster_delayed_unassigned_shards":       0,
				"cluster_initializing_shards":             0,
				"cluster_number_of_data_nodes":            2,
				"cluster_number_of_in_flight_fetch":       0,
				"cluster_number_of_nodes":                 3,
				"cluster_number_of_pending_tasks":         0,
				"cluster_relocating_shards":               0,
				"cluster_status_green":                    1,
				"cluster_status_red":                      0,
				"cluster_status_yellow":                   0,
				"cluster_unassigned_shards":               0,
			},
		},
		"v842: only cluster_stats": {
			prepare: func() *Elasticsearch {
				es := New()
				es.DoNodeStats = false
				es.DoClusterHealth = false
				es.DoClusterStats = true
				es.DoIndicesStats = false
				return es
			},
			wantCharts: len(clusterStatsChartsTmpl),
			wantCollected: map[string]int64{
				"cluster_indices_count":                     97,
				"cluster_indices_docs_count":                402750703,
				"cluster_indices_query_cache_hit_count":     96838726,
				"cluster_indices_query_cache_miss_count":    587768226,
				"cluster_indices_shards_primaries":          97,
				"cluster_indices_shards_replication":        1,
				"cluster_indices_shards_total":              194,
				"cluster_indices_store_size_in_bytes":       380826136962,
				"cluster_nodes_count_coordinating_only":     0,
				"cluster_nodes_count_data":                  0,
				"cluster_nodes_count_data_cold":             0,
				"cluster_nodes_count_data_content":          2,
				"cluster_nodes_count_data_frozen":           0,
				"cluster_nodes_count_data_hot":              2,
				"cluster_nodes_count_data_warm":             0,
				"cluster_nodes_count_ingest":                2,
				"cluster_nodes_count_master":                3,
				"cluster_nodes_count_ml":                    0,
				"cluster_nodes_count_remote_cluster_client": 2,
				"cluster_nodes_count_total":                 3,
				"cluster_nodes_count_transform":             2,
				"cluster_nodes_count_voting_only":           1,
			},
		},
		"v842: only indices_stats": {
			prepare: func() *Elasticsearch {
				es := New()
				es.DoNodeStats = false
				es.DoClusterHealth = false
				es.DoClusterStats = false
				es.DoIndicesStats = true
				return es
			},
			wantCharts: len(nodeIndexChartsTmpl) * 3,
			wantCollected: map[string]int64{
				"node_index_my-index-000001_stats_docs_count":          1,
				"node_index_my-index-000001_stats_health_green":        0,
				"node_index_my-index-000001_stats_health_red":          0,
				"node_index_my-index-000001_stats_health_yellow":       1,
				"node_index_my-index-000001_stats_shards_count":        1,
				"node_index_my-index-000001_stats_store_size_in_bytes": 208,
				"node_index_my-index-000002_stats_docs_count":          1,
				"node_index_my-index-000002_stats_health_green":        0,
				"node_index_my-index-000002_stats_health_red":          0,
				"node_index_my-index-000002_stats_health_yellow":       1,
				"node_index_my-index-000002_stats_shards_count":        1,
				"node_index_my-index-000002_stats_store_size_in_bytes": 208,
				"node_index_my-index-000003_stats_docs_count":          1,
				"node_index_my-index-000003_stats_health_green":        0,
				"node_index_my-index-000003_stats_health_red":          0,
				"node_index_my-index-000003_stats_health_yellow":       1,
				"node_index_my-index-000003_stats_shards_count":        1,
				"node_index_my-index-000003_stats_store_size_in_bytes": 208,
			},
		},
	}

	for name, test := range tests {
		t.Run(name, func(t *testing.T) {
			es, cleanup := prepareElasticsearch(t, test.prepare)
			defer cleanup()

			var mx map[string]int64
			for i := 0; i < 10; i++ {
				mx = es.Collect()
			}

			//m := mx
			//l := make([]string, 0)
			//for k := range m {
			//	l = append(l, k)
			//}
			//sort.Strings(l)
			//for _, value := range l {
			//	fmt.Println(fmt.Sprintf("\"%s\": %d,", value, m[value]))
			//}
			//return

			assert.Equal(t, test.wantCollected, mx)
			assert.Len(t, *es.Charts(), test.wantCharts)
			ensureCollectedHasAllChartsDimsVarsIDs(t, es, mx)
		})
	}
}

func ensureCollectedHasAllChartsDimsVarsIDs(t *testing.T, es *Elasticsearch, collected map[string]int64) {
	for _, chart := range *es.Charts() {
		if chart.Obsolete {
			continue
		}
		for _, dim := range chart.Dims {
			_, ok := collected[dim.ID]
			assert.Truef(t, ok, "collected metrics has no data for dim '%s' chart '%s'", dim.ID, chart.ID)
		}
		for _, v := range chart.Vars {
			_, ok := collected[v.ID]
			assert.Truef(t, ok, "collected metrics has no data for var '%s' chart '%s'", v.ID, chart.ID)
		}
	}
}

func prepareElasticsearch(t *testing.T, createES func() *Elasticsearch) (es *Elasticsearch, cleanup func()) {
	t.Helper()
	srv := prepareElasticsearchEndpoint()

	es = createES()
	es.URL = srv.URL
	require.NoError(t, es.Init())

	return es, srv.Close
}

func prepareElasticsearchValidData(t *testing.T) (es *Elasticsearch, cleanup func()) {
	return prepareElasticsearch(t, New)
}

func prepareElasticsearchInvalidData(t *testing.T) (*Elasticsearch, func()) {
	t.Helper()
	srv := httptest.NewServer(http.HandlerFunc(
		func(w http.ResponseWriter, r *http.Request) {
			_, _ = w.Write([]byte("hello and\n goodbye"))
		}))
	es := New()
	es.URL = srv.URL
	require.NoError(t, es.Init())

	return es, srv.Close
}

func prepareElasticsearch404(t *testing.T) (*Elasticsearch, func()) {
	t.Helper()
	srv := httptest.NewServer(http.HandlerFunc(
		func(w http.ResponseWriter, r *http.Request) {
			w.WriteHeader(http.StatusNotFound)
		}))
	es := New()
	es.URL = srv.URL
	require.NoError(t, es.Init())

	return es, srv.Close
}

func prepareElasticsearchConnectionRefused(t *testing.T) (*Elasticsearch, func()) {
	t.Helper()
	es := New()
	es.URL = "http://127.0.0.1:38001"
	require.NoError(t, es.Init())

	return es, func() {}
}

func prepareElasticsearchEndpoint() *httptest.Server {
	return httptest.NewServer(http.HandlerFunc(
		func(w http.ResponseWriter, r *http.Request) {
			switch r.URL.Path {
			case urlPathNodesStats:
				_, _ = w.Write(dataVer842NodesStats)
			case urlPathLocalNodeStats:
				_, _ = w.Write(dataVer842NodesLocalStats)
			case urlPathClusterHealth:
				_, _ = w.Write(dataVer842ClusterHealth)
			case urlPathClusterStats:
				_, _ = w.Write(dataVer842ClusterStats)
			case urlPathIndicesStats:
				_, _ = w.Write(dataVer842CatIndicesStats)
			case "/":
				_, _ = w.Write(dataVer842Info)
			default:
				w.WriteHeader(http.StatusNotFound)
			}
		}))
}