-
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
Allow modifications to reported hostnames #160
Comments
We have a patch that allows applying a regex to the hostnames reported by puppet: https://gist.github.com/LeoCavaille/264d0f7cf27b0d7e2bb3. It's a good approach for simple cases, but we should investigate if it could be improved on or if we could use another approach. |
👍 |
We had a similar issue and used in the end the following patch: @@ -13,6 +13,12 @@ Puppet::Reports.register_report(:datadog_reports) do
raise(Puppet::ParseError, "Datadog report config file #{configfile} not readable") unless File.exist?(configfile)
config = YAML.load_file(configfile)
API_KEY = config[:datadog_api_key]
+ HOSTNAME_EXTRACTION_REGEX = config[:hostname_extraction_regex]
+ unless HOSTNAME_EXTRACTION_REGEX.empty?
+ HOSTNAME_EXTRACTION_REGEX = Regexp.new HOSTNAME_EXTRACTION_REGEX
+ else
+ HOSTNAME_EXTRACTION_REGEX = nil
+ end
desc <<-DESC
Send notification of metrics to Datadog
@@ -38,6 +44,12 @@ Puppet::Reports.register_report(:datadog_reports) do
def process
@summary = self.summary
@msg_host = self.host
+ unless HOSTNAME_EXTRACTION_REGEX.nil?
+ m = @msg_host.match(HOSTNAME_EXTRACTION_REGEX)
+ unless m[1].nil?
+ @msg_host = m[1]
+ end
+ end
event_title = ''
alert_type = '' and the following regexp |
This is a great patch -- I'd love to see it pushed to the project so we can use it without forking the project ourselves. |
@diranged I can try to rebase that to apply it to the current master. Will open a PR. |
Fixes DataDog#160. This option is a string regex which can be enabled and used to extract the hostname from puppet hostname strings with a capture group. It is useful for people that have specific puppet hostnames and that would like to sanitize them before reporting those in Datadog.
Fixes DataDog#160. This option is a string regex which can be enabled and used to extract the hostname from puppet hostname strings with a capture group. It is useful for people that have specific puppet hostnames and that would like to sanitize them before reporting those in Datadog.
Fixes #160. This option is a string regex which can be enabled and used to extract the hostname from puppet hostname strings with a capture group. It is useful for people that have specific puppet hostnames and that would like to sanitize them before reporting those in Datadog.
Fixes DataDog#160. This option is a string regex which can be enabled and used to extract the hostname from puppet hostname strings with a capture group. It is useful for people that have specific puppet hostnames and that would like to sanitize them before reporting those in Datadog.
Fixes DataDog#160. This option is a string regex which can be enabled and used to extract the hostname from puppet hostname strings with a capture group. It is useful for people that have specific puppet hostnames and that would like to sanitize them before reporting those in Datadog.
Related to #1
Hosts may show up as duplicates in infrastructure list, with puppet metrics only intermittently reporting. Some cases have included a workaround specific to each case, but these workarounds need to be included each time the puppet module is updated
The text was updated successfully, but these errors were encountered: