From 64594da273fbd07aa3aff78d1f71fad948b10424 Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Tue, 22 Aug 2023 22:49:18 +0200 Subject: [PATCH] collect docker logs --- inventory/hosts.yml | 51 +++++++++++++++++------------- roles/fluentbit/fluent-bit.conf.j2 | 24 ++++++++++++-- roles/fluentbit/parsers.conf.j2 | 8 +++++ 3 files changed, 59 insertions(+), 24 deletions(-) diff --git a/inventory/hosts.yml b/inventory/hosts.yml index c586fa2..88d3e68 100644 --- a/inventory/hosts.yml +++ b/inventory/hosts.yml @@ -1,26 +1,33 @@ +hypervisors: + hosts: + atlas: + ansible_host: atlas.hyp + jefke: + ansible_host: jefke.hyp + lewis: + ansible_host: lewis.hyp + +swarm: + hosts: + maestro: + ansible_host: maestro.dmz + bancomart: + ansible_host: bancomart.dmz + handjecontantje: + ansible_host: handjecontantje.dmz + +vms: + children: + swarm: + hosts: + concourse: + ansible_host: concourse.dmz + thecloud: + ansible_host: thecloud.dmz + hermes: + ansible_host: hermes.dmz + all: children: hypervisors: - hosts: - atlas: - ansible_host: atlas.hyp - jefke: - ansible_host: jefke.hyp - lewis: - ansible_host: lewis.hyp vms: - hosts: - maestro: - ansible_host: maestro.dmz - bancomart: - ansible_host: bancomart.dmz - handjecontantje: - ansible_host: handjecontantje.dmz - concourse: - ansible_host: concourse.dmz - thecloud: - ansible_host: thecloud.dmz - nextcloud: - ansible_host: nextcloud.dmz - hermes: - ansible_host: hermes.dmz diff --git a/roles/fluentbit/fluent-bit.conf.j2 b/roles/fluentbit/fluent-bit.conf.j2 index af6b479..c5239ab 100644 --- a/roles/fluentbit/fluent-bit.conf.j2 +++ b/roles/fluentbit/fluent-bit.conf.j2 @@ -82,6 +82,13 @@ # # storage.backlog.mem_limit 5M +{% if 'swarm' in group_names %} +[INPUT] + Name forward + Listen 0.0.0.0 + Port 22222 +{% endif %} + [INPUT] Name cpu Tag cpu @@ -103,7 +110,7 @@ [OUTPUT] Name forward - Match * + Match ** Host maestro.dmz Port {{ fluent_forward_port }} @@ -119,9 +126,22 @@ Key_Name exec Parser diskfree +{% if 'swarm' in group_names %} +[FILTER] + Name parser + Match docker.forgejo_forgejo.** + Key_Name log + Parser combinedlog + +[FILTER] + Name grep + Match docker.forgejo_forgejo.** + Regex host .* +{% endif %} + [FILTER] Name record_modifier - Match * + Match ** Record hostname ${HOSTNAME} [FILTER] diff --git a/roles/fluentbit/parsers.conf.j2 b/roles/fluentbit/parsers.conf.j2 index 649f85f..1dfe46c 100644 --- a/roles/fluentbit/parsers.conf.j2 +++ b/roles/fluentbit/parsers.conf.j2 @@ -10,3 +10,11 @@ Format regex Regex ^\S+\s+\d+\s+(?\d+)\s+(?\d+)\s+(?\d+)%\s+(?\S+) Types disk_used:integer disk_available:integer disk_percentage:integer disk_mount:string + +[PARSER] + Name combinedlog + Format regex + Regex ^(?\S+)\ (?\S+)\ (?\S+)\ \[(?[^\]]+)\]\ \"(?\S+\ .+ HTTP\/\d\.\d)\"\ (?\S+)\ (?\S+)\ \"(?[^\"]*)\" \"(?[^\"]*)\" + Types host:string ident:string authuser:string request:string status:integer size:integer referer:string useragent:string + Time_Key date + Time_Format %d/%b/%Y:%H:%M:%S %z