diff --git a/bundles/telegraf/items.py b/bundles/telegraf/items.py index 81b6375..4ee5ef2 100644 --- a/bundles/telegraf/items.py +++ b/bundles/telegraf/items.py @@ -11,7 +11,19 @@ telegraf_config = { 'quiet': False, 'round_interval': False, }, - 'inputs': { + 'outputs': { + 'influxdb_v2': [{ + 'urls': [node.metadata.get('telegraf/influxdb_url', repo.libs.defaults.influxdb_url)], + 'token': node.metadata.get('telegraf/influxdb_token', repo.vault.decrypt(repo.libs.defaults.influxdb_token)), + 'organization': node.metadata.get('telegraf/influxdb_org', repo.vault.decrypt(repo.libs.defaults.influxdb_org)), + 'bucket': node.metadata.get('telegraf/influxdb_bucket', repo.vault.decrypt(repo.libs.defaults.influxdb_bucket)), + }], + }, + 'inputs': {}, +} + +if node.metadata.get('telegraf/collect_default_metrics', True): + telegraf_config['inputs'] = { 'cpu': [{ 'percpu': False, 'totalcpu': True, @@ -43,17 +55,9 @@ telegraf_config = { 'nstat': [{}], 'processes': [{}], 'system': [{}], - **node.metadata.get('telegraf/input_plugins/builtin', {}), - }, - 'outputs': { - 'influxdb_v2': [{ - 'urls': [node.metadata.get('telegraf/influxdb_url', repo.libs.defaults.influxdb_url)], - 'token': node.metadata.get('telegraf/influxdb_token', repo.vault.decrypt(repo.libs.defaults.influxdb_token)), - 'organization': node.metadata.get('telegraf/influxdb_org', repo.vault.decrypt(repo.libs.defaults.influxdb_org)), - 'bucket': node.metadata.get('telegraf/influxdb_bucket', repo.vault.decrypt(repo.libs.defaults.influxdb_bucket)), - }], - }, -} + } + +telegraf_config['inputs'].update(node.metadata.get('telegraf/input_plugins/builtin', {})) # Bundlewrap can't merge lists. To work around this, telegraf/input_plugins/exec(d) # is a dict, of which we only use the value of it. This also allows us