add promtail support
This commit is contained in:
parent
1b9547ecd8
commit
248ed5fd02
4 changed files with 60 additions and 1 deletions
|
|
@ -240,6 +240,8 @@ prometheus_agent:
|
|||
preferred_ip_protocol: ip4
|
||||
prober: icmp
|
||||
jobs: {}
|
||||
promtail:
|
||||
enable: False
|
||||
scrape_timeout: ~
|
||||
scrape_interval: ~
|
||||
metrics_path: ~
|
||||
|
|
|
|||
|
|
@ -12,3 +12,8 @@
|
|||
service:
|
||||
name: prometheus-blackbox-exporter
|
||||
state: restarted
|
||||
|
||||
- name: restart grafana-promtail
|
||||
service:
|
||||
name: grafana-promtail
|
||||
state: restarted
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@
|
|||
name: certificates
|
||||
vars:
|
||||
certificates:
|
||||
certs: "{{ {}|combine(prometheus_certs, inventory_certs, recursive=True) }}"
|
||||
certs: "{{ { 'prometheus_agent': ({}|combine(prometheus_certs, inventory_certs, recursive=True))['prometheus_agent'] } }}"
|
||||
|
||||
- name: slurp up all scraper certs
|
||||
loop: "{{ prometheus_agent.scrapers.keys()|list }}"
|
||||
|
|
@ -123,6 +123,21 @@
|
|||
dest: /etc/prometheus/conf.d/rule_files/agent_{{ inventory_hostname }}.conf
|
||||
mode: 0644
|
||||
|
||||
- name: handle grafana-promtail
|
||||
when: prometheus_agent.agents.promtail.enable
|
||||
block:
|
||||
- name: install promtail
|
||||
apt:
|
||||
pkg: grafana-promtail
|
||||
- name: wrtie promtail config
|
||||
notify: restart grafana-promtail
|
||||
template:
|
||||
owner: grafana-promtail
|
||||
group: grafana-promtail
|
||||
mode: 0640
|
||||
dest: /etc/grafana-promtail.yml
|
||||
src: grafana-promtail.yml.j2
|
||||
|
||||
- name: create node-exporter-textfile group
|
||||
ansible.builtin.group:
|
||||
name: node-exporter-textfile
|
||||
|
|
|
|||
37
templates/grafana-promtail.yml.j2
Normal file
37
templates/grafana-promtail.yml.j2
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
server:
|
||||
disable: true
|
||||
http_listen_port: 9080
|
||||
grpc_listen_port: 0
|
||||
|
||||
positions:
|
||||
filename: /var/lib/grafana-promtail/positions.yaml
|
||||
|
||||
clients:
|
||||
{% for i in prometheus_agent.scrapers if prometheus_agent.scrapers[i].get("loki") %}
|
||||
{% set lokiconfig = {}|combine({ "external_labels": merged_prometheus_labels|combine( {"instance": inventory_hostname} ) }, prometheus_agent.scrapers[i]['loki'] ) %}
|
||||
- {{ lokiconfig|to_json }}
|
||||
{% endfor %}
|
||||
|
||||
scrape_configs:
|
||||
- job_name: system
|
||||
static_configs:
|
||||
- targets:
|
||||
- localhost
|
||||
labels:
|
||||
job: varlogs
|
||||
__path__: /var/log/*log
|
||||
- job_name: journal
|
||||
journal:
|
||||
max_age: 12h
|
||||
labels:
|
||||
job: systemd-journal
|
||||
relabel_configs:
|
||||
- source_labels: ['__journal__systemd_unit']
|
||||
target_label: 'unit'
|
||||
- job_name: nginx
|
||||
static_configs:
|
||||
- targets:
|
||||
- localhost
|
||||
labels:
|
||||
job: nginx
|
||||
__path__: /var/log/nginx/access-promtail.log
|
||||
Loading…
Add table
Add a link
Reference in a new issue