Skip to content

Commit

Permalink
allow multiple targets for prometheus and promtail
Browse files Browse the repository at this point in the history
  • Loading branch information
robertvolkmann committed Dec 4, 2024
1 parent 6466817 commit b29d172
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
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
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 b29d172

Please sign in to comment.