nodes_stats.go 25 KB

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