Skip to content

Commit

Permalink
Adds tests for load_avg metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
excalq committed Apr 20, 2023
1 parent 48f9cee commit f9985b3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions collectors/nodestats/nodestats_collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ func TestCollectNotNil(t *testing.T) {
"logstash_stats_pipeline_reloads_successes",
"logstash_stats_process_cpu_percent",
"logstash_stats_process_cpu_total_millis",
"logstash_stats_process_cpu_load_average_1m",
"logstash_stats_process_cpu_load_average_5m",
"logstash_stats_process_cpu_load_average_15m",
"logstash_stats_process_max_file_descriptors",
"logstash_stats_process_mem_total_virtual",
"logstash_stats_process_open_file_descriptors",
Expand Down
2 changes: 1 addition & 1 deletion prometheus_helper/prometheus_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (h *SimpleDescHelper) NewDescWithHelpAndLabel(name, help, label string) *pr
// ExtractFqName extracts the fqName from a prometheus.Desc string.
// This is useful for testing collectors.
func ExtractFqName(metric string) (string, error) {
regex := regexp.MustCompile(`fqName:\s*"([a-zA-Z_-]+)"`)
regex := regexp.MustCompile(`fqName:\s*"([a-zA-Z0-9_-]+)"`)
matches := regex.FindStringSubmatch(metric)
if len(matches) < 2 {
return "", errors.New("failed to extract fqName from metric string")
Expand Down
3 changes: 3 additions & 0 deletions scripts/snapshots/metric_names.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ logstash_stats_pipeline_reloads_failures
logstash_stats_pipeline_reloads_successes
logstash_stats_process_cpu_percent
logstash_stats_process_cpu_total_millis
logstash_stats_process_cpu_load_average_1m
logstash_stats_process_cpu_load_average_5m
logstash_stats_process_cpu_load_average_15m
logstash_stats_process_max_file_descriptors
logstash_stats_process_mem_total_virtual
logstash_stats_process_open_file_descriptors
Expand Down

0 comments on commit f9985b3

Please sign in to comment.