-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathingest_loki_data.yml
More file actions
43 lines (37 loc) · 1.15 KB
/
ingest_loki_data.yml
File metadata and controls
43 lines (37 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
---
# Ingest data log to Loki that is generated from gen_synth_loki_data.yml"
# Push the json format data log to loki
- name: Ingest data log to Loki via API
block:
- name: Read log file content
ansible.builtin.slurp:
src: "{{ ck_output_file_remote }}"
register: log_file_content
- name: Push data to Loki
ansible.builtin.uri:
url: "{{ loki_push_url }}"
method: POST
body: "{{ log_file_content['content'] | b64decode | from_json }}"
body_format: json
client_cert: "{{ cert_dir }}/tls.crt"
client_key: "{{ cert_dir }}/tls.key"
validate_certs: false
status_code: 204
return_content: yes
register: loki_response
ignore_errors: false
failed_when: loki_response.status != 204
# Success
- name: Confirm Success
ansible.builtin.debug:
msg: "Ingestion Successful!"
rescue:
# Rescue block
- name: Debug failure
ansible.builtin.debug:
msg: "{{ loki_response.status }}"
# Failure
- name: Report Ingestion Failure
ansible.builtin.fail:
msg: "Ingestion Failed"
ignore_errors: false