-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add fact generation and catalog application times * Refactors module to use shared util for splunk_hec Fixes SSL handling with simpler options Adds terminus for facts to be sent to splunk Enables profiling for both report and fact submission Updates splunk_hec module to support customization of facts collected Updates splunk_hec module to optionally manage reports setting * Update README.md * Adds Fact Terminus Major changes to module were done to enable the Fact Terminus: - util/splunk_hec.rb created for common access methods - consistent info and error handling for both reports and facts - performance profile support for Fact Terminus - Documentation updated with guide and default facts listed - Module updated to optionally manage reports setting in puppet.conf - Module updated to add new parameters and template values - Fact collection time added to puppet report processor - SSL handling and documentation improved * Hard codes puppet:summary sourcetype in event Without this, it was dependent on the user to create the HEC properly Now as long as the HEC token provided is correct, the reports will go to the puppet:summary sourcetype Example splunk_hec.yaml was updated to reflect new changes to install * Adjusts metrics hash for consistency with splunk plugin
- Loading branch information
Showing
11 changed files
with
272 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# managed by puppet | ||
--- | ||
"server" : "splunk-dev.foo.bar.com" | ||
"token" : "9BEFBCD1-47B2-4A74-90FF-2098EEBE4EE3" | ||
"puppetdb_callback_hostname": "puppetdb.foo.bar.com" | ||
"url" : "https://splunk-dev.testing.local:8088/services/collector" | ||
"token" : "13311780-EC29-4DD0-A796-9F0CDC56F2AD" | ||
"pe_console": "puppetdb.foo.bar.com" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
require 'puppet/indirector/facts/puppetdb' | ||
require 'puppet/util/splunk_hec' | ||
|
||
# splunk_hec.rb | ||
class Puppet::Node::Facts::Splunk_hec < Puppet::Node::Facts::Puppetdb | ||
desc "Save facts to Splunk over HEC and PuppetDB. | ||
It uses PuppetDB to retrieve facts for catalog compilation." | ||
|
||
include Puppet::Util::Splunk_hec | ||
|
||
def save(request) | ||
# puppetdb goes first | ||
super(request) | ||
|
||
profile('splunk_facts#save', [:splunk, :facts, :save, request.key]) do | ||
begin | ||
host = request.instance.name.dup | ||
incoming_facts = request.instance.values.dup | ||
|
||
hardcoded = [ | ||
'os', | ||
'memory', | ||
'puppetversion', | ||
'system_uptime', | ||
'load_averages', | ||
'ipaddress', | ||
'fqdn', | ||
] | ||
|
||
# lets ensure user provided fact names are downcased | ||
users = settings['facts'].map(&:downcase) | ||
|
||
keep = (hardcoded + users).uniq | ||
|
||
facts = incoming_facts.select { |k, _v| keep.include?(k) } | ||
|
||
facts['trusted'] = get_trusted_info(request.node) | ||
facts['environment'] = request.options[:environment] || request.environment.to_s | ||
facts['producer'] = Puppet[:node_name_value] | ||
facts['pe_console'] = pe_console | ||
|
||
event = { | ||
'host' => host, | ||
'sourcetype' => 'puppet:facts', | ||
'event' => facts, | ||
} | ||
|
||
Puppet.info "Submitting facts to Splunk at #{splunk_url}" | ||
submit_request event | ||
rescue StandardError => e | ||
Puppet.err "Could not send facts to Satellite: #{e}\n#{e.backtrace}" | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.