Skip to content

Commit

Permalink
Fix #5. logging role splitted into two: logging/k3s for deploying efk…
Browse files Browse the repository at this point in the history
… in k3s cluster and logging/external_nodes for deploying fluentbit in control nodes
  • Loading branch information
ricsanfre committed Oct 29, 2021
1 parent cbec271 commit c71b5fb
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 6 deletions.
12 changes: 11 additions & 1 deletion ansible/group_vars/control.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
##########################
# fluentbit configuration
##########################


# Fluentbit_inputs
fluentbit_inputs:
- Name: tail
Expand All @@ -16,6 +18,14 @@ fluentbit_inputs:
Path_key: log_file
DB: /run/fluent-bit-syslog.state
Parser: syslog-rfc3164-nopri

# Fluentbit_filters
fluentbit_filters:
- name: lua
match: "*"
script: /etc/td-agent-bit/adjust_ts.lua
call: local_timestamp_to_UTC

# Fluentbit Elasticsearch output
fluentbit_outputs:
- Name: es
Expand All @@ -39,4 +49,4 @@ fluentbit_custom_parsers:
Time_Key: time
Time_Format: "%b %d %H:%M:%S"
Time_Keep: false # Remove duplicated time field, avoid elasticsearh processing error
Time_Offset: "+0200" # Add TimeZone UTC offset
# Time_Offset: "+0200" # Add TimeZone UTC offset
8 changes: 4 additions & 4 deletions ansible/k3s_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
tags: ['certmanager']
- role: longhorn
tags: ['longhorn']
- role: logging
- role: logging/k3s
tags: ['logging']

- name: Deploy fluentbit on Pi Cluster Gateway
hosts: gateway
- name: Deploy fluentbit on control nodes (gateway and pimaster)
hosts: control
gather_facts: true
tags: [logging]
vars:
ansible_become: true
roles:
- role: ricsanfre.fluentbit
- role: logging/external_node
tags: ['logging']
2 changes: 1 addition & 1 deletion ansible/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ roles:
- name: ricsanfre.k8s_cli
version: v1.0.0
- name: ricsanfre.fluentbit
version: v1.0.2
version: v1.0.3
collections:
- name: kubernetes.core
version: 2.1.1
10 changes: 10 additions & 0 deletions ansible/roles/logging/external_node/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
# Deploy fluentbit
- name: Deploy fluentbit.
include_role:
name: ricsanfre.fluentbit
vars:
# lua scripts
fluentbit_lua_scripts:
- name: adjust_ts.lua
content: "{{ lookup('template','templates/adjust_ts.lua') }}"
7 changes: 7 additions & 0 deletions ansible/roles/logging/external_node/templates/adjust_ts.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function local_timestamp_to_UTC(tag, timestamp, record)
local utcdate = os.date("!*t", ts)
local localdate = os.date("*t", ts)
localdate.isdst = false -- this is the trick
utc_time_diff = os.difftime(os.time(localdate), os.time(utcdate))
return 1, timestamp - utc_time_diff, record
end
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit c71b5fb

Please sign in to comment.