Class: DatadogExporter::Monitors::Utilities::TemplateManager
- Inherits:
-
Object
- Object
- DatadogExporter::Monitors::Utilities::TemplateManager
- Defined in:
- lib/datadog_exporter/monitors/utilities/template_manager.rb
Overview
This class transform the monitor into a template
Defined Under Namespace
Classes: PlaceholderToString, StringToPlaceholder
Instance Method Summary collapse
- #create_monitor(template, environment: :base) ⇒ Object
-
#create_template(datadog_hash, environment: :base) ⇒ Hash
Transforms the monitor to a template.
-
#initialize(config: DatadogExporter::Client::Config.new) ⇒ TemplateManager
constructor
A new instance of TemplateManager.
Constructor Details
#initialize(config: DatadogExporter::Client::Config.new) ⇒ TemplateManager
Returns a new instance of TemplateManager.
52 53 54 |
# File 'lib/datadog_exporter/monitors/utilities/template_manager.rb', line 52 def initialize(config: DatadogExporter::Client::Config.new) @config = config.organizations_config[:monitors] end |
Instance Method Details
#create_monitor(template, environment: :base) ⇒ Object
72 73 74 75 76 |
# File 'lib/datadog_exporter/monitors/utilities/template_manager.rb', line 72 def create_monitor(template, environment: :base) placeholders = @config[:placeholders][environment] replace_placeholders_with_values(placeholders, filter_by_template_keys(template)) end |
#create_template(datadog_hash, environment: :base) ⇒ Hash
Transforms the monitor to a template
Placeholders can be defined in a “organizations_config.yml” file See “organizations_config.example.yml” to see an example
If no placeholder is defined, it returns the monitor as it is
66 67 68 69 70 |
# File 'lib/datadog_exporter/monitors/utilities/template_manager.rb', line 66 def create_template(datadog_hash, environment: :base) placeholders = @config[:placeholders][environment] replace_values_with_placeholders(filter_by_template_keys(datadog_hash), placeholders) end |