Add prometheus-es-exporter
Example config in cluster model:
```
properties:
prometheus:
elasticsearch_exporter:
queries:
all:
enabled: False
terms:
indices: '<notification-{now/d}>'
json: |
{
"size": 0,
"query": {
"match_all": {}
},
"aggs": {
"program": {
"terms": {
"field": "programname.keyword"
}
}
}
}
```
Change-Id: I86553b392f7af669913052430ba6778b1c537154
Related-bug: PROD-27904 (PROD:27904)
diff --git a/metadata/service/elasticsearch_exporter/container.yml b/metadata/service/elasticsearch_exporter/container.yml
new file mode 100644
index 0000000..565cb4f
--- /dev/null
+++ b/metadata/service/elasticsearch_exporter/container.yml
@@ -0,0 +1,11 @@
+applications:
+ - prometheus
+parameters:
+ prometheus:
+ elasticsearch_exporter:
+ enabled: true
+ queries:
+ default:
+ json: {}
+ dir:
+ config: /srv/local/elasticsearch_exporter
diff --git a/prometheus/elasticsearch_exporter.sls b/prometheus/elasticsearch_exporter.sls
new file mode 100644
index 0000000..099d082
--- /dev/null
+++ b/prometheus/elasticsearch_exporter.sls
@@ -0,0 +1,17 @@
+{% from "prometheus/map.jinja" import elasticsearch_exporter with context %}
+{%- if elasticsearch_exporter.enabled %}
+ {%- if pillar.docker is defined and pillar.docker.host is defined %}
+
+{{elasticsearch_exporter.dir.config}}:
+ file.directory:
+ - makedirs: True
+
+{{elasticsearch_exporter.dir.config}}/elasticsearch_exporter.cfg:
+ file.managed:
+ - source: salt://prometheus/files/elasticsearch_exporter.cfg
+ - template: jinja
+ - require:
+ - file: {{elasticsearch_exporter.dir.config}}
+
+ {%- endif %}
+{%- endif %}
diff --git a/prometheus/files/elasticsearch_exporter.cfg b/prometheus/files/elasticsearch_exporter.cfg
new file mode 100644
index 0000000..0f43e20
--- /dev/null
+++ b/prometheus/files/elasticsearch_exporter.cfg
@@ -0,0 +1,22 @@
+{% from "prometheus/map.jinja" import elasticsearch_exporter with context %}
+
+[DEFAULT]
+QueryIntervalSecs = {{ elasticsearch_exporter.query_interval|default(15) }}
+QueryTimeoutSecs = {{ elasticsearch_exporter.query_timeout|default(15) }}
+QueryIndices = {{ elasticsearch_exporter.query_indices|default('_all') }}
+
+{%- for name, query in elasticsearch_exporter.queries.iteritems() | sort %}
+ {%- if query.get('enabled', True) %}
+[query_{{ name }}]
+ {%- if query.interval is defined %}
+QueryIntervalSecs = {{ query.interval }}
+ {%- endif %}
+ {%- if query.timeout is defined %}
+QueryTimeoutSecs = {{ query.timeout }}
+ {%- endif %}
+ {%- if query.indices is defined %}
+QueryIndices = {{ query.indices }}
+ {%- endif %}
+QueryJson = {{ query.json|json }}
+ {%- endif %}
+{%- endfor %}
diff --git a/prometheus/init.sls b/prometheus/init.sls
index 17d2656..608e759 100644
--- a/prometheus/init.sls
+++ b/prometheus/init.sls
@@ -3,6 +3,7 @@
pillar.prometheus.get('alerta', {}).get('enabled', False) or
pillar.prometheus.get('pushgateway', {}).get('enabled', False) or
pillar.prometheus.get('sf_notifier', {}).get('enabled', False) or
+ pillar.prometheus.get('elasticsearch_exporter', {}).get('enabled', False) or
pillar.prometheus.alertmanager is defined or
pillar.prometheus.exporters is defined %}
include:
@@ -21,6 +22,9 @@
{%- if pillar.prometheus.get('sf_notifier', {}).get('enabled', False) %}
- prometheus.sf_notifier
{%- endif %}
+ {%- if pillar.prometheus.get('elasticsearch_exporter', {}).get('enabled', False) %}
+ - prometheus.elasticsearch_exporter
+ {%- endif %}
{%- if pillar.prometheus.alertmanager is defined %}
- prometheus.alertmanager
{%- endif %}
diff --git a/prometheus/map.jinja b/prometheus/map.jinja
index 386d453..45718d8 100644
--- a/prometheus/map.jinja
+++ b/prometheus/map.jinja
@@ -82,3 +82,8 @@
'default': {
},
}, merge=salt['pillar.get']('prometheus:sf_notifier')) %}}
+
+{% set elasticsearch_exporter = salt['grains.filter_by']({
+ 'default': {
+ },
+}, merge=salt['pillar.get']('prometheus:elasticsearch_exporter')) %}