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_address: 127.0.0.1
loki_listen_port: 3100 loki_listen_port: 3100
promtail_listen_address: "{{ loki_listen_address }}"
loki_binary_local_dir: '' loki_binary_local_dir: ''
loki_target: all loki_target: all
loki_auth_enabled: false loki_auth_enabled: 'false'
loki_server_config: loki_server_config:
http_listen_address: "{{ loki_listen_address }}" http_listen_address: "{{ loki_listen_address }}"
http_listen_port: "{{ loki_listen_port }}" http_listen_port: "{{ loki_listen_port }}"
@ -57,15 +57,19 @@ loki_schema_config:
object_store: filesystem object_store: filesystem
schema: v11 schema: v11
index: index:
prefix: loki prefix: index_
period: 168h period: 168h
chunks: chunks:
prefix: loki prefix: index_
period: 168h period: 168h
row_shards: 16 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_frontend_worker_config: []
loki_runtime_config: [] loki_runtime_config: []
loki_table_manager_config: loki_table_manager_config:
@ -87,27 +91,23 @@ promtail_client_config:
- url: "http://{{ loki_listen_address }}:{{ loki_listen_port }}/loki/api/v1/push" - url: "http://{{ loki_listen_address }}:{{ loki_listen_port }}/loki/api/v1/push"
promtail_server_config: promtail_server_config:
http_listen_address: "{{ promtail_listen_address }}"
http_listen_port: 9080 http_listen_port: 9080
grpc_listen_address: "{{ promtail_listen_address }}"
grpc_listen_port: 0 grpc_listen_port: 0
promtail_scrape_config: 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 - job_name: journal
journal: journal:
max_age: 12h
labels: labels:
job: systemd-journal job: systemd-journal
host: "{{ ansible_hostname }}"
max_age: 12h
relabel_configs: relabel_configs:
- source_labels: ['__journal__systemd_unit'] - source_labels:
target_label: 'unit' - __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 }}"
- "{{ loki_storage_dir }}/index" - "{{ loki_storage_dir }}/index"
- "{{ loki_storage_dir }}/chunks" - "{{ loki_storage_dir }}/chunks"
when: ('loki' in loki_bins)
- name: create loki configuration directories - name: create loki configuration directories
file: file:

View File

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

View File

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