1// Copyright 2012-present Oliver Eilhard. All rights reserved.
2// Use of this source code is governed by a MIT-license.
3// See http://olivere.mit-license.org/license.txt for details.
4
5package elastic
6
7import (
8	"context"
9	"encoding/json"
10	"fmt"
11	"net/url"
12	"strings"
13
14	"github.com/olivere/elastic/uritemplates"
15)
16
17// NodesStatsService returns node statistics.
18// See http://www.elastic.co/guide/en/elasticsearch/reference/5.2/cluster-nodes-stats.html
19// for details.
20type NodesStatsService struct {
21	client           *Client
22	pretty           bool
23	metric           []string
24	indexMetric      []string
25	nodeId           []string
26	completionFields []string
27	fielddataFields  []string
28	fields           []string
29	groups           *bool
30	human            *bool
31	level            string
32	timeout          string
33	types            []string
34}
35
36// NewNodesStatsService creates a new NodesStatsService.
37func NewNodesStatsService(client *Client) *NodesStatsService {
38	return &NodesStatsService{
39		client: client,
40	}
41}
42
43// Metric limits the information returned to the specified metrics.
44func (s *NodesStatsService) Metric(metric ...string) *NodesStatsService {
45	s.metric = append(s.metric, metric...)
46	return s
47}
48
49// IndexMetric limits the information returned for `indices` metric
50// to the specific index metrics. Isn't used if `indices` (or `all`)
51// metric isn't specified..
52func (s *NodesStatsService) IndexMetric(indexMetric ...string) *NodesStatsService {
53	s.indexMetric = append(s.indexMetric, indexMetric...)
54	return s
55}
56
57// NodeId is a list of node IDs or names to limit the returned information;
58// use `_local` to return information from the node you're connecting to,
59// leave empty to get information from all nodes.
60func (s *NodesStatsService) NodeId(nodeId ...string) *NodesStatsService {
61	s.nodeId = append(s.nodeId, nodeId...)
62	return s
63}
64
65// CompletionFields is a list of fields for `fielddata` and `suggest`
66// index metric (supports wildcards).
67func (s *NodesStatsService) CompletionFields(completionFields ...string) *NodesStatsService {
68	s.completionFields = append(s.completionFields, completionFields...)
69	return s
70}
71
72// FielddataFields is a list of fields for `fielddata` index metric (supports wildcards).
73func (s *NodesStatsService) FielddataFields(fielddataFields ...string) *NodesStatsService {
74	s.fielddataFields = append(s.fielddataFields, fielddataFields...)
75	return s
76}
77
78// Fields is a list of fields for `fielddata` and `completion` index metric (supports wildcards).
79func (s *NodesStatsService) Fields(fields ...string) *NodesStatsService {
80	s.fields = append(s.fields, fields...)
81	return s
82}
83
84// Groups is a list of search groups for `search` index metric.
85func (s *NodesStatsService) Groups(groups bool) *NodesStatsService {
86	s.groups = &groups
87	return s
88}
89
90// Human indicates whether to return time and byte values in human-readable format.
91func (s *NodesStatsService) Human(human bool) *NodesStatsService {
92	s.human = &human
93	return s
94}
95
96// Level specifies whether to return indices stats aggregated at node, index or shard level.
97func (s *NodesStatsService) Level(level string) *NodesStatsService {
98	s.level = level
99	return s
100}
101
102// Timeout specifies an explicit operation timeout.
103func (s *NodesStatsService) Timeout(timeout string) *NodesStatsService {
104	s.timeout = timeout
105	return s
106}
107
108// Types a list of document types for the `indexing` index metric.
109func (s *NodesStatsService) Types(types ...string) *NodesStatsService {
110	s.types = append(s.types, types...)
111	return s
112}
113
114// Pretty indicates that the JSON response be indented and human readable.
115func (s *NodesStatsService) Pretty(pretty bool) *NodesStatsService {
116	s.pretty = pretty
117	return s
118}
119
120// buildURL builds the URL for the operation.
121func (s *NodesStatsService) buildURL() (string, url.Values, error) {
122	var err error
123	var path string
124
125	if len(s.nodeId) > 0 && len(s.metric) > 0 && len(s.indexMetric) > 0 {
126		path, err = uritemplates.Expand("/_nodes/{node_id}/stats/{metric}/{index_metric}", map[string]string{
127			"index_metric": strings.Join(s.indexMetric, ","),
128			"node_id":      strings.Join(s.nodeId, ","),
129			"metric":       strings.Join(s.metric, ","),
130		})
131	} else if len(s.nodeId) > 0 && len(s.metric) > 0 && len(s.indexMetric) == 0 {
132		path, err = uritemplates.Expand("/_nodes/{node_id}/stats/{metric}", map[string]string{
133			"node_id": strings.Join(s.nodeId, ","),
134			"metric":  strings.Join(s.metric, ","),
135		})
136	} else if len(s.nodeId) > 0 && len(s.metric) == 0 && len(s.indexMetric) > 0 {
137		path, err = uritemplates.Expand("/_nodes/{node_id}/stats/_all/{index_metric}", map[string]string{
138			"index_metric": strings.Join(s.indexMetric, ","),
139			"node_id":      strings.Join(s.nodeId, ","),
140		})
141	} else if len(s.nodeId) > 0 && len(s.metric) == 0 && len(s.indexMetric) == 0 {
142		path, err = uritemplates.Expand("/_nodes/{node_id}/stats", map[string]string{
143			"node_id": strings.Join(s.nodeId, ","),
144		})
145	} else if len(s.nodeId) == 0 && len(s.metric) > 0 && len(s.indexMetric) > 0 {
146		path, err = uritemplates.Expand("/_nodes/stats/{metric}/{index_metric}", map[string]string{
147			"index_metric": strings.Join(s.indexMetric, ","),
148			"metric":       strings.Join(s.metric, ","),
149		})
150	} else if len(s.nodeId) == 0 && len(s.metric) > 0 && len(s.indexMetric) == 0 {
151		path, err = uritemplates.Expand("/_nodes/stats/{metric}", map[string]string{
152			"metric": strings.Join(s.metric, ","),
153		})
154	} else if len(s.nodeId) == 0 && len(s.metric) == 0 && len(s.indexMetric) > 0 {
155		path, err = uritemplates.Expand("/_nodes/stats/_all/{index_metric}", map[string]string{
156			"index_metric": strings.Join(s.indexMetric, ","),
157		})
158	} else { // if len(s.nodeId) == 0 && len(s.metric) == 0 && len(s.indexMetric) == 0 {
159		path = "/_nodes/stats"
160	}
161	if err != nil {
162		return "", url.Values{}, err
163	}
164
165	// Add query string parameters
166	params := url.Values{}
167	if s.pretty {
168		params.Set("pretty", "true")
169	}
170	if len(s.completionFields) > 0 {
171		params.Set("completion_fields", strings.Join(s.completionFields, ","))
172	}
173	if len(s.fielddataFields) > 0 {
174		params.Set("fielddata_fields", strings.Join(s.fielddataFields, ","))
175	}
176	if len(s.fields) > 0 {
177		params.Set("fields", strings.Join(s.fields, ","))
178	}
179	if s.groups != nil {
180		params.Set("groups", fmt.Sprintf("%v", *s.groups))
181	}
182	if s.human != nil {
183		params.Set("human", fmt.Sprintf("%v", *s.human))
184	}
185	if s.level != "" {
186		params.Set("level", s.level)
187	}
188	if s.timeout != "" {
189		params.Set("timeout", s.timeout)
190	}
191	if len(s.types) > 0 {
192		params.Set("types", strings.Join(s.types, ","))
193	}
194	return path, params, nil
195}
196
197// Validate checks if the operation is valid.
198func (s *NodesStatsService) Validate() error {
199	return nil
200}
201
202// Do executes the operation.
203func (s *NodesStatsService) Do(ctx context.Context) (*NodesStatsResponse, error) {
204	// Check pre-conditions
205	if err := s.Validate(); err != nil {
206		return nil, err
207	}
208
209	// Get URL for request
210	path, params, err := s.buildURL()
211	if err != nil {
212		return nil, err
213	}
214
215	// Get HTTP response
216	res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
217		Method: "GET",
218		Path:   path,
219		Params: params,
220	})
221	if err != nil {
222		return nil, err
223	}
224
225	// Return operation response
226	ret := new(NodesStatsResponse)
227	if err := json.Unmarshal(res.Body, ret); err != nil {
228		return nil, err
229	}
230	return ret, nil
231}
232
233// NodesStatsResponse is the response of NodesStatsService.Do.
234type NodesStatsResponse struct {
235	ClusterName string                     `json:"cluster_name"`
236	Nodes       map[string]*NodesStatsNode `json:"nodes"`
237}
238
239type NodesStatsNode struct {
240	// Timestamp when these stats we're gathered.
241	Timestamp int64 `json:"timestamp"`
242	// Name of the node, e.g. "Mister Fear"
243	Name string `json:"name"`
244	// TransportAddress, e.g. "127.0.0.1:9300"
245	TransportAddress string `json:"transport_address"`
246	// Host is the host name, e.g. "macbookair"
247	Host string `json:"host"`
248	// IP is an IP address, e.g. "192.168.1.2"
249	IP string `json:"ip"`
250	// Roles is a list of the roles of the node, e.g. master, data, ingest.
251	Roles []string `json:"roles"`
252
253	// Attributes of the node.
254	Attributes map[string]interface{} `json:"attributes"`
255
256	// Indices returns index information.
257	Indices *NodesStatsIndex `json:"indices"`
258
259	// OS information, e.g. CPU and memory.
260	OS *NodesStatsNodeOS `json:"os"`
261
262	// Process information, e.g. max file descriptors.
263	Process *NodesStatsNodeProcess `json:"process"`
264
265	// JVM information, e.g. VM version.
266	JVM *NodesStatsNodeJVM `json:"jvm"`
267
268	// ThreadPool information.
269	ThreadPool map[string]*NodesStatsNodeThreadPool `json:"thread_pool"`
270
271	// FS returns information about the filesystem.
272	FS *NodesStatsNodeFS `json:"fs"`
273
274	// Network information.
275	Transport *NodesStatsNodeTransport `json:"transport"`
276
277	// HTTP information.
278	HTTP *NodesStatsNodeHTTP `json:"http"`
279
280	// Breaker contains information about circuit breakers.
281	Breaker map[string]*NodesStatsBreaker `json:"breakers"`
282
283	// ScriptStats information.
284	ScriptStats *NodesStatsScriptStats `json:"script"`
285
286	// Discovery information.
287	Discovery *NodesStatsDiscovery `json:"discovery"`
288
289	// Ingest information
290	Ingest *NodesStatsIngest `json:"ingest"`
291}
292
293type NodesStatsIndex struct {
294	Docs         *NodesStatsDocsStats         `json:"docs"`
295	Store        *NodesStatsStoreStats        `json:"store"`
296	Indexing     *NodesStatsIndexingStats     `json:"indexing"`
297	Get          *NodesStatsGetStats          `json:"get"`
298	Search       *NodesStatsSearchStats       `json:"search"`
299	Merges       *NodesStatsMergeStats        `json:"merges"`
300	Refresh      *NodesStatsRefreshStats      `json:"refresh"`
301	Flush        *NodesStatsFlushStats        `json:"flush"`
302	Warmer       *NodesStatsWarmerStats       `json:"warmer"`
303	QueryCache   *NodesStatsQueryCacheStats   `json:"query_cache"`
304	Fielddata    *NodesStatsFielddataStats    `json:"fielddata"`
305	Percolate    *NodesStatsPercolateStats    `json:"percolate"`
306	Completion   *NodesStatsCompletionStats   `json:"completion"`
307	Segments     *NodesStatsSegmentsStats     `json:"segments"`
308	Translog     *NodesStatsTranslogStats     `json:"translog"`
309	Suggest      *NodesStatsSuggestStats      `json:"suggest"`
310	RequestCache *NodesStatsRequestCacheStats `json:"request_cache"`
311	Recovery     NodesStatsRecoveryStats      `json:"recovery"`
312
313	Indices map[string]*NodesStatsIndex `json:"indices"` // for level=indices
314	Shards  map[string]*NodesStatsIndex `json:"shards"`  // for level=shards
315}
316
317type NodesStatsDocsStats struct {
318	Count   int64 `json:"count"`
319	Deleted int64 `json:"deleted"`
320}
321
322type NodesStatsStoreStats struct {
323	Size        string `json:"size"`
324	SizeInBytes int64  `json:"size_in_bytes"`
325}
326
327type NodesStatsIndexingStats struct {
328	IndexTotal         int64  `json:"index_total"`
329	IndexTime          string `json:"index_time"`
330	IndexTimeInMillis  int64  `json:"index_time_in_millis"`
331	IndexCurrent       int64  `json:"index_current"`
332	IndexFailed        int64  `json:"index_failed"`
333	DeleteTotal        int64  `json:"delete_total"`
334	DeleteTime         string `json:"delete_time"`
335	DeleteTimeInMillis int64  `json:"delete_time_in_millis"`
336	DeleteCurrent      int64  `json:"delete_current"`
337	NoopUpdateTotal    int64  `json:"noop_update_total"`
338
339	Types map[string]*NodesStatsIndexingStats `json:"types"` // stats for individual types
340}
341
342type NodesStatsGetStats struct {
343	Total               int64  `json:"total"`
344	Time                string `json:"get_time"`
345	TimeInMillis        int64  `json:"time_in_millis"`
346	Exists              int64  `json:"exists"`
347	ExistsTime          string `json:"exists_time"`
348	ExistsTimeInMillis  int64  `json:"exists_in_millis"`
349	Missing             int64  `json:"missing"`
350	MissingTime         string `json:"missing_time"`
351	MissingTimeInMillis int64  `json:"missing_in_millis"`
352	Current             int64  `json:"current"`
353}
354
355type NodesStatsSearchStats struct {
356	OpenContexts       int64  `json:"open_contexts"`
357	QueryTotal         int64  `json:"query_total"`
358	QueryTime          string `json:"query_time"`
359	QueryTimeInMillis  int64  `json:"query_time_in_millis"`
360	QueryCurrent       int64  `json:"query_current"`
361	FetchTotal         int64  `json:"fetch_total"`
362	FetchTime          string `json:"fetch_time"`
363	FetchTimeInMillis  int64  `json:"fetch_time_in_millis"`
364	FetchCurrent       int64  `json:"fetch_current"`
365	ScrollTotal        int64  `json:"scroll_total"`
366	ScrollTime         string `json:"scroll_time"`
367	ScrollTimeInMillis int64  `json:"scroll_time_in_millis"`
368	ScrollCurrent      int64  `json:"scroll_current"`
369
370	Groups map[string]*NodesStatsSearchStats `json:"groups"` // stats for individual groups
371}
372
373type NodesStatsMergeStats struct {
374	Current                    int64  `json:"current"`
375	CurrentDocs                int64  `json:"current_docs"`
376	CurrentSize                string `json:"current_size"`
377	CurrentSizeInBytes         int64  `json:"current_size_in_bytes"`
378	Total                      int64  `json:"total"`
379	TotalTime                  string `json:"total_time"`
380	TotalTimeInMillis          int64  `json:"total_time_in_millis"`
381	TotalDocs                  int64  `json:"total_docs"`
382	TotalSize                  string `json:"total_size"`
383	TotalSizeInBytes           int64  `json:"total_size_in_bytes"`
384	TotalStoppedTime           string `json:"total_stopped_time"`
385	TotalStoppedTimeInMillis   int64  `json:"total_stopped_time_in_millis"`
386	TotalThrottledTime         string `json:"total_throttled_time"`
387	TotalThrottledTimeInMillis int64  `json:"total_throttled_time_in_millis"`
388	TotalThrottleBytes         string `json:"total_auto_throttle"`
389	TotalThrottleBytesInBytes  int64  `json:"total_auto_throttle_in_bytes"`
390}
391
392type NodesStatsRefreshStats struct {
393	Total             int64  `json:"total"`
394	TotalTime         string `json:"total_time"`
395	TotalTimeInMillis int64  `json:"total_time_in_millis"`
396}
397
398type NodesStatsFlushStats struct {
399	Total             int64  `json:"total"`
400	TotalTime         string `json:"total_time"`
401	TotalTimeInMillis int64  `json:"total_time_in_millis"`
402}
403
404type NodesStatsWarmerStats struct {
405	Current           int64  `json:"current"`
406	Total             int64  `json:"total"`
407	TotalTime         string `json:"total_time"`
408	TotalTimeInMillis int64  `json:"total_time_in_millis"`
409}
410
411type NodesStatsQueryCacheStats struct {
412	MemorySize        string `json:"memory_size"`
413	MemorySizeInBytes int64  `json:"memory_size_in_bytes"`
414	TotalCount        int64  `json:"total_count"`
415	HitCount          int64  `json:"hit_count"`
416	MissCount         int64  `json:"miss_count"`
417	CacheSize         int64  `json:"cache_size"`
418	CacheCount        int64  `json:"cache_count"`
419	Evictions         int64  `json:"evictions"`
420}
421
422type NodesStatsFielddataStats struct {
423	MemorySize        string `json:"memory_size"`
424	MemorySizeInBytes int64  `json:"memory_size_in_bytes"`
425	Evictions         int64  `json:"evictions"`
426	Fields            map[string]struct {
427		MemorySize        string `json:"memory_size"`
428		MemorySizeInBytes int64  `json:"memory_size_in_bytes"`
429	} `json:"fields"`
430}
431
432type NodesStatsPercolateStats struct {
433	Total             int64  `json:"total"`
434	Time              string `json:"time"`
435	TimeInMillis      int64  `json:"time_in_millis"`
436	Current           int64  `json:"current"`
437	MemorySize        string `json:"memory_size"`
438	MemorySizeInBytes int64  `json:"memory_size_in_bytes"`
439	Queries           int64  `json:"queries"`
440}
441
442type NodesStatsCompletionStats struct {
443	Size        string `json:"size"`
444	SizeInBytes int64  `json:"size_in_bytes"`
445	Fields      map[string]struct {
446		Size        string `json:"size"`
447		SizeInBytes int64  `json:"size_in_bytes"`
448	} `json:"fields"`
449}
450
451type NodesStatsSegmentsStats struct {
452	Count                       int64  `json:"count"`
453	Memory                      string `json:"memory"`
454	MemoryInBytes               int64  `json:"memory_in_bytes"`
455	TermsMemory                 string `json:"terms_memory"`
456	TermsMemoryInBytes          int64  `json:"terms_memory_in_bytes"`
457	StoredFieldsMemory          string `json:"stored_fields_memory"`
458	StoredFieldsMemoryInBytes   int64  `json:"stored_fields_memory_in_bytes"`
459	TermVectorsMemory           string `json:"term_vectors_memory"`
460	TermVectorsMemoryInBytes    int64  `json:"term_vectors_memory_in_bytes"`
461	NormsMemory                 string `json:"norms_memory"`
462	NormsMemoryInBytes          int64  `json:"norms_memory_in_bytes"`
463	DocValuesMemory             string `json:"doc_values_memory"`
464	DocValuesMemoryInBytes      int64  `json:"doc_values_memory_in_bytes"`
465	IndexWriterMemory           string `json:"index_writer_memory"`
466	IndexWriterMemoryInBytes    int64  `json:"index_writer_memory_in_bytes"`
467	IndexWriterMaxMemory        string `json:"index_writer_max_memory"`
468	IndexWriterMaxMemoryInBytes int64  `json:"index_writer_max_memory_in_bytes"`
469	VersionMapMemory            string `json:"version_map_memory"`
470	VersionMapMemoryInBytes     int64  `json:"version_map_memory_in_bytes"`
471	FixedBitSetMemory           string `json:"fixed_bit_set"` // not a typo
472	FixedBitSetMemoryInBytes    int64  `json:"fixed_bit_set_memory_in_bytes"`
473}
474
475type NodesStatsTranslogStats struct {
476	Operations  int64  `json:"operations"`
477	Size        string `json:"size"`
478	SizeInBytes int64  `json:"size_in_bytes"`
479}
480
481type NodesStatsSuggestStats struct {
482	Total             int64  `json:"total"`
483	TotalTime         string `json:"total_time"`
484	TotalTimeInMillis int64  `json:"total_time_in_millis"`
485	Current           int64  `json:"current"`
486}
487
488type NodesStatsRequestCacheStats struct {
489	MemorySize        string `json:"memory_size"`
490	MemorySizeInBytes int64  `json:"memory_size_in_bytes"`
491	Evictions         int64  `json:"evictions"`
492	HitCount          int64  `json:"hit_count"`
493	MissCount         int64  `json:"miss_count"`
494}
495
496type NodesStatsRecoveryStats struct {
497	CurrentAsSource int `json:"current_as_source"`
498	CurrentAsTarget int `json:"current_as_target"`
499}
500
501type NodesStatsNodeOS struct {
502	Timestamp int64                 `json:"timestamp"`
503	CPU       *NodesStatsNodeOSCPU  `json:"cpu"`
504	Mem       *NodesStatsNodeOSMem  `json:"mem"`
505	Swap      *NodesStatsNodeOSSwap `json:"swap"`
506}
507
508type NodesStatsNodeOSCPU struct {
509	Percent     int                `json:"percent"`
510	LoadAverage map[string]float64 `json:"load_average"` // keys are: 1m, 5m, and 15m
511}
512
513type NodesStatsNodeOSMem struct {
514	Total        string `json:"total"`
515	TotalInBytes int64  `json:"total_in_bytes"`
516	Free         string `json:"free"`
517	FreeInBytes  int64  `json:"free_in_bytes"`
518	Used         string `json:"used"`
519	UsedInBytes  int64  `json:"used_in_bytes"`
520	FreePercent  int    `json:"free_percent"`
521	UsedPercent  int    `json:"used_percent"`
522}
523
524type NodesStatsNodeOSSwap struct {
525	Total        string `json:"total"`
526	TotalInBytes int64  `json:"total_in_bytes"`
527	Free         string `json:"free"`
528	FreeInBytes  int64  `json:"free_in_bytes"`
529	Used         string `json:"used"`
530	UsedInBytes  int64  `json:"used_in_bytes"`
531}
532
533type NodesStatsNodeProcess struct {
534	Timestamp           int64 `json:"timestamp"`
535	OpenFileDescriptors int64 `json:"open_file_descriptors"`
536	MaxFileDescriptors  int64 `json:"max_file_descriptors"`
537	CPU                 struct {
538		Percent       int    `json:"percent"`
539		Total         string `json:"total"`
540		TotalInMillis int64  `json:"total_in_millis"`
541	} `json:"cpu"`
542	Mem struct {
543		TotalVirtual        string `json:"total_virtual"`
544		TotalVirtualInBytes int64  `json:"total_virtual_in_bytes"`
545	} `json:"mem"`
546}
547
548type NodesStatsNodeJVM struct {
549	Timestamp      int64                                   `json:"timestamp"`
550	Uptime         string                                  `json:"uptime"`
551	UptimeInMillis int64                                   `json:"uptime_in_millis"`
552	Mem            *NodesStatsNodeJVMMem                   `json:"mem"`
553	Threads        *NodesStatsNodeJVMThreads               `json:"threads"`
554	GC             *NodesStatsNodeJVMGC                    `json:"gc"`
555	BufferPools    map[string]*NodesStatsNodeJVMBufferPool `json:"buffer_pools"`
556	Classes        *NodesStatsNodeJVMClasses               `json:"classes"`
557}
558
559type NodesStatsNodeJVMMem struct {
560	HeapUsed                string `json:"heap_used"`
561	HeapUsedInBytes         int64  `json:"heap_used_in_bytes"`
562	HeapUsedPercent         int    `json:"heap_used_percent"`
563	HeapCommitted           string `json:"heap_committed"`
564	HeapCommittedInBytes    int64  `json:"heap_committed_in_bytes"`
565	HeapMax                 string `json:"heap_max"`
566	HeapMaxInBytes          int64  `json:"heap_max_in_bytes"`
567	NonHeapUsed             string `json:"non_heap_used"`
568	NonHeapUsedInBytes      int64  `json:"non_heap_used_in_bytes"`
569	NonHeapCommitted        string `json:"non_heap_committed"`
570	NonHeapCommittedInBytes int64  `json:"non_heap_committed_in_bytes"`
571	Pools                   map[string]struct {
572		Used            string `json:"used"`
573		UsedInBytes     int64  `json:"used_in_bytes"`
574		Max             string `json:"max"`
575		MaxInBytes      int64  `json:"max_in_bytes"`
576		PeakUsed        string `json:"peak_used"`
577		PeakUsedInBytes int64  `json:"peak_used_in_bytes"`
578		PeakMax         string `json:"peak_max"`
579		PeakMaxInBytes  int64  `json:"peak_max_in_bytes"`
580	} `json:"pools"`
581}
582
583type NodesStatsNodeJVMThreads struct {
584	Count     int64 `json:"count"`
585	PeakCount int64 `json:"peak_count"`
586}
587
588type NodesStatsNodeJVMGC struct {
589	Collectors map[string]*NodesStatsNodeJVMGCCollector `json:"collectors"`
590}
591
592type NodesStatsNodeJVMGCCollector struct {
593	CollectionCount        int64  `json:"collection_count"`
594	CollectionTime         string `json:"collection_time"`
595	CollectionTimeInMillis int64  `json:"collection_time_in_millis"`
596}
597
598type NodesStatsNodeJVMBufferPool struct {
599	Count                int64  `json:"count"`
600	TotalCapacity        string `json:"total_capacity"`
601	TotalCapacityInBytes int64  `json:"total_capacity_in_bytes"`
602}
603
604type NodesStatsNodeJVMClasses struct {
605	CurrentLoadedCount int64 `json:"current_loaded_count"`
606	TotalLoadedCount   int64 `json:"total_loaded_count"`
607	TotalUnloadedCount int64 `json:"total_unloaded_count"`
608}
609
610type NodesStatsNodeThreadPool struct {
611	Threads   int   `json:"threads"`
612	Queue     int   `json:"queue"`
613	Active    int   `json:"active"`
614	Rejected  int64 `json:"rejected"`
615	Largest   int   `json:"largest"`
616	Completed int64 `json:"completed"`
617}
618
619type NodesStatsNodeFS struct {
620	Timestamp int64                    `json:"timestamp"`
621	Total     *NodesStatsNodeFSEntry   `json:"total"`
622	Data      []*NodesStatsNodeFSEntry `json:"data"`
623	IOStats   *NodesStatsNodeFSIOStats `json:"io_stats"`
624}
625
626type NodesStatsNodeFSEntry struct {
627	Path             string `json:"path"`
628	Mount            string `json:"mount"`
629	Type             string `json:"type"`
630	Total            string `json:"total"`
631	TotalInBytes     int64  `json:"total_in_bytes"`
632	Free             string `json:"free"`
633	FreeInBytes      int64  `json:"free_in_bytes"`
634	Available        string `json:"available"`
635	AvailableInBytes int64  `json:"available_in_bytes"`
636	Spins            string `json:"spins"`
637}
638
639type NodesStatsNodeFSIOStats struct {
640	Devices []*NodesStatsNodeFSIOStatsEntry `json:"devices"`
641	Total   *NodesStatsNodeFSIOStatsEntry   `json:"total"`
642}
643
644type NodesStatsNodeFSIOStatsEntry struct {
645	DeviceName      string `json:"device_name"`
646	Operations      int64  `json:"operations"`
647	ReadOperations  int64  `json:"read_operations"`
648	WriteOperations int64  `json:"write_operations"`
649	ReadKilobytes   int64  `json:"read_kilobytes"`
650	WriteKilobytes  int64  `json:"write_kilobytes"`
651}
652
653type NodesStatsNodeTransport struct {
654	ServerOpen    int    `json:"server_open"`
655	RxCount       int64  `json:"rx_count"`
656	RxSize        string `json:"rx_size"`
657	RxSizeInBytes int64  `json:"rx_size_in_bytes"`
658	TxCount       int64  `json:"tx_count"`
659	TxSize        string `json:"tx_size"`
660	TxSizeInBytes int64  `json:"tx_size_in_bytes"`
661}
662
663type NodesStatsNodeHTTP struct {
664	CurrentOpen int `json:"current_open"`
665	TotalOpened int `json:"total_opened"`
666}
667
668type NodesStatsBreaker struct {
669	LimitSize            string  `json:"limit_size"`
670	LimitSizeInBytes     int64   `json:"limit_size_in_bytes"`
671	EstimatedSize        string  `json:"estimated_size"`
672	EstimatedSizeInBytes int64   `json:"estimated_size_in_bytes"`
673	Overhead             float64 `json:"overhead"`
674	Tripped              int64   `json:"tripped"`
675}
676
677type NodesStatsScriptStats struct {
678	Compilations   int64 `json:"compilations"`
679	CacheEvictions int64 `json:"cache_evictions"`
680}
681
682type NodesStatsDiscovery struct {
683	ClusterStateQueue *NodesStatsDiscoveryStats `json:"cluster_state_queue"`
684}
685
686type NodesStatsDiscoveryStats struct {
687	Total     int64 `json:"total"`
688	Pending   int64 `json:"pending"`
689	Committed int64 `json:"committed"`
690}
691
692type NodesStatsIngest struct {
693	Total     *NodesStatsIngestStats `json:"total"`
694	Pipelines interface{}            `json:"pipelines"`
695}
696
697type NodesStatsIngestStats struct {
698	Count        int64  `json:"count"`
699	Time         string `json:"time"`
700	TimeInMillis int64  `json:"time_in_millis"`
701	Current      int64  `json:"current"`
702	Failed       int64  `json:"failed"`
703}
704