-
Notifications
You must be signed in to change notification settings - Fork 2
change: telegraf reqired tags added at internal code #182
change: telegraf reqired tags added at internal code #182
Conversation
…nd telegraph metric definitions into toml strings
@@ -395,7 +397,64 @@ impl MetricCollectorManager { | |||
}; | |||
|
|||
let mut outputs_toml = toml::value::Array::new(); | |||
let mut inputs_map = HashMap::<String, Vec<serde_json::Map<std::string::String, serde_json::Value>>>::new(); | |||
if metric_definition.collector == "telegraf" { |
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.
duplicated code
metric_definition.collector == "telegraf"
|
||
let mut outputs_toml = toml::value::Array::new(); | ||
let mut inputs_map = HashMap::<String, Vec<serde_json::Map<std::string::String, serde_json::Value>>>::new(); | ||
if metric_definition.collector == "telegraf" { |
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.
duplicated line
error!("[telegraf] inputs not found"); | ||
continue; | ||
}; | ||
let Some(inputs_object) = inputs.as_object() else { |
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.
let Some(inputs_object) = metric_definition.metadata.get("inputs").and_then(|inputs| inputs.as_object()) else {
error!("[telegraf] Failed to convert metadata.inputs to as_object");
continue;
};
continue; | ||
}; | ||
|
||
let mut inputs_object_arr = Vec::<serde_json::Map<std::string::String, serde_json::Value>>::new(); |
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.
add a comment to describe the data structure
//
// Example:
// { // inputs_object
// cloudwatch: [ // inputs_object_arr
// {
// cloudwatch
// },
// {
// cloudwatch
// }
// ]
// }
//
//
…nto 180-telegraf-delete-required-tags-and-handle-internal
let mut root_toml = "".to_string(); | ||
// Create a TOML array representing the metric definitions | ||
for metric_definition in metric_definitions { | ||
if !validation_vector_definition(metric_definition) { |
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.
It would be good that function names start with a verb
validation_vector_definition => validate_vector_definition
Types of changes
What this PR does / why we need it:
Delete required tags from metric definition and handle them internally.
Which issue/s this PR fixes
fixes #180
How Has This Been Tested?
Checklist: