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 6, 2024
1 parent d109bd1 commit 3e51a02
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,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 All @@ -364,15 +366,17 @@ Table of exported metrics:
| logstash_stats_pipeline_events_out | counter | Number of events that have been processed by this pipeline. |
| logstash_stats_pipeline_events_queue_push_duration | counter | Time needed to push event to queue. |
| logstash_stats_pipeline_flow_filter_current | gauge | Current number of events in the filter queue. |
| logstash_stats_pipeline_flow_filter_lifetime | counter | Lifetime number of events in the filter queue. |
| logstash_stats_pipeline_flow_filter_lifetime | gauge | Lifetime number of events in the filter queue. |
| logstash_stats_pipeline_flow_input_current | gauge | Current number of events in the input queue. |
| logstash_stats_pipeline_flow_input_lifetime | counter | Lifetime number of events in the input queue. |
| logstash_stats_pipeline_flow_input_lifetime | gauge | Lifetime number of events in the input queue. |
| logstash_stats_pipeline_flow_output_current | gauge | Current number of events in the output queue. |
| logstash_stats_pipeline_flow_output_lifetime | counter | Lifetime number of events in the output queue. |
| logstash_stats_pipeline_flow_output_lifetime | gauge | Lifetime number of events in the output queue. |
| logstash_stats_pipeline_flow_queue_backpressure_current | gauge | Current number of events in the backpressure queue. |
| logstash_stats_pipeline_flow_queue_backpressure_lifetime | counter | Lifetime number of events in the backpressure queue. |
| logstash_stats_pipeline_flow_queue_backpressure_lifetime | gauge | Lifetime number of events in the backpressure queue. |
| logstash_stats_pipeline_flow_worker_concurrency_current | gauge | Current number of workers. |
| logstash_stats_pipeline_flow_worker_concurrency_lifetime | counter | Lifetime number of workers. |
| logstash_stats_pipeline_flow_worker_concurrency_lifetime | gauge | Lifetime number of workers. |
| logstash_stats_pipeline_flow_worker_utilization_current | gauge | Current worker utilization. |
| logstash_stats_pipeline_flow_worker_utilization_lifetime | gauge | Lifetime worker utilization. |
| logstash_stats_pipeline_plugin_bulk_requests_errors | counter | Number of bulk request errors. |
| logstash_stats_pipeline_plugin_bulk_requests_responses | counter | Bulk request HTTP response counts by code. |
| logstash_stats_pipeline_plugin_documents_non_retryable_failures | counter | Number of output events with non-retryable failures. |
Expand Down
16 changes: 16 additions & 0 deletions collectors/nodestats/nodestats_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,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 @@ -98,6 +101,11 @@ func NewNodestatsCollector(client logstashclient.Client) *NodestatsCollector {
JvmMemPoolCommittedInBytes: descHelper.NewDescWithHelpAndLabels(
"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.NewDescWithHelpAndLabels(
"jvm_gc_collection_count", "Count of garbage collection runs for a given JVM memory pool.", "pool"),
JvmGcCollectionTimeInMillis: descHelper.NewDescWithHelpAndLabels(
"jvm_gc_collection_time_millis_total", "Total time spent running garbage collection for a given JVM memory pool.", "pool"),

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

ProcessOpenFileDescriptors: descHelper.NewDescWithHelp("process_open_file_descriptors", "Number of currently open file descriptors."),
Expand Down Expand Up @@ -169,6 +177,14 @@ func (c *NodestatsCollector) Collect(ctx context.Context, ch chan<- prometheus.M
ch <- prometheus.MustNewConstMetric(c.JvmMemPoolMaxInBytes, prometheus.GaugeValue, float64(nodeStats.Jvm.Mem.Pools.Survivor.MaxInBytes), "survivor")
ch <- prometheus.MustNewConstMetric(c.JvmMemPoolCommittedInBytes, prometheus.GaugeValue, float64(nodeStats.Jvm.Mem.Pools.Survivor.CommittedInBytes), "survivor")

// GC
// young
ch <- prometheus.MustNewConstMetric(c.JvmGcCollectionCount, prometheus.CounterValue, float64(nodeStats.Jvm.Gc.Collectors.Young.CollectionCount), "young")
ch <- prometheus.MustNewConstMetric(c.JvmGcCollectionTimeInMillis, prometheus.CounterValue, float64(nodeStats.Jvm.Gc.Collectors.Young.CollectionTimeInMillis), "young")
// old
ch <- prometheus.MustNewConstMetric(c.JvmGcCollectionCount, prometheus.CounterValue, float64(nodeStats.Jvm.Gc.Collectors.Old.CollectionCount), "old")
ch <- prometheus.MustNewConstMetric(c.JvmGcCollectionTimeInMillis, prometheus.CounterValue, float64(nodeStats.Jvm.Gc.Collectors.Old.CollectionTimeInMillis), "old")

ch <- prometheus.MustNewConstMetric(c.JvmUptimeMillis, prometheus.GaugeValue, float64(nodeStats.Jvm.UptimeInMillis))

ch <- prometheus.MustNewConstMetric(c.ProcessOpenFileDescriptors, prometheus.GaugeValue, float64(nodeStats.Process.OpenFileDescriptors))
Expand Down
2 changes: 2 additions & 0 deletions collectors/nodestats/nodestats_collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,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

0 comments on commit 3e51a02

Please sign in to comment.