Skip to content

Commit

Permalink
Add GC metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
VCCPlindsten committed Nov 7, 2024
1 parent 48d2d3a commit f001186
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ Table of exported metrics:
| logstash_info_pipeline_batch_size | gauge | Number of events to retrieve from the input queue before sending to the filter and output stages. |
| logstash_info_pipeline_workers | gauge | Number of worker threads that will process pipeline events. |
| logstash_info_status | counter | A metric with a constant '1' value labeled by status. |
| logstash_info_up | counter | A metric that returns 1 if the node is up, 0 otherwise. |
| logstash_info_up | gauge | A metric that returns 1 if the node is up, 0 otherwise. |
| logstash_stats_events_duration_millis | gauge | Duration of events processing in milliseconds. |
| logstash_stats_events_filtered | gauge | Number of events filtered out. |
| logstash_stats_events_in | gauge | Number of events received. |
Expand All @@ -302,6 +302,8 @@ Table of exported metrics:
| logstash_stats_flow_queue_backpressure_lifetime | gauge | Lifetime number of events in the backpressure queue. |
| logstash_stats_flow_worker_concurrency_current | gauge | Current number of workers. |
| logstash_stats_flow_worker_concurrency_lifetime | gauge | Lifetime number of workers. |
| logstash_stats_jvm_gc_collection_count | counter | Count of garbage collection runs for a given JVM memory pool. |
| logstash_stats_jvm_gc_collection_time_millis_total | counter | Total time spent running garbage collection for a given JVM memory pool. |
| logstash_stats_jvm_mem_heap_committed_bytes | gauge | Amount of heap memory in bytes that is committed for the Java virtual machine to use. |
| logstash_stats_jvm_mem_heap_max_bytes | gauge | Maximum amount of heap memory in bytes that can be used for memory management. |
| logstash_stats_jvm_mem_heap_used_bytes | gauge | Amount of used heap memory in bytes. |
Expand Down
22 changes: 22 additions & 0 deletions internal/collectors/nodestats/nodestats_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ type NodestatsCollector struct {
JvmMemPoolMaxInBytes *prometheus.Desc
JvmMemPoolCommittedInBytes *prometheus.Desc

JvmGcCollectionCount *prometheus.Desc
JvmGcCollectionTimeInMillis *prometheus.Desc

JvmUptimeMillis *prometheus.Desc

ProcessOpenFileDescriptors *prometheus.Desc
Expand Down Expand Up @@ -108,6 +111,11 @@ func NewNodestatsCollector(clients []logstash_client.Client) *NodestatsCollector
JvmMemPoolCommittedInBytes: descHelper.NewDesc("jvm_mem_pool_committed_bytes",
"Amount of bytes that are committed for the Java virtual machine to use in a given JVM memory pool.", "pool"),

JvmGcCollectionCount: descHelper.NewDesc(
"jvm_gc_collection_count", "Count of garbage collection runs for a given JVM memory pool.", "pool"),
JvmGcCollectionTimeInMillis: descHelper.NewDesc(
"jvm_gc_collection_time_millis_total", "Total time spent running garbage collection for a given JVM memory pool.", "pool"),

JvmUptimeMillis: descHelper.NewDesc("jvm_uptime_millis",
"Uptime of the JVM in milliseconds."),

Expand Down Expand Up @@ -234,6 +242,20 @@ func (collector *NodestatsCollector) collectSingleInstance(client logstash_clien
// *************************
// ********************************

// ************ GC ************
// ********* YOUNG *********
metricsHelper.Labels = []string{"young", endpoint}
metricsHelper.NewIntMetric(collector.JvmGcCollectionCount, prometheus.CounterValue, nodeStats.Jvm.Gc.Collectors.Young.CollectionCount)
metricsHelper.NewIntMetric(collector.JvmGcCollectionTimeInMillis, prometheus.CounterValue, nodeStats.Jvm.Gc.Collectors.Young.CollectionTimeInMillis)
// *************************

// ********* OLD *********
metricsHelper.Labels = []string{"old", endpoint}
metricsHelper.NewIntMetric(collector.JvmGcCollectionCount, prometheus.CounterValue, nodeStats.Jvm.Gc.Collectors.Old.CollectionCount)
metricsHelper.NewIntMetric(collector.JvmGcCollectionTimeInMillis, prometheus.CounterValue, nodeStats.Jvm.Gc.Collectors.Old.CollectionTimeInMillis)
// *************************
// ********************************

metricsHelper.Labels = []string{endpoint}

// ************ UPTIME ************
Expand Down
2 changes: 2 additions & 0 deletions internal/collectors/nodestats/nodestats_collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ func TestCollectNotNil(t *testing.T) {
"logstash_stats_jvm_mem_pool_peak_max_bytes",
"logstash_stats_jvm_mem_pool_max_bytes",
"logstash_stats_jvm_mem_pool_committed_bytes",
"logstash_stats_jvm_gc_collection_count",
"logstash_stats_jvm_gc_collection_time_millis_total",
}

var foundMetrics []string
Expand Down
2 changes: 2 additions & 0 deletions scripts/snapshots/metric_names.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,5 @@ logstash_stats_flow_worker_concurrency_current
logstash_stats_flow_worker_concurrency_lifetime
logstash_stats_pipeline_flow_worker_utilization_current
logstash_stats_pipeline_flow_worker_utilization_lifetime
logstash_stats_jvm_gc_collection_count
logstash_stats_jvm_gc_collection_time_millis_total

0 comments on commit f001186

Please sign in to comment.