bundles/telegraf: use node.metadate.get() everywhere
All checks were successful
bundlewrap/pipeline/head This commit looks good

This commit is contained in:
Franzi 2021-04-24 14:39:13 +02:00
parent e5c49ab172
commit ffd899534a
Signed by: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -1,5 +1,3 @@
metadata = node.metadata['telegraf']
telegraf_config = {
'agent': {
'collection_jitter': '5s',
@ -45,19 +43,23 @@ telegraf_config = {
'nstat': [{}],
'processes': [{}],
'system': [{}],
**metadata.get('input_plugins', {}).get('builtin', {}),
**node.metadata.get('telegraf/input_plugins/builtin', {}),
},
'outputs': {
'influxdb_v2': [{
'urls': [metadata['influxdb_url']],
'token': metadata['influxdb_token'],
'organization': metadata['influxdb_org'],
'bucket': metadata['influxdb_bucket'],
'urls': [node.metadata['telegraf']['influxdb_url']],
'token': node.metadata['telegraf']['influxdb_token'],
'organization': node.metadata['telegraf']['influxdb_org'],
'bucket': node.metadata['telegraf']['influxdb_bucket'],
}],
},
}
for config in metadata.get('input_plugins', {}).get('exec', {}).values():
# Bundlewrap can't merge lists. To work around this, telegraf/input_plugins/exec
# is a dict, of which we only use the value of it. This also allows us
# to overwrite values set by metadata defaults/reactors in node and group
# metadata, if needed.
for config in node.metadata.get('telegraf/input_plugins/exec', {}).values():
if 'exec' not in telegraf_config['inputs']:
telegraf_config['inputs']['exec'] = []