Skip to content

Commit

Permalink
Adds option to add extra scrape targets for node exporter
Browse files Browse the repository at this point in the history
This enables you to scrape external targets more easily.

Change-Id: I55b612d2f5f5a3fc8d21c6d2f71d6c58d89d4e31
  • Loading branch information
jovial authored and technowhizz committed Sep 11, 2024
1 parent d9c2d18 commit 02d1b8a
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ansible/roles/prometheus/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,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
####################
Expand Down
7 changes: 7 additions & 0 deletions ansible/roles/prometheus/templates/prometheus.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
26 changes: 26 additions & 0 deletions doc/source/reference/logging-and-monitoring/prometheus-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,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
Original file line number Diff line number Diff line change
@@ -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
<reference/logging-and-monitoring/prometheus-guide.html>` for more
information.

0 comments on commit 02d1b8a

Please sign in to comment.