This commit is contained in:
Diogenes Pelisson 2020-04-21 19:54:44 -03:00
parent 653277b1d5
commit d4dbe48400
4 changed files with 31 additions and 26 deletions

View File

@ -17,12 +17,12 @@ loki_tags: []
loki_listen_address: 127.0.0.1
loki_listen_port: 3100
promtail_listen_address: "{{ loki_listen_address }}"
loki_binary_local_dir: ''
loki_target: all
loki_auth_enabled: false
loki_auth_enabled: 'false'
loki_server_config:
http_listen_address: "{{ loki_listen_address }}"
http_listen_port: "{{ loki_listen_port }}"
@ -57,15 +57,19 @@ loki_schema_config:
object_store: filesystem
schema: v11
index:
prefix: loki
prefix: index_
period: 168h
chunks:
prefix: loki
prefix: index_
period: 168h
row_shards: 16
loki_limits_config: []
loki_limits_config:
enforce_metric_name: false
reject_old_samples: true
reject_old_samples_max_age: 168h
loki_frontend_worker_config: []
loki_runtime_config: []
loki_table_manager_config:
@ -87,27 +91,23 @@ promtail_client_config:
- url: "http://{{ loki_listen_address }}:{{ loki_listen_port }}/loki/api/v1/push"
promtail_server_config:
http_listen_address: "{{ promtail_listen_address }}"
http_listen_port: 9080
grpc_listen_address: "{{ promtail_listen_address }}"
grpc_listen_port: 0
promtail_scrape_config:
- job_name: system
pipeline_stages:
static_configs:
- targets:
- localhost
labels:
job: varlogs
host: "{{ ansible_hostname }}"
__path__: /var/log/*.log
- job_name: journal
journal:
max_age: 12h
labels:
job: systemd-journal
host: "{{ ansible_hostname }}"
max_age: 12h
relabel_configs:
- source_labels: ['__journal__systemd_unit']
target_label: 'unit'
- source_labels:
- __journal__systemd_unit
target_label: unit
promtail_target_config: []
promtail_target_config: []
promtail_positions_config:
filename: /tmp/positions.yaml

View File

@ -25,6 +25,7 @@
- "{{ loki_storage_dir }}"
- "{{ loki_storage_dir }}/index"
- "{{ loki_storage_dir }}/chunks"
when: ('loki' in loki_bins)
- name: create loki configuration directories
file:

View File

@ -1,8 +1,8 @@
---
# - name: Assert usage of systemd as an init system
# assert:
# that: ansible_service_mgr == 'systemd'
# msg: "This module only works with systemd"
- name: Assert usage of systemd as an init system
assert:
that: ansible_service_mgr == 'systemd'
msg: "This module only works with systemd"
- block:
- name: Get latest release
@ -20,7 +20,7 @@
until: _latest_release.status == 200
retries: 5
- name: "Set loki version to {{ _latest_release.json.tag_name[1:] }}"
- name: Set loki version to {{ _latest_release.json.tag_name[1:] }}
set_fact:
loki_version: "{{ _latest_release.json.tag_name[1:] }}"
when:
@ -28,12 +28,12 @@
- loki_binary_local_dir | length == 0
- block:
- name: "Get checksum list"
- name: Get checksum list
set_fact:
__loki_checksums: "{{ lookup('url', 'https://github.com/grafana/loki/releases/download/v' + loki_version + '/SHA256SUMS', wantlist=True) | list }}"
run_once: true
- name: "Get checksum for {{ item[1] }} in {{ go_arch }} architecture"
- name: Get checksum for bins
set_fact:
__loki_bins_checksum: "{{ __loki_bins_checksum | default({}) | combine({item[1]: item[0].split()[0]}) }}"
loop: "{{ lookup('nested', __loki_checksums, loki_bins, wantlist=True) }}"

View File

@ -5,6 +5,10 @@
server:
{{ promtail_server_config | to_nice_yaml(indent=2) | indent(2, False) }}
{% endif %}
{% if promtail_positions_config != [] %}
positions:
{{ promtail_positions_config | to_nice_yaml(indent=2) | indent(2, False) }}
{% endif %}
{% if promtail_client_config != [] %}
clients:
{{ promtail_client_config | to_nice_yaml(indent=2) | indent(2, False) }}