bundles/telegraf: add option to opt-out of default metrics

This commit is contained in:
Franzi 2024-07-31 17:40:36 +02:00
parent 6854bd55ff
commit a1eb9cb3fc

View file

@ -11,7 +11,19 @@ telegraf_config = {
'quiet': False, 'quiet': False,
'round_interval': 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': [{ 'cpu': [{
'percpu': False, 'percpu': False,
'totalcpu': True, 'totalcpu': True,
@ -43,17 +55,9 @@ telegraf_config = {
'nstat': [{}], 'nstat': [{}],
'processes': [{}], 'processes': [{}],
'system': [{}], 'system': [{}],
**node.metadata.get('telegraf/input_plugins/builtin', {}), }
},
'outputs': { telegraf_config['inputs'].update(node.metadata.get('telegraf/input_plugins/builtin', {}))
'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)),
}],
},
}
# Bundlewrap can't merge lists. To work around this, telegraf/input_plugins/exec(d) # 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 # is a dict, of which we only use the value of it. This also allows us