From 37e20d3dc70cd0aae12d387cc66c5f6af77cf7e6 Mon Sep 17 00:00:00 2001 From: coreymbe Date: Tue, 26 Mar 2024 12:23:43 -0700 Subject: [PATCH] (MAINT) Bug Fix - ship sar metrics --- CHANGELOG.md | 2 ++ lib/puppet/application/splunk_hec.rb | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 465b693..17f8a32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,8 @@ All notable changes to this project will be documented in this file. The format ### Fixed +- Bug fix preventing `sar` metrics collected by `puppet_metrics_collector::system` from being shipped to Splunk. [#214](https://github.com/puppetlabs/puppetlabs-splunk_hec/pull/214) + - The `collect_facts` parameter has been renamed to `facts_allowlist` to align with the `facts_blocklist` parameter. [#212](https://github.com/puppetlabs/puppetlabs-splunk_hec/pull/212) - No longer utilizing `parse_legacy_metrics` function for metrics collected with older versions of `puppet_metrics_collector`. [#211](https://github.com/puppetlabs/puppetlabs-splunk_hec/pull/211) diff --git a/lib/puppet/application/splunk_hec.rb b/lib/puppet/application/splunk_hec.rb index e12baf5..d68abb7 100644 --- a/lib/puppet/application/splunk_hec.rb +++ b/lib/puppet/application/splunk_hec.rb @@ -44,7 +44,12 @@ def send_pe_metrics(data, sourcetype) content.each_key do |serv| event = event_template.clone event['host'] = name - event['event'] = content[serv.to_s] + if content[serv.to_s].is_a?(Array) + event['event'] = {} + event['event']['metrics'] = content[serv.to_s] + else + event['event'] = content[serv.to_s] + end event['event']['pe_console'] = pe_console event['event']['pe_service'] = serv.to_s Puppet.info 'Submitting metrics to Splunk'