Add Prometheus exporters
Change-Id: I71538bc6b39edaa6a0856c8bba9de11b88cec67a
diff --git a/metadata/service/exporters/jmx.yml b/metadata/service/exporters/jmx.yml
new file mode 100644
index 0000000..04f3bc1
--- /dev/null
+++ b/metadata/service/exporters/jmx.yml
@@ -0,0 +1,13 @@
+applications:
+ - prometheus
+parameters:
+ _param:
+ prometheus_exporter_jmx_port: 9111
+ prometheus:
+ exporters:
+ jmx:
+ enabled: true
+ packages:
+ - jmx-exporter
+ bind:
+ port: ${_param:prometheus_exporter_jmx_port}
diff --git a/metadata/service/exporters/libvirt.yml b/metadata/service/exporters/libvirt.yml
new file mode 100644
index 0000000..9f277ea
--- /dev/null
+++ b/metadata/service/exporters/libvirt.yml
@@ -0,0 +1,14 @@
+applications:
+ - prometheus
+parameters:
+ _param:
+ prometheus_exporter_libvirt_port: 9177
+ prometheus:
+ exporters:
+ libvirt:
+ enabled: true
+ packages:
+ - libvirt-exporter
+ bind:
+ address: 0.0.0.0
+ port: ${_param:prometheus_exporter_libvirt_port}
diff --git a/prometheus/exporters.sls b/prometheus/exporters.sls
new file mode 100644
index 0000000..8baba39
--- /dev/null
+++ b/prometheus/exporters.sls
@@ -0,0 +1,11 @@
+{% from "prometheus/map.jinja" import exporters with context %}
+
+{%- for exporter, parameters in exporters.iteritems() %}
+ {%- if parameters.get('enabled', False) %}
+ {%- if parameters.get('packages', False) %}
+{{ exporter }}_exporter_packages:
+ pkg.installed:
+ - names: {{ parameters.packages }}
+ {%- endif %}
+ {%- endif %}
+{%- endfor %}
diff --git a/prometheus/init.sls b/prometheus/init.sls
index 3141a49..cd31765 100644
--- a/prometheus/init.sls
+++ b/prometheus/init.sls
@@ -1,5 +1,6 @@
{%- if pillar.prometheus.server is defined or
- pillar.prometheus.alertmanager is defined %}
+ pillar.prometheus.alertmanager is defined or
+ pillar.prometheus.exporters is defined %}
include:
{%- if pillar.prometheus.server is defined %}
- prometheus.server
@@ -7,4 +8,7 @@
{%- if pillar.prometheus.alertmanager is defined %}
- prometheus.alertmanager
{%- endif %}
+ {%- if pillar.prometheus.exporters is defined %}
+ - prometheus.exporters
+ {%- endif %}
{%- endif %}
diff --git a/prometheus/map.jinja b/prometheus/map.jinja
index 3ff6bb6..6d62276 100644
--- a/prometheus/map.jinja
+++ b/prometheus/map.jinja
@@ -7,3 +7,8 @@
'default': {
},
}, merge=salt['pillar.get']('prometheus:alertmanager')) %}
+
+{% set exporters = salt['grains.filter_by']({
+ 'default': {
+ },
+}, merge=salt['pillar.get']('prometheus:exporters')) %}