Merge "Add telegraf ping plugin" into release/2019.2.0
diff --git a/metadata/service/support.yml b/metadata/service/support.yml
index 21ff9f2..213c3a1 100644
--- a/metadata/service/support.yml
+++ b/metadata/service/support.yml
@@ -5,4 +5,6 @@
enabled: true
prometheus:
enabled: true
+ telegraf:
+ enabled: true
diff --git a/telegraf/files/input/ping.conf b/telegraf/files/input/ping.conf
new file mode 100644
index 0000000..5bae6a3
--- /dev/null
+++ b/telegraf/files/input/ping.conf
@@ -0,0 +1,17 @@
+[[inputs.ping]]
+{%- include 'telegraf/files/input/_common.conf' %}
+urls = {{ values.urls | sort | json }}
+count = {{ values.get("count", 1) }}
+ping_interval = {{ values.get("ping_interval", 1.0) | float}}
+timeout = {{ values.get("timeout", 1.0) | float }}
+deadline = {{ values.get("deadline", 10) }}
+{%- if values.interface is defined %}
+interface = "{{ values.interface }}"
+{%- endif %}
+{%- if values.binary is defined %}
+binary = "{{ values.binary }}"
+{%- endif %}
+{%- if values.get("arguments", False) %}
+arguments = {{ values.arguments | json }}
+{%- endif %}
+{%- include 'telegraf/files/input/_filters.conf' %}
diff --git a/telegraf/meta/prometheus.yml b/telegraf/meta/prometheus.yml
index 994597a..c93b7f3 100644
--- a/telegraf/meta/prometheus.yml
+++ b/telegraf/meta/prometheus.yml
@@ -14,9 +14,20 @@
{%- endif %}
{%- endif %}
{%- endif %}
-
-{%- if address is defined %}
server:
+ alert:
+ NodeDown:
+ if: >-
+ sum by (host, url) (label_replace((up{job=~"telegraf|fluentd"}), "url", "$1", "instance", "(.*):.*")) + on (url) group_left abs(clamp_max(ping_result_code, 1) - 1) == 0
+ labels:
+ severity: critical
+ service: system
+ annotations:
+{%- raw %}
+ summary: "The {{ $labels.host }} node is down"
+ description: "The {{ $labels.host }} node is unreachable at {{ $labels.url }}, the Telegraf and Fluentd targets on the {{ $labels.host }} node are down."
+{%- endraw %}
+{%- if address is defined %}
target:
static:
telegraf:
diff --git a/telegraf/meta/telegraf.yml b/telegraf/meta/telegraf.yml
new file mode 100644
index 0000000..2965166
--- /dev/null
+++ b/telegraf/meta/telegraf.yml
@@ -0,0 +1,20 @@
+{%- if pillar.telegraf.remote_agent is defined %}
+ {%- set addresses = [] %}
+ {%- for node_name, node_grains in salt['mine.get']('*', 'grains.items').items() %}
+ {%- if node_grains.get('dns_records', []) is iterable %}
+ {%- for record in node_grains.get('dns_records', []) %}
+ {%- do addresses.append(record.address) %}
+ {%- endfor %}
+ {%- endif %}
+ {%- endfor %}
+ {%- if addresses %}
+remote_agent:
+ input:
+ ping:
+ urls: {{ addresses }}
+ count: 1
+ ping_interval: 0.2
+ timeout: 10
+ deadline: 0
+ {%- endif %}
+{%- endif %}