diff --git a/ansible/roles/prometheus/defaults/main.yml b/ansible/roles/prometheus/defaults/main.yml index cdd3cf485e..83a2a42102 100644 --- a/ansible/roles/prometheus/defaults/main.yml +++ b/ansible/roles/prometheus/defaults/main.yml @@ -171,6 +171,11 @@ prometheus_mysql_exporter_database_user: "{% if use_preconfigured_databases | bo prometheus_active_passive: true prometheus_alertmanager_active_passive: true +#################### +# Node Exporter +#################### +prometheus_node_exporter_targets_extra: [] + #################### # Blackbox #################### diff --git a/ansible/roles/prometheus/templates/prometheus.yml.j2 b/ansible/roles/prometheus/templates/prometheus.yml.j2 index e56bb19ab4..915e3f7e95 100644 --- a/ansible/roles/prometheus/templates/prometheus.yml.j2 +++ b/ansible/roles/prometheus/templates/prometheus.yml.j2 @@ -42,6 +42,13 @@ scrape_configs: instance: "{{ hostvars[host].prometheus_instance_label }}" {% endif %} {% endfor %} +{% for target in prometheus_node_exporter_targets_extra %} + - targets: + - '{{ target.target }}' +{% if target.labels | default({}, true) %} + labels: {{ target.labels | to_json }} +{% endif %} +{% endfor %} {% endif %} {% if enable_prometheus_mysqld_exporter | bool %} diff --git a/doc/source/reference/logging-and-monitoring/prometheus-guide.rst b/doc/source/reference/logging-and-monitoring/prometheus-guide.rst index a36e906f2e..5229b882d2 100644 --- a/doc/source/reference/logging-and-monitoring/prometheus-guide.rst +++ b/doc/source/reference/logging-and-monitoring/prometheus-guide.rst @@ -217,3 +217,29 @@ sure to set the ``prometheus_instance_label`` variable to ``None``. This feature may generate duplicate metrics temporarily while Prometheus updates the metric labels. Please be aware of this while analyzing metrics during the transition period. + +Exporter configuration +~~~~~~~~~~~~~~~~~~~~~~ + +Node Exporter +------------- + +Sometimes it can be useful to monitor hosts outside of the Kolla deployment. +One method of doing this is to configure a list of additional targets using the +``prometheus_node_exporter_targets_extra`` variable. The format of which +should be a list of dictionaries with the following keys: + +* target: URL of node exporter to scrape +* labels: (Optional) A list of labels to set on the metrics scaped from this + exporter. + +For example: + +.. code-block:: yaml + :caption: ``/etc/kolla/globals.yml`` + + prometheus_node_exporter_targets_extra: + - target: http://10.0.0.1:1234 + labels: + instance: host1 + diff --git a/releasenotes/notes/adds-node-exporter-targets-extra-c037d4755d1002e8.yaml b/releasenotes/notes/adds-node-exporter-targets-extra-c037d4755d1002e8.yaml new file mode 100644 index 0000000000..39a25b042c --- /dev/null +++ b/releasenotes/notes/adds-node-exporter-targets-extra-c037d4755d1002e8.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + Adds ``prometheus_node_exporter_targets_extra`` to add additional scrape + targets to the node exporter job. See kolla-ansible-doc:`documentation + ` for more + information.