mirror of
https://github.com/prometheus-community/ansible
synced 2024-11-10 06:14:13 +00:00
Merge pull request #368 from manzsolutions-lpr/add-prometheus-scrape-config-files
feat: Added prometheus scrape_config_files support
This commit is contained in:
commit
9d34d42809
5 changed files with 31 additions and 0 deletions
|
@ -97,6 +97,10 @@ prometheus_static_targets_files:
|
|||
- prometheus/targets/*.yml
|
||||
- prometheus/targets/*.json
|
||||
|
||||
prometheus_scrape_config_files:
|
||||
- prometheus/targets/*.yml
|
||||
- prometheus/targets/*.json
|
||||
|
||||
# yamllint disable rule:line-length
|
||||
prometheus_alert_rules: # noqa yaml[line-length] # noqa line-length
|
||||
- alert: Watchdog
|
||||
|
|
|
@ -150,6 +150,15 @@ argument_specs:
|
|||
default:
|
||||
- "prometheus/targets/*.yml"
|
||||
- "prometheus/targets/*.json"
|
||||
prometheus_scrape_config_files:
|
||||
description:
|
||||
- "List of folders where ansible will look for files containing custom scrape config configuration files which will be copied to C({{ prometheus_config_dir }}/scrapes/)."
|
||||
- "This feature is available starting from Prometheus v2.43.0."
|
||||
type: "list"
|
||||
elements: "str"
|
||||
default:
|
||||
- "prometheus/scrapes/*.yml"
|
||||
- "prometheus/scrapes/*.json"
|
||||
prometheus_system_group:
|
||||
description:
|
||||
- "System group for Prometheus."
|
||||
|
|
|
@ -70,3 +70,13 @@
|
|||
group: "{{ prometheus_system_group }}"
|
||||
mode: 0640
|
||||
with_fileglob: "{{ prometheus_static_targets_files }}"
|
||||
|
||||
- name: Copy prometheus scrape config files
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ prometheus_config_dir }}/scrapes/"
|
||||
force: true
|
||||
owner: root
|
||||
group: "{{ prometheus_system_group }}"
|
||||
mode: 0640
|
||||
with_fileglob: "{{ prometheus_scrape_config_files }}"
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
- "{{ prometheus_config_dir }}"
|
||||
- "{{ prometheus_config_dir }}/rules"
|
||||
- "{{ prometheus_config_dir }}/file_sd"
|
||||
- "{{ prometheus_config_dir }}/scrapes"
|
||||
|
||||
- name: Get prometheus binary
|
||||
when:
|
||||
|
|
|
@ -34,3 +34,10 @@ alerting:
|
|||
|
||||
scrape_configs:
|
||||
{{ prometheus_scrape_configs | to_nice_yaml(indent=2,sort_keys=False) | indent(2,False) }}
|
||||
|
||||
{% if prometheus_version is version('2.43.0', '>=') %}
|
||||
{% if prometheus_scrape_config_files != [] %}
|
||||
scrape_config_files:
|
||||
- scrapes/*
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
|
Loading…
Reference in a new issue