diff --git a/salt/telegraf/etc/telegraf.conf b/salt/telegraf/etc/telegraf.conf index 67cbf0af9..86be01e70 100644 --- a/salt/telegraf/etc/telegraf.conf +++ b/salt/telegraf/etc/telegraf.conf @@ -832,19 +832,18 @@ # ## more about them here: # ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md # data_format = "influx" -{% if salt['pillar.get']('healthcheck:enabled', 'False') %} +{%- if salt['pillar.get']('healthcheck:enabled', 'False') %} [[inputs.file]] files = ["/host/nsm/zeek/logs/zeek_restart.log"] data_format = "influx" -{% endif %} -{% if grains.role in ['so-manager', 'so-managersearch', 'so-standalone', 'so-eval'] %} +{%- endif %} [[inputs.file]] - files = ["/etc/telegraf/nodes_config.json"] - name_override = "nodes_config" + files = ["/etc/telegraf/node_config.json"] + name_override = "node_config" data_format = "json" interval = "5m" -{% endif %} - + json_string_fields = ['manint', 'monint'] + tag_keys = ['role'] # # Count files in a directory # [[inputs.filecount]] diff --git a/salt/telegraf/init.sls b/salt/telegraf/init.sls index 7c2091875..615cfc237 100644 --- a/salt/telegraf/init.sls +++ b/salt/telegraf/init.sls @@ -42,15 +42,13 @@ tgrafconf: - template: jinja - source: salt://telegraf/etc/telegraf.conf -{% if grains.role in ['so-manager', 'so-managersearch', 'so-standalone', 'so-eval'] %} #this file will be read by telegraf to send node details(management interface, monitor interface, etc) # into influx so that grafan can build dashboards using queries -node_tab: +node_config: file.managed: - - name: /opt/so/conf/telegraf/nodes_config.json - - source: salt://telegraf/nodes_config.json.jinja + - name: /opt/so/conf/telegraf/node_config.json + - source: salt://telegraf/node_config.json.jinja - template: jinja -{% endif %} so-telegraf: docker_container.running: @@ -66,9 +64,7 @@ so-telegraf: - binds: - /opt/so/log/telegraf:/var/log/telegraf:rw - /opt/so/conf/telegraf/etc/telegraf.conf:/etc/telegraf/telegraf.conf:ro -{% if grains.role in ['so-manager', 'so-managersearch', 'so-standalone', 'so-eval'] %} - - /opt/so/conf/telegraf/nodes_config.json:/etc/telegraf/nodes_config.json:ro -{% endif %} + - /opt/so/conf/telegraf/node_config.json:/etc/telegraf/node_config.json:ro - /var/run/utmp:/var/run/utmp:ro - /var/run/docker.sock:/var/run/docker.sock:ro - /:/host/root:ro @@ -91,6 +87,7 @@ so-telegraf: - watch: - file: tgrafconf - file: tgrafsyncscripts + - file: node_config append_so-telegraf_so-status.conf: file.append: diff --git a/salt/telegraf/node_config.json.jinja b/salt/telegraf/node_config.json.jinja new file mode 100644 index 000000000..6aeef5fb7 --- /dev/null +++ b/salt/telegraf/node_config.json.jinja @@ -0,0 +1,7 @@ +{ + "role": "{{ grains.id.split('_') | last }}", + "manint": "{{ salt['pillar.get']('host:mainint', '') }}", +{%- if grains.role in ['so-standalone', 'so-eval', 'so-sensor', 'so-heavynode', ] %} + "monint": "{{ salt['pillar.get']('sensor:interface', '') }}" +{% endif -%} +} diff --git a/salt/telegraf/nodes_config.json.jinja b/salt/telegraf/nodes_config.json.jinja deleted file mode 100644 index 891e944a3..000000000 --- a/salt/telegraf/nodes_config.json.jinja +++ /dev/null @@ -1,6 +0,0 @@ -{% for tabtype in ['managertab', 'managersearchtab', 'standalonetab', 'sensorstab', 'nodestab', 'evaltab'] %} - {% set node_type_data = salt['pillar.get'](tabtype, False) %} - {% if node_type_data %} - {{ node_type_data | json }} - {% endif %} -{% endfor %}