github.com/netdata/go.d.plugin@v0.58.1/modules/elasticsearch/charts.go (about)

     1  // SPDX-License-Identifier: GPL-3.0-or-later
     2  
     3  package elasticsearch
     4  
     5  import (
     6  	"fmt"
     7  	"strings"
     8  
     9  	"github.com/netdata/go.d.plugin/agent/module"
    10  )
    11  
    12  const (
    13  	prioNodeIndicesIndexingOps = module.Priority + iota
    14  	prioNodeIndicesIndexingOpsCurrent
    15  	prioNodeIndicesIndexingOpsTime
    16  	prioNodeIndicesSearchOps
    17  	prioNodeIndicesSearchOpsCurrent
    18  	prioNodeIndicesSearchOpsTime
    19  	prioNodeIndicesRefreshOps
    20  	prioNodeIndicesRefreshOpsTime
    21  	prioNodeIndicesFlushOps
    22  	prioNodeIndicesFlushOpsTime
    23  	prioNodeIndicesFieldDataMemoryUsage
    24  	prioNodeIndicesFieldDataEvictions
    25  	prioNodeIndicesSegmentsCount
    26  	prioNodeIndicesSegmentsMemoryUsageTotal
    27  	prioNodeIndicesSegmentsMemoryUsage
    28  	prioNodeIndicesTransLogOps
    29  	prioNodeIndexTransLogSize
    30  	prioNodeFileDescriptors
    31  	prioNodeJVMMemHeap
    32  	prioNodeJVMMemHeapBytes
    33  	prioNodeJVMBufferPoolsCount
    34  	prioNodeJVMBufferPoolDirectMemory
    35  	prioNodeJVMBufferPoolMappedMemory
    36  	prioNodeJVMGCCount
    37  	prioNodeJVMGCTime
    38  	prioNodeThreadPoolQueued
    39  	prioNodeThreadPoolRejected
    40  	prioNodeClusterCommunicationPackets
    41  	prioNodeClusterCommunication
    42  	prioNodeHTTPConnections
    43  	prioNodeBreakersTrips
    44  
    45  	prioClusterStatus
    46  	prioClusterNodesCount
    47  	prioClusterShardsCount
    48  	prioClusterPendingTasks
    49  	prioClusterInFlightFetchesCount
    50  
    51  	prioClusterIndicesCount
    52  	prioClusterIndicesShardsCount
    53  	prioClusterIndicesDocsCount
    54  	prioClusterIndicesStoreSize
    55  	prioClusterIndicesQueryCache
    56  	prioClusterNodesByRoleCount
    57  
    58  	prioNodeIndexHealth
    59  	prioNodeIndexShardsCount
    60  	prioNodeIndexDocsCount
    61  	prioNodeIndexStoreSize
    62  )
    63  
    64  var nodeChartsTmpl = module.Charts{
    65  	nodeIndicesIndexingOpsChartTmpl.Copy(),
    66  	nodeIndicesIndexingOpsCurrentChartTmpl.Copy(),
    67  	nodeIndicesIndexingOpsTimeChartTmpl.Copy(),
    68  
    69  	nodeIndicesSearchOpsChartTmpl.Copy(),
    70  	nodeIndicesSearchOpsCurrentChartTmpl.Copy(),
    71  	nodeIndicesSearchOpsTimeChartTmpl.Copy(),
    72  
    73  	nodeIndicesRefreshOpsChartTmpl.Copy(),
    74  	nodeIndicesRefreshOpsTimeChartTmpl.Copy(),
    75  
    76  	nodeIndicesFlushOpsChartTmpl.Copy(),
    77  	nodeIndicesFlushOpsTimeChartTmpl.Copy(),
    78  
    79  	nodeIndicesFieldDataMemoryUsageChartTmpl.Copy(),
    80  	nodeIndicesFieldDataEvictionsChartTmpl.Copy(),
    81  
    82  	nodeIndicesSegmentsCountChartTmpl.Copy(),
    83  	nodeIndicesSegmentsMemoryUsageTotalChartTmpl.Copy(),
    84  	nodeIndicesSegmentsMemoryUsageChartTmpl.Copy(),
    85  
    86  	nodeIndicesTransLogOpsChartTmpl.Copy(),
    87  	nodeIndexTransLogSizeChartTmpl.Copy(),
    88  
    89  	nodeFileDescriptorsChartTmpl.Copy(),
    90  
    91  	nodeJVMMemHeapChartTmpl.Copy(),
    92  	nodeJVMMemHeapBytesChartTmpl.Copy(),
    93  	nodeJVMBufferPoolsCountChartTmpl.Copy(),
    94  	nodeJVMBufferPoolDirectMemoryChartTmpl.Copy(),
    95  	nodeJVMBufferPoolMappedMemoryChartTmpl.Copy(),
    96  	nodeJVMGCCountChartTmpl.Copy(),
    97  	nodeJVMGCTimeChartTmpl.Copy(),
    98  
    99  	nodeThreadPoolQueuedChartTmpl.Copy(),
   100  	nodeThreadPoolRejectedChartTmpl.Copy(),
   101  
   102  	nodeClusterCommunicationPacketsChartTmpl.Copy(),
   103  	nodeClusterCommunicationChartTmpl.Copy(),
   104  
   105  	nodeHTTPConnectionsChartTmpl.Copy(),
   106  
   107  	nodeBreakersTripsChartTmpl.Copy(),
   108  }
   109  
   110  var (
   111  	nodeIndicesIndexingOpsChartTmpl = module.Chart{
   112  		ID:       "node_%s_cluster_%s_indices_indexing_operations",
   113  		Title:    "Indexing Operations",
   114  		Units:    "operations/s",
   115  		Fam:      "indices indexing",
   116  		Ctx:      "elasticsearch.node_indices_indexing",
   117  		Priority: prioNodeIndicesIndexingOps,
   118  		Dims: module.Dims{
   119  			{ID: "node_%s_indices_indexing_index_total", Name: "index", Algo: module.Incremental},
   120  		},
   121  	}
   122  	nodeIndicesIndexingOpsCurrentChartTmpl = module.Chart{
   123  		ID:       "node_%s_cluster_%s_indices_indexing_operations_current",
   124  		Title:    "Indexing Operations Current",
   125  		Units:    "operations",
   126  		Fam:      "indices indexing",
   127  		Ctx:      "elasticsearch.node_indices_indexing_current",
   128  		Priority: prioNodeIndicesIndexingOpsCurrent,
   129  		Dims: module.Dims{
   130  			{ID: "node_%s_indices_indexing_index_current", Name: "index"},
   131  		},
   132  	}
   133  	nodeIndicesIndexingOpsTimeChartTmpl = module.Chart{
   134  		ID:       "node_%s_cluster_%s_indices_indexing_operations_time",
   135  		Title:    "Time Spent On Indexing Operations",
   136  		Units:    "milliseconds",
   137  		Fam:      "indices indexing",
   138  		Ctx:      "elasticsearch.node_indices_indexing_time",
   139  		Priority: prioNodeIndicesIndexingOpsTime,
   140  		Dims: module.Dims{
   141  			{ID: "node_%s_indices_indexing_index_time_in_millis", Name: "index", Algo: module.Incremental},
   142  		},
   143  	}
   144  
   145  	nodeIndicesSearchOpsChartTmpl = module.Chart{
   146  		ID:       "node_%s_cluster_%s_indices_search_operations",
   147  		Title:    "Search Operations",
   148  		Units:    "operations/s",
   149  		Fam:      "indices search",
   150  		Ctx:      "elasticsearch.node_indices_search",
   151  		Type:     module.Stacked,
   152  		Priority: prioNodeIndicesSearchOps,
   153  		Dims: module.Dims{
   154  			{ID: "node_%s_indices_search_query_total", Name: "queries", Algo: module.Incremental},
   155  			{ID: "node_%s_indices_search_fetch_total", Name: "fetches", Algo: module.Incremental},
   156  		},
   157  	}
   158  	nodeIndicesSearchOpsCurrentChartTmpl = module.Chart{
   159  		ID:       "node_%s_cluster_%s_indices_search_operations_current",
   160  		Title:    "Search Operations Current",
   161  		Units:    "operations",
   162  		Fam:      "indices search",
   163  		Ctx:      "elasticsearch.node_indices_search_current",
   164  		Type:     module.Stacked,
   165  		Priority: prioNodeIndicesSearchOpsCurrent,
   166  		Dims: module.Dims{
   167  			{ID: "node_%s_indices_search_query_current", Name: "queries"},
   168  			{ID: "node_%s_indices_search_fetch_current", Name: "fetches"},
   169  		},
   170  	}
   171  	nodeIndicesSearchOpsTimeChartTmpl = module.Chart{
   172  		ID:       "node_%s_cluster_%s_indices_search_operations_time",
   173  		Title:    "Time Spent On Search Operations",
   174  		Units:    "milliseconds",
   175  		Fam:      "indices search",
   176  		Ctx:      "elasticsearch.node_indices_search_time",
   177  		Type:     module.Stacked,
   178  		Priority: prioNodeIndicesSearchOpsTime,
   179  		Dims: module.Dims{
   180  			{ID: "node_%s_indices_search_query_time_in_millis", Name: "query", Algo: module.Incremental},
   181  			{ID: "node_%s_indices_search_fetch_time_in_millis", Name: "fetch", Algo: module.Incremental},
   182  		},
   183  	}
   184  
   185  	nodeIndicesRefreshOpsChartTmpl = module.Chart{
   186  		ID:       "node_%s_cluster_%s_indices_refresh_operations",
   187  		Title:    "Refresh Operations",
   188  		Units:    "operations/s",
   189  		Fam:      "indices refresh",
   190  		Ctx:      "elasticsearch.node_indices_refresh",
   191  		Priority: prioNodeIndicesRefreshOps,
   192  		Dims: module.Dims{
   193  			{ID: "node_%s_indices_refresh_total", Name: "refresh", Algo: module.Incremental},
   194  		},
   195  	}
   196  	nodeIndicesRefreshOpsTimeChartTmpl = module.Chart{
   197  		ID:       "node_%s_cluster_%s_indices_refresh_operations_time",
   198  		Title:    "Time Spent On Refresh Operations",
   199  		Units:    "milliseconds",
   200  		Fam:      "indices refresh",
   201  		Ctx:      "elasticsearch.node_indices_refresh_time",
   202  		Priority: prioNodeIndicesRefreshOpsTime,
   203  		Dims: module.Dims{
   204  			{ID: "node_%s_indices_refresh_total_time_in_millis", Name: "refresh", Algo: module.Incremental},
   205  		},
   206  	}
   207  
   208  	nodeIndicesFlushOpsChartTmpl = module.Chart{
   209  		ID:       "node_%s_cluster_%s_indices_flush_operations",
   210  		Title:    "Flush Operations",
   211  		Units:    "operations/s",
   212  		Fam:      "indices flush",
   213  		Ctx:      "elasticsearch.node_indices_flush",
   214  		Priority: prioNodeIndicesFlushOps,
   215  		Dims: module.Dims{
   216  			{ID: "node_%s_indices_flush_total", Name: "flush", Algo: module.Incremental},
   217  		},
   218  	}
   219  	nodeIndicesFlushOpsTimeChartTmpl = module.Chart{
   220  		ID:       "node_%s_cluster_%s_indices_flush_operations_time",
   221  		Title:    "Time Spent On Flush Operations",
   222  		Units:    "milliseconds",
   223  		Fam:      "indices flush",
   224  		Ctx:      "elasticsearch.node_indices_flush_time",
   225  		Priority: prioNodeIndicesFlushOpsTime,
   226  		Dims: module.Dims{
   227  			{ID: "node_%s_indices_flush_total_time_in_millis", Name: "flush", Algo: module.Incremental},
   228  		},
   229  	}
   230  
   231  	nodeIndicesFieldDataMemoryUsageChartTmpl = module.Chart{
   232  		ID:       "node_%s_cluster_%s_indices_fielddata_memory_usage",
   233  		Title:    "Fielddata Cache Memory Usage",
   234  		Units:    "bytes",
   235  		Fam:      "indices fielddata",
   236  		Ctx:      "elasticsearch.node_indices_fielddata_memory_usage",
   237  		Type:     module.Area,
   238  		Priority: prioNodeIndicesFieldDataMemoryUsage,
   239  		Dims: module.Dims{
   240  			{ID: "node_%s_indices_fielddata_memory_size_in_bytes", Name: "used"},
   241  		},
   242  	}
   243  	nodeIndicesFieldDataEvictionsChartTmpl = module.Chart{
   244  		ID:       "node_%s_cluster_%s_indices_fielddata_evictions",
   245  		Title:    "Fielddata Evictions",
   246  		Units:    "operations/s",
   247  		Fam:      "indices fielddata",
   248  		Ctx:      "elasticsearch.node_indices_fielddata_evictions",
   249  		Priority: prioNodeIndicesFieldDataEvictions,
   250  		Dims: module.Dims{
   251  			{ID: "node_%s_indices_fielddata_evictions", Name: "evictions", Algo: module.Incremental},
   252  		},
   253  	}
   254  
   255  	nodeIndicesSegmentsCountChartTmpl = module.Chart{
   256  		ID:       "node_%s_cluster_%s_indices_segments_count",
   257  		Title:    "Segments Count",
   258  		Units:    "segments",
   259  		Fam:      "indices segments",
   260  		Ctx:      "elasticsearch.node_indices_segments_count",
   261  		Priority: prioNodeIndicesSegmentsCount,
   262  		Dims: module.Dims{
   263  			{ID: "node_%s_indices_segments_count", Name: "segments"},
   264  		},
   265  	}
   266  	nodeIndicesSegmentsMemoryUsageTotalChartTmpl = module.Chart{
   267  		ID:       "node_%s_cluster_%s_indices_segments_memory_usage_total",
   268  		Title:    "Segments Memory Usage Total",
   269  		Units:    "bytes",
   270  		Fam:      "indices segments",
   271  		Ctx:      "elasticsearch.node_indices_segments_memory_usage_total",
   272  		Priority: prioNodeIndicesSegmentsMemoryUsageTotal,
   273  		Dims: module.Dims{
   274  			{ID: "node_%s_indices_segments_memory_in_bytes", Name: "used"},
   275  		},
   276  	}
   277  	nodeIndicesSegmentsMemoryUsageChartTmpl = module.Chart{
   278  		ID:       "node_%s_cluster_%s_indices_segments_memory_usage",
   279  		Title:    "Segments Memory Usage",
   280  		Units:    "bytes",
   281  		Fam:      "indices segments",
   282  		Ctx:      "elasticsearch.node_indices_segments_memory_usage",
   283  		Type:     module.Stacked,
   284  		Priority: prioNodeIndicesSegmentsMemoryUsage,
   285  		Dims: module.Dims{
   286  			{ID: "node_%s_indices_segments_terms_memory_in_bytes", Name: "terms"},
   287  			{ID: "node_%s_indices_segments_stored_fields_memory_in_bytes", Name: "stored_fields"},
   288  			{ID: "node_%s_indices_segments_term_vectors_memory_in_bytes", Name: "term_vectors"},
   289  			{ID: "node_%s_indices_segments_norms_memory_in_bytes", Name: "norms"},
   290  			{ID: "node_%s_indices_segments_points_memory_in_bytes", Name: "points"},
   291  			{ID: "node_%s_indices_segments_doc_values_memory_in_bytes", Name: "doc_values"},
   292  			{ID: "node_%s_indices_segments_index_writer_memory_in_bytes", Name: "index_writer"},
   293  			{ID: "node_%s_indices_segments_version_map_memory_in_bytes", Name: "version_map"},
   294  			{ID: "node_%s_indices_segments_fixed_bit_set_memory_in_bytes", Name: "fixed_bit_set"},
   295  		},
   296  	}
   297  
   298  	nodeIndicesTransLogOpsChartTmpl = module.Chart{
   299  		ID:       "node_%s_cluster_%s_indices_translog_operations",
   300  		Title:    "Translog Operations",
   301  		Units:    "operations",
   302  		Fam:      "indices translog",
   303  		Ctx:      "elasticsearch.node_indices_translog_operations",
   304  		Type:     module.Area,
   305  		Priority: prioNodeIndicesTransLogOps,
   306  		Dims: module.Dims{
   307  			{ID: "node_%s_indices_translog_operations", Name: "total"},
   308  			{ID: "node_%s_indices_translog_uncommitted_operations", Name: "uncommitted"},
   309  		},
   310  	}
   311  	nodeIndexTransLogSizeChartTmpl = module.Chart{
   312  		ID:       "node_%s_cluster_%s_index_translog_size",
   313  		Title:    "Translog Size",
   314  		Units:    "bytes",
   315  		Fam:      "indices translog",
   316  		Ctx:      "elasticsearch.node_indices_translog_size",
   317  		Type:     module.Area,
   318  		Priority: prioNodeIndexTransLogSize,
   319  		Dims: module.Dims{
   320  			{ID: "node_%s_indices_translog_size_in_bytes", Name: "total"},
   321  			{ID: "node_%s_indices_translog_uncommitted_size_in_bytes", Name: "uncommitted"},
   322  		},
   323  	}
   324  
   325  	nodeFileDescriptorsChartTmpl = module.Chart{
   326  		ID:       "node_%s_cluster_%s_file_descriptors",
   327  		Title:    "Process File Descriptors",
   328  		Units:    "fd",
   329  		Fam:      "process",
   330  		Ctx:      "elasticsearch.node_file_descriptors",
   331  		Priority: prioNodeFileDescriptors,
   332  		Dims: module.Dims{
   333  			{ID: "node_%s_process_open_file_descriptors", Name: "open"},
   334  		},
   335  	}
   336  
   337  	nodeJVMMemHeapChartTmpl = module.Chart{
   338  		ID:       "node_%s_cluster_%s_jvm_mem_heap",
   339  		Title:    "JVM Heap Percentage Currently in Use",
   340  		Units:    "percentage",
   341  		Fam:      "jvm",
   342  		Ctx:      "elasticsearch.node_jvm_heap",
   343  		Type:     module.Area,
   344  		Priority: prioNodeJVMMemHeap,
   345  		Dims: module.Dims{
   346  			{ID: "node_%s_jvm_mem_heap_used_percent", Name: "inuse"},
   347  		},
   348  	}
   349  	nodeJVMMemHeapBytesChartTmpl = module.Chart{
   350  		ID:       "node_%s_cluster_%s_jvm_mem_heap_bytes",
   351  		Title:    "JVM Heap Commit And Usage",
   352  		Units:    "bytes",
   353  		Fam:      "jvm",
   354  		Ctx:      "elasticsearch.node_jvm_heap_bytes",
   355  		Type:     module.Area,
   356  		Priority: prioNodeJVMMemHeapBytes,
   357  		Dims: module.Dims{
   358  			{ID: "node_%s_jvm_mem_heap_committed_in_bytes", Name: "committed"},
   359  			{ID: "node_%s_jvm_mem_heap_used_in_bytes", Name: "used"},
   360  		},
   361  	}
   362  	nodeJVMBufferPoolsCountChartTmpl = module.Chart{
   363  		ID:       "node_%s_cluster_%s_jvm_buffer_pools_count",
   364  		Title:    "JVM Buffer Pools Count",
   365  		Units:    "pools",
   366  		Fam:      "jvm",
   367  		Ctx:      "elasticsearch.node_jvm_buffer_pools_count",
   368  		Priority: prioNodeJVMBufferPoolsCount,
   369  		Dims: module.Dims{
   370  			{ID: "node_%s_jvm_buffer_pools_direct_count", Name: "direct"},
   371  			{ID: "node_%s_jvm_buffer_pools_mapped_count", Name: "mapped"},
   372  		},
   373  	}
   374  	nodeJVMBufferPoolDirectMemoryChartTmpl = module.Chart{
   375  		ID:       "node_%s_cluster_%s_jvm_buffer_pool_direct_memory",
   376  		Title:    "JVM Buffer Pool Direct Memory",
   377  		Units:    "bytes",
   378  		Fam:      "jvm",
   379  		Ctx:      "elasticsearch.node_jvm_buffer_pool_direct_memory",
   380  		Type:     module.Area,
   381  		Priority: prioNodeJVMBufferPoolDirectMemory,
   382  		Dims: module.Dims{
   383  			{ID: "node_%s_jvm_buffer_pools_direct_total_capacity_in_bytes", Name: "total"},
   384  			{ID: "node_%s_jvm_buffer_pools_direct_used_in_bytes", Name: "used"},
   385  		},
   386  	}
   387  	nodeJVMBufferPoolMappedMemoryChartTmpl = module.Chart{
   388  		ID:       "node_%s_cluster_%s_jvm_buffer_pool_mapped_memory",
   389  		Title:    "JVM Buffer Pool Mapped Memory",
   390  		Units:    "bytes",
   391  		Fam:      "jvm",
   392  		Ctx:      "elasticsearch.node_jvm_buffer_pool_mapped_memory",
   393  		Type:     module.Area,
   394  		Priority: prioNodeJVMBufferPoolMappedMemory,
   395  		Dims: module.Dims{
   396  			{ID: "node_%s_jvm_buffer_pools_mapped_total_capacity_in_bytes", Name: "total"},
   397  			{ID: "node_%s_jvm_buffer_pools_mapped_used_in_bytes", Name: "used"},
   398  		},
   399  	}
   400  	nodeJVMGCCountChartTmpl = module.Chart{
   401  		ID:       "node_%s_cluster_%s_jvm_gc_count",
   402  		Title:    "JVM Garbage Collections",
   403  		Units:    "gc/s",
   404  		Fam:      "jvm",
   405  		Ctx:      "elasticsearch.node_jvm_gc_count",
   406  		Type:     module.Stacked,
   407  		Priority: prioNodeJVMGCCount,
   408  		Dims: module.Dims{
   409  			{ID: "node_%s_jvm_gc_collectors_young_collection_count", Name: "young", Algo: module.Incremental},
   410  			{ID: "node_%s_jvm_gc_collectors_old_collection_count", Name: "old", Algo: module.Incremental},
   411  		},
   412  	}
   413  	nodeJVMGCTimeChartTmpl = module.Chart{
   414  		ID:       "node_%s_cluster_%s_jvm_gc_time",
   415  		Title:    "JVM Time Spent On Garbage Collections",
   416  		Units:    "milliseconds",
   417  		Fam:      "jvm",
   418  		Ctx:      "elasticsearch.node_jvm_gc_time",
   419  		Type:     module.Stacked,
   420  		Priority: prioNodeJVMGCTime,
   421  		Dims: module.Dims{
   422  			{ID: "node_%s_jvm_gc_collectors_young_collection_time_in_millis", Name: "young", Algo: module.Incremental},
   423  			{ID: "node_%s_jvm_gc_collectors_old_collection_time_in_millis", Name: "old", Algo: module.Incremental},
   424  		},
   425  	}
   426  
   427  	nodeThreadPoolQueuedChartTmpl = module.Chart{
   428  		ID:       "node_%s_cluster_%s_thread_pool_queued",
   429  		Title:    "Thread Pool Queued Threads Count",
   430  		Units:    "threads",
   431  		Fam:      "thread pool",
   432  		Ctx:      "elasticsearch.node_thread_pool_queued",
   433  		Type:     module.Stacked,
   434  		Priority: prioNodeThreadPoolQueued,
   435  		Dims: module.Dims{
   436  			{ID: "node_%s_thread_pool_generic_queue", Name: "generic"},
   437  			{ID: "node_%s_thread_pool_search_queue", Name: "search"},
   438  			{ID: "node_%s_thread_pool_search_throttled_queue", Name: "search_throttled"},
   439  			{ID: "node_%s_thread_pool_get_queue", Name: "get"},
   440  			{ID: "node_%s_thread_pool_analyze_queue", Name: "analyze"},
   441  			{ID: "node_%s_thread_pool_write_queue", Name: "write"},
   442  			{ID: "node_%s_thread_pool_snapshot_queue", Name: "snapshot"},
   443  			{ID: "node_%s_thread_pool_warmer_queue", Name: "warmer"},
   444  			{ID: "node_%s_thread_pool_refresh_queue", Name: "refresh"},
   445  			{ID: "node_%s_thread_pool_listener_queue", Name: "listener"},
   446  			{ID: "node_%s_thread_pool_fetch_shard_started_queue", Name: "fetch_shard_started"},
   447  			{ID: "node_%s_thread_pool_fetch_shard_store_queue", Name: "fetch_shard_store"},
   448  			{ID: "node_%s_thread_pool_flush_queue", Name: "flush"},
   449  			{ID: "node_%s_thread_pool_force_merge_queue", Name: "force_merge"},
   450  			{ID: "node_%s_thread_pool_management_queue", Name: "management"},
   451  		},
   452  	}
   453  	nodeThreadPoolRejectedChartTmpl = module.Chart{
   454  		ID:       "node_%s_cluster_%s_thread_pool_rejected",
   455  		Title:    "Thread Pool Rejected Threads Count",
   456  		Units:    "threads",
   457  		Fam:      "thread pool",
   458  		Ctx:      "elasticsearch.node_thread_pool_rejected",
   459  		Type:     module.Stacked,
   460  		Priority: prioNodeThreadPoolRejected,
   461  		Dims: module.Dims{
   462  			{ID: "node_%s_thread_pool_generic_rejected", Name: "generic"},
   463  			{ID: "node_%s_thread_pool_search_rejected", Name: "search"},
   464  			{ID: "node_%s_thread_pool_search_throttled_rejected", Name: "search_throttled"},
   465  			{ID: "node_%s_thread_pool_get_rejected", Name: "get"},
   466  			{ID: "node_%s_thread_pool_analyze_rejected", Name: "analyze"},
   467  			{ID: "node_%s_thread_pool_write_rejected", Name: "write"},
   468  			{ID: "node_%s_thread_pool_snapshot_rejected", Name: "snapshot"},
   469  			{ID: "node_%s_thread_pool_warmer_rejected", Name: "warmer"},
   470  			{ID: "node_%s_thread_pool_refresh_rejected", Name: "refresh"},
   471  			{ID: "node_%s_thread_pool_listener_rejected", Name: "listener"},
   472  			{ID: "node_%s_thread_pool_fetch_shard_started_rejected", Name: "fetch_shard_started"},
   473  			{ID: "node_%s_thread_pool_fetch_shard_store_rejected", Name: "fetch_shard_store"},
   474  			{ID: "node_%s_thread_pool_flush_rejected", Name: "flush"},
   475  			{ID: "node_%s_thread_pool_force_merge_rejected", Name: "force_merge"},
   476  			{ID: "node_%s_thread_pool_management_rejected", Name: "management"},
   477  		},
   478  	}
   479  
   480  	nodeClusterCommunicationPacketsChartTmpl = module.Chart{
   481  		ID:       "node_%s_cluster_%s_cluster_communication_packets",
   482  		Title:    "Node Cluster Communication",
   483  		Units:    "pps",
   484  		Fam:      "transport",
   485  		Ctx:      "elasticsearch.node_cluster_communication_packets",
   486  		Priority: prioNodeClusterCommunicationPackets,
   487  		Dims: module.Dims{
   488  			{ID: "node_%s_transport_rx_count", Name: "received", Algo: module.Incremental},
   489  			{ID: "node_%s_transport_tx_count", Name: "sent", Mul: -1, Algo: module.Incremental},
   490  		},
   491  	}
   492  	nodeClusterCommunicationChartTmpl = module.Chart{
   493  		ID:       "node_%s_cluster_%s_cluster_communication_traffic",
   494  		Title:    "Cluster Communication Bandwidth",
   495  		Units:    "bytes/s",
   496  		Fam:      "transport",
   497  		Ctx:      "elasticsearch.node_cluster_communication_traffic",
   498  		Priority: prioNodeClusterCommunication,
   499  		Dims: module.Dims{
   500  			{ID: "node_%s_transport_rx_size_in_bytes", Name: "received", Algo: module.Incremental},
   501  			{ID: "node_%s_transport_tx_size_in_bytes", Name: "sent", Mul: -1, Algo: module.Incremental},
   502  		},
   503  	}
   504  
   505  	nodeHTTPConnectionsChartTmpl = module.Chart{
   506  		ID:       "node_%s_cluster_%s_http_connections",
   507  		Title:    "HTTP Connections",
   508  		Units:    "connections",
   509  		Fam:      "http",
   510  		Ctx:      "elasticsearch.node_http_connections",
   511  		Priority: prioNodeHTTPConnections,
   512  		Dims: module.Dims{
   513  			{ID: "node_%s_http_current_open", Name: "open"},
   514  		},
   515  	}
   516  
   517  	nodeBreakersTripsChartTmpl = module.Chart{
   518  		ID:       "node_%s_cluster_%s_breakers_trips",
   519  		Title:    "Circuit Breaker Trips Count",
   520  		Units:    "trips/s",
   521  		Fam:      "circuit breakers",
   522  		Ctx:      "elasticsearch.node_breakers_trips",
   523  		Type:     module.Stacked,
   524  		Priority: prioNodeBreakersTrips,
   525  		Dims: module.Dims{
   526  			{ID: "node_%s_breakers_request_tripped", Name: "requests", Algo: module.Incremental},
   527  			{ID: "node_%s_breakers_fielddata_tripped", Name: "fielddata", Algo: module.Incremental},
   528  			{ID: "node_%s_breakers_in_flight_requests_tripped", Name: "in_flight_requests", Algo: module.Incremental},
   529  			{ID: "node_%s_breakers_model_inference_tripped", Name: "model_inference", Algo: module.Incremental},
   530  			{ID: "node_%s_breakers_accounting_tripped", Name: "accounting", Algo: module.Incremental},
   531  			{ID: "node_%s_breakers_parent_tripped", Name: "parent", Algo: module.Incremental},
   532  		},
   533  	}
   534  )
   535  
   536  var clusterHealthChartsTmpl = module.Charts{
   537  	clusterStatusChartTmpl.Copy(),
   538  	clusterNodesCountChartTmpl.Copy(),
   539  	clusterShardsCountChartTmpl.Copy(),
   540  	clusterPendingTasksChartTmpl.Copy(),
   541  	clusterInFlightFetchesCountChartTmpl.Copy(),
   542  }
   543  
   544  var (
   545  	clusterStatusChartTmpl = module.Chart{
   546  		ID:       "cluster_%s_status",
   547  		Title:    "Cluster Status",
   548  		Units:    "status",
   549  		Fam:      "cluster health",
   550  		Ctx:      "elasticsearch.cluster_health_status",
   551  		Priority: prioClusterStatus,
   552  		Dims: module.Dims{
   553  			{ID: "cluster_status_green", Name: "green"},
   554  			{ID: "cluster_status_red", Name: "red"},
   555  			{ID: "cluster_status_yellow", Name: "yellow"},
   556  		},
   557  	}
   558  	clusterNodesCountChartTmpl = module.Chart{
   559  		ID:       "cluster_%s_number_of_nodes",
   560  		Title:    "Cluster Nodes Count",
   561  		Units:    "nodes",
   562  		Fam:      "cluster health",
   563  		Ctx:      "elasticsearch.cluster_number_of_nodes",
   564  		Priority: prioClusterNodesCount,
   565  		Dims: module.Dims{
   566  			{ID: "cluster_number_of_nodes", Name: "nodes"},
   567  			{ID: "cluster_number_of_data_nodes", Name: "data_nodes"},
   568  		},
   569  	}
   570  	clusterShardsCountChartTmpl = module.Chart{
   571  		ID:       "cluster_%s_shards_count",
   572  		Title:    "Cluster Shards Count",
   573  		Units:    "shards",
   574  		Fam:      "cluster health",
   575  		Ctx:      "elasticsearch.cluster_shards_count",
   576  		Priority: prioClusterShardsCount,
   577  		Dims: module.Dims{
   578  			{ID: "cluster_active_primary_shards", Name: "active_primary"},
   579  			{ID: "cluster_active_shards", Name: "active"},
   580  			{ID: "cluster_relocating_shards", Name: "relocating"},
   581  			{ID: "cluster_initializing_shards", Name: "initializing"},
   582  			{ID: "cluster_unassigned_shards", Name: "unassigned"},
   583  			{ID: "cluster_delayed_unassigned_shards", Name: "delayed_unassigned"},
   584  		},
   585  	}
   586  	clusterPendingTasksChartTmpl = module.Chart{
   587  		ID:       "cluster_%s_pending_tasks",
   588  		Title:    "Cluster Pending Tasks",
   589  		Units:    "tasks",
   590  		Fam:      "cluster health",
   591  		Ctx:      "elasticsearch.cluster_pending_tasks",
   592  		Priority: prioClusterPendingTasks,
   593  		Dims: module.Dims{
   594  			{ID: "cluster_number_of_pending_tasks", Name: "pending"},
   595  		},
   596  	}
   597  	clusterInFlightFetchesCountChartTmpl = module.Chart{
   598  		ID:       "cluster_%s_number_of_in_flight_fetch",
   599  		Title:    "Cluster Unfinished Fetches",
   600  		Units:    "fetches",
   601  		Fam:      "cluster health",
   602  		Ctx:      "elasticsearch.cluster_number_of_in_flight_fetch",
   603  		Priority: prioClusterInFlightFetchesCount,
   604  		Dims: module.Dims{
   605  			{ID: "cluster_number_of_in_flight_fetch", Name: "in_flight_fetch"},
   606  		},
   607  	}
   608  )
   609  
   610  var clusterStatsChartsTmpl = module.Charts{
   611  	clusterIndicesCountChartTmpl.Copy(),
   612  	clusterIndicesShardsCountChartTmpl.Copy(),
   613  	clusterIndicesDocsCountChartTmpl.Copy(),
   614  	clusterIndicesStoreSizeChartTmpl.Copy(),
   615  	clusterIndicesQueryCacheChartTmpl.Copy(),
   616  	clusterNodesByRoleCountChartTmpl.Copy(),
   617  }
   618  
   619  var (
   620  	clusterIndicesCountChartTmpl = module.Chart{
   621  		ID:       "cluster_%s_indices_count",
   622  		Title:    "Cluster Indices Count",
   623  		Units:    "indices",
   624  		Fam:      "cluster stats",
   625  		Ctx:      "elasticsearch.cluster_indices_count",
   626  		Priority: prioClusterIndicesCount,
   627  		Dims: module.Dims{
   628  			{ID: "cluster_indices_count", Name: "indices"},
   629  		},
   630  	}
   631  	clusterIndicesShardsCountChartTmpl = module.Chart{
   632  		ID:       "cluster_%s_indices_shards_count",
   633  		Title:    "Cluster Indices Shards Count",
   634  		Units:    "shards",
   635  		Fam:      "cluster stats",
   636  		Ctx:      "elasticsearch.cluster_indices_shards_count",
   637  		Priority: prioClusterIndicesShardsCount,
   638  		Dims: module.Dims{
   639  			{ID: "cluster_indices_shards_total", Name: "total"},
   640  			{ID: "cluster_indices_shards_primaries", Name: "primaries"},
   641  			{ID: "cluster_indices_shards_replication", Name: "replication"},
   642  		},
   643  	}
   644  	clusterIndicesDocsCountChartTmpl = module.Chart{
   645  		ID:       "cluster_%s_indices_docs_count",
   646  		Title:    "Cluster Indices Docs Count",
   647  		Units:    "docs",
   648  		Fam:      "cluster stats",
   649  		Ctx:      "elasticsearch.cluster_indices_docs_count",
   650  		Priority: prioClusterIndicesDocsCount,
   651  		Dims: module.Dims{
   652  			{ID: "cluster_indices_docs_count", Name: "docs"},
   653  		},
   654  	}
   655  	clusterIndicesStoreSizeChartTmpl = module.Chart{
   656  		ID:       "cluster_%s_indices_store_size",
   657  		Title:    "Cluster Indices Store Size",
   658  		Units:    "bytes",
   659  		Fam:      "cluster stats",
   660  		Ctx:      "elasticsearch.cluster_indices_store_size",
   661  		Priority: prioClusterIndicesStoreSize,
   662  		Dims: module.Dims{
   663  			{ID: "cluster_indices_store_size_in_bytes", Name: "size"},
   664  		},
   665  	}
   666  	clusterIndicesQueryCacheChartTmpl = module.Chart{
   667  		ID:       "cluster_%s_indices_query_cache",
   668  		Title:    "Cluster Indices Query Cache",
   669  		Units:    "events/s",
   670  		Fam:      "cluster stats",
   671  		Ctx:      "elasticsearch.cluster_indices_query_cache",
   672  		Type:     module.Stacked,
   673  		Priority: prioClusterIndicesQueryCache,
   674  		Dims: module.Dims{
   675  			{ID: "cluster_indices_query_cache_hit_count", Name: "hit", Algo: module.Incremental},
   676  			{ID: "cluster_indices_query_cache_miss_count", Name: "miss", Algo: module.Incremental},
   677  		},
   678  	}
   679  	clusterNodesByRoleCountChartTmpl = module.Chart{
   680  		ID:       "cluster_%s_nodes_by_role_count",
   681  		Title:    "Cluster Nodes By Role Count",
   682  		Units:    "nodes",
   683  		Fam:      "cluster stats",
   684  		Ctx:      "elasticsearch.cluster_nodes_by_role_count",
   685  		Priority: prioClusterNodesByRoleCount,
   686  		Dims: module.Dims{
   687  			{ID: "cluster_nodes_count_coordinating_only", Name: "coordinating_only"},
   688  			{ID: "cluster_nodes_count_data", Name: "data"},
   689  			{ID: "cluster_nodes_count_data_cold", Name: "data_cold"},
   690  			{ID: "cluster_nodes_count_data_content", Name: "data_content"},
   691  			{ID: "cluster_nodes_count_data_frozen", Name: "data_frozen"},
   692  			{ID: "cluster_nodes_count_data_hot", Name: "data_hot"},
   693  			{ID: "cluster_nodes_count_data_warm", Name: "data_warm"},
   694  			{ID: "cluster_nodes_count_ingest", Name: "ingest"},
   695  			{ID: "cluster_nodes_count_master", Name: "master"},
   696  			{ID: "cluster_nodes_count_ml", Name: "ml"},
   697  			{ID: "cluster_nodes_count_remote_cluster_client", Name: "remote_cluster_client"},
   698  			{ID: "cluster_nodes_count_voting_only", Name: "voting_only"},
   699  		},
   700  	}
   701  )
   702  
   703  var nodeIndexChartsTmpl = module.Charts{
   704  	nodeIndexHealthChartTmpl.Copy(),
   705  	nodeIndexShardsCountChartTmpl.Copy(),
   706  	nodeIndexDocsCountChartTmpl.Copy(),
   707  	nodeIndexStoreSizeChartTmpl.Copy(),
   708  }
   709  
   710  var (
   711  	nodeIndexHealthChartTmpl = module.Chart{
   712  		ID:       "node_index_%s_cluster_%s_health",
   713  		Title:    "Index Health",
   714  		Units:    "status",
   715  		Fam:      "index stats",
   716  		Ctx:      "elasticsearch.node_index_health",
   717  		Priority: prioNodeIndexHealth,
   718  		Dims: module.Dims{
   719  			{ID: "node_index_%s_stats_health_green", Name: "green"},
   720  			{ID: "node_index_%s_stats_health_red", Name: "red"},
   721  			{ID: "node_index_%s_stats_health_yellow", Name: "yellow"},
   722  		},
   723  	}
   724  	nodeIndexShardsCountChartTmpl = module.Chart{
   725  		ID:       "node_index_%s_cluster_%s_shards_count",
   726  		Title:    "Index Shards Count",
   727  		Units:    "shards",
   728  		Fam:      "index stats",
   729  		Ctx:      "elasticsearch.node_index_shards_count",
   730  		Priority: prioNodeIndexShardsCount,
   731  		Dims: module.Dims{
   732  			{ID: "node_index_%s_stats_shards_count", Name: "shards"},
   733  		},
   734  	}
   735  	nodeIndexDocsCountChartTmpl = module.Chart{
   736  		ID:       "node_index_%s_cluster_%s_docs_count",
   737  		Title:    "Index Docs Count",
   738  		Units:    "docs",
   739  		Fam:      "index stats",
   740  		Ctx:      "elasticsearch.node_index_docs_count",
   741  		Priority: prioNodeIndexDocsCount,
   742  		Dims: module.Dims{
   743  			{ID: "node_index_%s_stats_docs_count", Name: "docs"},
   744  		},
   745  	}
   746  	nodeIndexStoreSizeChartTmpl = module.Chart{
   747  		ID:       "node_index_%s_cluster_%s_store_size",
   748  		Title:    "Index Store Size",
   749  		Units:    "bytes",
   750  		Fam:      "index stats",
   751  		Ctx:      "elasticsearch.node_index_store_size",
   752  		Priority: prioNodeIndexStoreSize,
   753  		Dims: module.Dims{
   754  			{ID: "node_index_%s_stats_store_size_in_bytes", Name: "store_size"},
   755  		},
   756  	}
   757  )
   758  
   759  func (es *Elasticsearch) addClusterStatsCharts() {
   760  	charts := clusterStatsChartsTmpl.Copy()
   761  
   762  	for _, chart := range *charts {
   763  		chart.ID = fmt.Sprintf(chart.ID, es.clusterName)
   764  		chart.Labels = []module.Label{
   765  			{Key: "cluster_name", Value: es.clusterName},
   766  		}
   767  	}
   768  
   769  	if err := es.charts.Add(*charts...); err != nil {
   770  		es.Warning(err)
   771  	}
   772  }
   773  
   774  func (es *Elasticsearch) addClusterHealthCharts() {
   775  	charts := clusterHealthChartsTmpl.Copy()
   776  
   777  	for _, chart := range *charts {
   778  		chart.ID = fmt.Sprintf(chart.ID, es.clusterName)
   779  		chart.Labels = []module.Label{
   780  			{Key: "cluster_name", Value: es.clusterName},
   781  		}
   782  	}
   783  
   784  	if err := es.charts.Add(*charts...); err != nil {
   785  		es.Warning(err)
   786  	}
   787  }
   788  
   789  func (es *Elasticsearch) addNodeCharts(nodeID string, node *esNodeStats) {
   790  	charts := nodeChartsTmpl.Copy()
   791  
   792  	for _, chart := range *charts {
   793  		chart.ID = fmt.Sprintf(chart.ID, nodeID, es.clusterName)
   794  		chart.Labels = []module.Label{
   795  			{Key: "cluster_name", Value: es.clusterName},
   796  			{Key: "node_name", Value: node.Name},
   797  			{Key: "host", Value: node.Host},
   798  		}
   799  		for _, dim := range chart.Dims {
   800  			dim.ID = fmt.Sprintf(dim.ID, nodeID)
   801  		}
   802  	}
   803  
   804  	if err := es.Charts().Add(*charts...); err != nil {
   805  		es.Warning(err)
   806  	}
   807  }
   808  
   809  func (es *Elasticsearch) removeNodeCharts(nodeID string) {
   810  	px := fmt.Sprintf("node_%s_cluster_%s_", nodeID, es.clusterName)
   811  	es.removeCharts(px)
   812  }
   813  
   814  func (es *Elasticsearch) addIndexCharts(index string) {
   815  	charts := nodeIndexChartsTmpl.Copy()
   816  
   817  	for _, chart := range *charts {
   818  		chart.ID = fmt.Sprintf(chart.ID, index, es.clusterName)
   819  		chart.Labels = []module.Label{
   820  			{Key: "cluster_name", Value: es.clusterName},
   821  			{Key: "index", Value: index},
   822  		}
   823  		for _, dim := range chart.Dims {
   824  			dim.ID = fmt.Sprintf(dim.ID, index)
   825  		}
   826  	}
   827  
   828  	if err := es.Charts().Add(*charts...); err != nil {
   829  		es.Warning(err)
   830  	}
   831  }
   832  
   833  func (es *Elasticsearch) removeIndexCharts(index string) {
   834  	px := fmt.Sprintf("node_index_%s_cluster_%s_", index, es.clusterName)
   835  	es.removeCharts(px)
   836  }
   837  
   838  func (es *Elasticsearch) removeCharts(prefix string) {
   839  	for _, chart := range *es.Charts() {
   840  		if strings.HasPrefix(chart.ID, prefix) {
   841  			chart.MarkRemove()
   842  			chart.MarkNotCreated()
   843  		}
   844  	}
   845  }