-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for trusted fact tags and add info line for puppetserver … #662
Conversation
…log notifications
@albertvaka resolved the issues for trusted facts. |
Thanks a lot! We didn't know this was possible :) To be consistent with #658 I think we want to have a separate argument (eg: |
@albertvaka either merged or separate works makes sense. The reason I merged into a single hash was user simplicity and trusted is a reserved name so there is not a chance of duplication. |
Yeah, I agree it's simpler like this, but since I initially added two separate arguments for |
Makes sense to stay consistent with that pattern. |
I pushed a commit to your branch that should do it, can you give it a quick look before I merge? |
Were you able to test this or you do want me to test in my lab? |
I've tested the Puppet side but not the Ruby script changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there Mike! A couple typo fixes and some formatting to help with documentation readability, in the README.md.
README.md
Outdated
@@ -152,7 +152,7 @@ To enable reporting of Puppet runs to your Datadog timeline, enable the report p | |||
|
|||
5. (Optional) Enable tagging of reports with facts: | |||
|
|||
You can add tags to reports that are sent to Datadog as events. These tags can be sourced from Puppet facts for the given node the report is regarding. These should be 1:1 and not involve structured facts (hashes, arrays, etc.) to ensure readability. To enable tagging, set the parameter `datadog_agent::reports::report_fact_tags` to the array value of facts—for example `["virtual","trusted.extensions.pp_role","operatingsystem"]` results in three separate tags per report event. | |||
You can add tags to reports that are sent to Datadog as events. These tags can be sourced from Puppet facts for the given node the report is regarding. These should be 1:1 and not involve structured facts (hashes, arrays, etc.) to ensure readability. To enable regular fact tagging, set the parameter `datadog_agent::reports::report_fact_tags` to the array value of facts—for example `["virtual","operatingsystem"]`. To enable trustd fact tagging, set the parameter `datadog_agent::reports::report_trusted_fact_tags` to the array value of facts—for example `["trusted.certname","trusted.extensions.pp_role","trusted hostname"]`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add tags to reports that are sent to Datadog as events. These tags can be sourced from Puppet facts for the given node the report is regarding. These should be 1:1 and not involve structured facts (hashes, arrays, etc.) to ensure readability. To enable regular fact tagging, set the parameter `datadog_agent::reports::report_fact_tags` to the array value of facts—for example `["virtual","operatingsystem"]`. To enable trustd fact tagging, set the parameter `datadog_agent::reports::report_trusted_fact_tags` to the array value of facts—for example `["trusted.certname","trusted.extensions.pp_role","trusted hostname"]`. | |
You can add tags to reports that are sent to Datadog as events. These tags can be sourced from Puppet facts for the given node the report is regarding. These should be 1:1 and not involve structured facts (hashes, arrays, etc.) to ensure readability. | |
To enable regular fact tagging, set the parameter `datadog_agent::reports::report_fact_tags` to the array value of facts—for example `["virtual","operatingsystem"]`. | |
To enable trusted fact tagging, set the parameter `datadog_agent::reports::report_trusted_fact_tags` to the array value of facts—for example `["trusted.certname","trusted.extensions.pp_role","trusted.hostname"]`. |
@kayayarai @albertvaka sorry for delay but I did some testing and confirmed functionality. I updated the readme and some debugging if needed as well. I tried to differentiate between tags for Datadog agents and Report (event) tagging. |
Co-authored-by: Kari Halsted <[email protected]>
Puppet.debug "Sending events for #{@msg_host} to Datadog" | ||
facts_tags = REPORT_FACT_TAGS.map { |name| "#{name}:#{facts.dig(*name.split('.'))}" } | ||
trusted_facts = (Puppet.lookup(:trusted_information) { Hash.new }).to_h | ||
trusted_facts = { "trusted" => trusted_facts.to_h } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make sure report_trusted_fact_tags
is consistent with trusted_facts_to_tags
. When accessing the $trusted
variable from puppet code, do you have to use the trusted.*
prefix? (eg: $trusted['trusted. certname']
). Since trusted_facts_to_tags
just digs in $trusted
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the examples section in Puppet docs [1], it looks like the trusted
prefix doesn't have to be used when accessing $trusted
, so I'm going to remove it from this PR and merge it.
[1] https://puppet.com/docs/puppet/5.5/lang_facts_and_builtin_vars.html#examples
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for the documentation
So report_trusted_fact_tags is consistent wih trusted_facts_to_tags
Disable Style/EmptyLiteral since it's way less readable to do { {} }
…log notifications
What does this PR do?
Resolve issue where trusted facts were not working for report fact tags.
Motivation
Customer request based on experience/need.
Additional Notes
Added an unrelated info line to the report processor to log successful sends to Datadog API
Describe your test plan
Tested in a lab environment using Puppet Enterprise 2019.8.1 with current Datadog.