-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
Support repeated input types #42
Comments
|
Is this the feature you were alluding to as well @millingworth ? |
|
Would this slight modification work? define telegraf::input (
$plugin_type = $name,
$options = undef,
$sections = undef,
) {
include telegraf
if $options {
validate_hash($options)
}
if $sections {
validate_hash($sections)
}
Class['::telegraf::config']
->
file {"${telegraf::config_folder}/${name}.conf $title":
path => "${telegraf::config_folder}/${name}.conf"
content => template('telegraf/input.conf.erb')
}
~>
Class['::telegraf::service']
}Note the file resource name change. |
|
I'm not a puppet/hiera expert, but I'm not sure that will solve my issue. This is an example of the telegraf.conf that I'm hoping to generate: Here's the hiera that I would think might work: Would this scenario be supported? |
|
I doubt it. Because a hash is not able to store the same key more than once. I'm working on a new commit which would solve this problem by introducing a separate variable for repeated inputs. |
|
This applies to outputs as well. For instance, consider: 'file' => {
'files' => [
"/tmp/telegraf_output_influx.out",
],
'data_format' => "influx",
},
'file' => {
'files' => [
"/tmp/telegraf_output_graphite.out",
],
'data_format' => "graphite",
}, |
|
Same issue for me. Is it possible to configure multiple outputs of the same type using |
|
I think this is going to require a re-structuring of the parameters into something like: telegraf::inputs:
- endpoint1:
input_type: "httpjson"
servers:
- "http://localhost/foo"
method: "GET"
- endpoint2:
input_type: "httpjson"
servers:
- "http://localhost/bar"
method: "GET"The limitation of one key having one value is part of hiera, so using input/output types (which can be repeated in the telegraf.conf) as hiera keys was a mistake. This would be a compatibility breaking feature unless the code can be modified to check telegraf::inputs for sub-keys vs an array. |
|
@7yl4r You're right, it was shortsighted and we're jumping through hoops in the meantime as a result. My plan is to draw a line under this module for 1.x, and to introduce 2.0 which will depend on Puppet 4 and address problems such as this. |
|
FWIW, this is my current solution which I've picked up from other modules: Hiera: profiles::telegraf::inputs:
cloudwatch_qa_alb:
plugin_type: 'cloudwatch'
options:
profile: 'qa'
region: 'us-east-1'
period: '1m'
delay: '1m'
interval: '1m'
namespace: 'AWS/ApplicationELB'
ratelimit: 20
cloudwatch_qa_elb:
plugin_type: 'cloudwatch'
options:
profile: 'qa'
region: 'us-east-1'
period: '1m'
delay: '1m'
interval: '1m'
namespace: 'AWS/ELB'
ratelimit: 20
cloudwatch_dev_alb:
plugin_type: 'cloudwatch'
options:
profile: 'dev'
region: 'us-east-1'
period: '1m'
delay: '1m'
interval: '1m'
namespace: 'AWS/ApplicationELB'
ratelimit: 20
cloudwatch_dev_elb:
plugin_type: 'cloudwatch'
options:
profile: 'dev'
region: 'us-east-1'
period: '1m'
delay: '1m'
interval: '1m'
namespace: 'AWS/ELB'
ratelimit: 20Manifest: class profiles::telegraf (
Hash $inputs = {},
) {
include ::telegraf
create_resources(telegraf::input, $inputs)
}Which generates these configs: ==> /etc/telegraf/telegraf.d/cloudwatch_dev_alb.conf <== [[inputs.cloudwatch]]
delay = "1m"
interval = "1m"
namespace = "AWS/ApplicationELB"
period = "1m"
profile = "dev"
ratelimit = 20
region = "us-east-1"==> /etc/telegraf/telegraf.d/cloudwatch_dev_elb.conf <== [[inputs.cloudwatch]]
delay = "1m"
interval = "1m"
namespace = "AWS/ELB"
period = "1m"
profile = "dev"
ratelimit = 20
region = "us-east-1"
==> /etc/telegraf/telegraf.d/cloudwatch_qa_alb.conf <== [[inputs.cloudwatch]]
delay = "1m"
interval = "1m"
namespace = "AWS/ApplicationELB"
period = "1m"
profile = "qa"
ratelimit = 20
region = "us-east-1"==> /etc/telegraf/telegraf.d/cloudwatch_qa_elb.conf <== [[inputs.cloudwatch]]
delay = "1m"
interval = "1m"
namespace = "AWS/ELB"
period = "1m"
profile = "qa"
ratelimit = 20
region = "us-east-1" |
|
@yankcrime Any plans to (maybe) cut a branch for 2.0? I'm currently running into this issue with input and output plugins and I would love to try and help with this. |
|
I've modified this module to use a real toml generator rather than templates to fix this issue. Tests are still failing because I don't know any ruby, but everything else works fine. This requires the toml-rb gem and slightly changes the configuration structure to match the generated toml output. |
|
We use the plugin snmp and need many "snmp.field" entries. It's impossible to do this with a hash. I use this code for "sections" in input.conf.erb: Don't forget to comment "validate_hash($sections)" in input.pp My hiera file: The conf file: |
|
Closing this now that #80 has been merged which should address these use cases / issues. |
|
@yankcrime it is not obvious to me how to utilize the new functionality in #80 to accomplish the goal here. Can you give an example? |
|
Answering my own question: Two |
|
This should work too (I didn't test this, but that's how #80 was supposed to be used) |
|
Does this change mean that every hiera config needs to be changed, or do old style just-one-hash-no-array configs still work? |
|
Every hiera config needs to be changed. |
I'd like to be able to use the same input type multiple times with different configurations. For example, I have 2 urls that I'd like to monitor with http_response inputs. I'd like to use hiera to configure the inputs. Right now given the way the hiera hash is used it will only keep 1 of the repeated inputs.
The text was updated successfully, but these errors were encountered: