Skip to content

Commit

Permalink
Allow multiple prometheus and promtail targets
Browse files Browse the repository at this point in the history
  • Loading branch information
simcod committed Jan 15, 2025
1 parent 10e7af1 commit 02d108b
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 52 deletions.
50 changes: 24 additions & 26 deletions partition/roles/monitoring/prometheus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,27 @@ Deploys prometheus in a systemd-managed Docker container.
This role uses variables from [partition-defaults](/partition). So, make sure
you define them adequately as well.

| Name | Mandatory | Description |
| ------------------------------------------------ | --------- | ----------------------------------------------------------- |
| prometheus_port | | Port for prometheus |
| prometheus_image_name | yes | Image version of the prometheus |
| prometheus_image_tag | yes | Image tag of the prometheus |
| prometheus_config_host_dir | | The host directory for prometheus configurations |
| prometheus_data_host_dir | | The host directory for prometheus data |
| prometheus_alertmanager_target | | Targets for the alertmanager |
| prometheus_alertmanager_basic_auth_username | | The username for the authentication to the alertmanager |
| prometheus_alertmanager_basic_auth_password | | The password for the authentication to the alertmanager |
| prometheus_remote_write_url | | Remote write target for prometheus |
| prometheus_frr_exporter_targets | | FRR exporter targets to scrape from |
| prometheus_metal_core_targets | | metal-core targets to scrape from |
| prometheus_node_exporter_targets | | Node exporter targets to scrape from |
| prometheus_promtail_targets | | Promtail targets to scrape from |
| prometheus_ping_targets | | Ping targets to scrape from |
| prometheus_sonic_exporter_targets | | Sonic exporter targets to scrape from |
| prometheus_blackbox_exporter_targets | | Blackbox exporter targets to scrape from |
| prometheus_lightbox_exporter_targets | | Lightbox exporter targets to scrape from |
| prometheus_lightos_smart_targets | | Lightos smart targets to scrape from |
| prometheus_ipmi_exporter_targets | | IPMI exporter targets to scrape from |
| prometheus_hosts_content | | Available hosts for prometheus |
| prometheus_blackbox_exporter_icmp_groups | | ICMP groups for the blackbox exporter |
| prometheus_blackbox_exporter_metal_api_probe_url | | metal-api probe URL for the blackbox exporter |
| prometheus_remote_write_basic_auth_username | | The username for the prometheus remote write authentication |
| prometheus_remote_write_basic_auth_password | | The password for the prometheus remote write authentication |
| Name | Mandatory | Description |
| ------------------------------------------------ | --------- | ------------------------------------------------------- |
| prometheus_port | | Port for prometheus |
| prometheus_image_name | yes | Image version of the prometheus |
| prometheus_image_tag | yes | Image tag of the prometheus |
| prometheus_config_host_dir | | The host directory for prometheus configurations |
| prometheus_data_host_dir | | The host directory for prometheus data |
| prometheus_alertmanager_target | | Targets for the alertmanager |
| prometheus_alertmanager_basic_auth_username | | The username for the authentication to the alertmanager |
| prometheus_alertmanager_basic_auth_password | | The password for the authentication to the alertmanager |
| prometheus_remote_write | | Remote write target for prometheus |
| prometheus_frr_exporter_targets | | FRR exporter targets to scrape from |
| prometheus_metal_core_targets | | metal-core targets to scrape from |
| prometheus_node_exporter_targets | | Node exporter targets to scrape from |
| prometheus_promtail_targets | | Promtail targets to scrape from |
| prometheus_ping_targets | | Ping targets to scrape from |
| prometheus_sonic_exporter_targets | | Sonic exporter targets to scrape from |
| prometheus_blackbox_exporter_targets | | Blackbox exporter targets to scrape from |
| prometheus_lightbox_exporter_targets | | Lightbox exporter targets to scrape from |
| prometheus_lightos_smart_targets | | Lightos smart targets to scrape from |
| prometheus_ipmi_exporter_targets | | IPMI exporter targets to scrape from |
| prometheus_hosts_content | | Available hosts for prometheus |
| prometheus_blackbox_exporter_icmp_groups | | ICMP groups for the blackbox exporter |
| prometheus_blackbox_exporter_metal_api_probe_url | | metal-api probe URL for the blackbox exporter |
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,9 @@ alerting:
- targets: [{{ prometheus_alertmanager_target }}]
{% endif %}

{% if prometheus_remote_write_url %}
{% if prometheus_remote_write %}
remote_write:
- url: {{ prometheus_remote_write_url }}
{% if prometheus_remote_write_basic_auth_username is defined and prometheus_remote_write_basic_auth_password is defined %}
basic_auth:
username: {{ prometheus_remote_write_basic_auth_username }}
password: {{ prometheus_remote_write_basic_auth_password }}
{% endif %}
{{ prometheus_remote_write | to_yaml(indent=2) }}
{% endif %}

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
Expand Down
16 changes: 7 additions & 9 deletions partition/roles/promtail/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ Deploys promtail in a systemd-managed Docker container.

## Variables

| Name | Mandatory | Description |
| --------------------------------- | --------- | ------------------------------------------ |
| promtail_config_host_dir | | The location of the promtail config |
| promtail_image_name | yes | Image version of the promtail |
| promtail_image_tag | yes | Image tag of the promtail |
| promtail_loki_push_endpoint | yes | The URL to the Loki push endpoint |
| promtail_scrape_configs | yes | A list containing the scrape configs |
| promtail_loki_basic_auth_username | | The username for the client authentication |
| promtail_loki_basic_auth_password | | The password for the client authentication |
| Name | Mandatory | Description |
| ------------------------ | --------- | ------------------------------------ |
| promtail_config_host_dir | | The location of the promtail config |
| promtail_image_name | yes | Image version of the promtail |
| promtail_image_tag | yes | Image tag of the promtail |
| promtail_clients | yes | Configuration for promtail clients |
| promtail_scrape_configs | yes | A list containing the scrape configs |
2 changes: 1 addition & 1 deletion partition/roles/promtail/defaults/main/main.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
promtail_config_host_dir: "/etc/promtail"

promtail_loki_push_endpoint:
promtail_clients: []
promtail_scrape_configs: []
2 changes: 1 addition & 1 deletion partition/roles/promtail/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
fail_msg: "not all mandatory variables given, check role documentation"
quiet: yes
that:
- promtail_clients
- promtail_image_tag is defined
- promtail_image_name is defined
- promtail_loki_push_endpoint is not none
- promtail_scrape_configs is defined and (promtail_scrape_configs|length>0)

- name: Create promtail config directory
Expand Down
10 changes: 2 additions & 8 deletions partition/roles/promtail/templates/promtail.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ positions:
filename: /var/log/promtail-positions.yaml

clients:
- url: {{ promtail_loki_push_endpoint }}
timeout: 60s
{% if promtail_loki_basic_auth_username is defined and promtail_loki_basic_auth_password is defined %}
basic_auth:
username: {{ promtail_loki_basic_auth_username }}
password: {{ promtail_loki_basic_auth_password }}
{% endif %}
{{ promtail_clients | to_yaml(indent=2) }}

scrape_configs:
{{ promtail_scrape_configs|to_yaml(indent=2) }}
{{ promtail_scrape_configs | to_yaml(indent=2) }}

0 comments on commit 02d108b

Please sign in to comment.