r/f-b-arr: Configure Fluent Bit for Servarr logs

The _fluent-bit-servarr_ role creates a configuration file for Fluent
Bit to read and parse logs from Radarr, Sonarr, and Prowlarr.  These
logs can then be sent to an output by defining the
`fluent_bit_servarr_outputs` variable.
This commit is contained in:
2025-12-03 22:36:35 -06:00
parent 23670338b3
commit f892570467
6 changed files with 70 additions and 0 deletions

View File

@@ -0,0 +1 @@
fluent_bit_servarr_outputs: []

View File

@@ -0,0 +1,4 @@
- name: restart fluent-bit
service:
name: fluent-bit
state: restarted

View File

@@ -0,0 +1,2 @@
dependencies:
- role: systemd-base

View File

@@ -0,0 +1,12 @@
- name: ensure fluent-bit configuration for servarr is in place
copy:
content: |+
{{ fluent_bit_servarr_config | to_nice_yaml(indent=2) }}
dest: /etc/fluent-bit/include/servarr.yml
mode: u=rw,go=r
owner: root
group: root
notify:
- restart fluent-bit
tags:
- config

View File

@@ -0,0 +1,45 @@
servarr_logs:
- /var/log/prowlarr/*.txt
- /var/log/radarr/*.txt
- /var/log/sonarr/*.txt
fluent_bit_servarr_config:
multiline_parsers:
- name: multiline_servarr
type: regex
flush_timeout: 500
rules:
- state: start_state
regex: ^\d{4}-\d{2}-\d{2} [ 0-2]?\d:\d{2}:\d{2}\.\d+\|
next_state: cont
- state: cont
regex: ^(?!\d{4}-\d{2}-\d{2} [ 0-2]?\d:\d{2}:\d{2}\.\d+\|).*
next_state: cont
parsers:
- name: servarr
format: regex
regex: /^(?<timestamp>\d{4}-\d{2}-\d{2} [ 0-2]?\d:\d{2}:\d{2}\.\d+)\|(?<level>[^|]+)\|(?<logger>[^|]+)\|(?<log>.*)/m
time_key: timestamp
time_format: '%Y-%m-%d %H:%M:%S.%L'
pipeline:
inputs:
- name: tail
alias: servarr
tag: servarr
path: '{{ servarr_logs | join(",") }}'
path_key: filename
multiline.parser: multiline_servarr
db: /var/lib/fluent-bit/servarr.db
read_from_head: true
filters:
- name: parser
alias: servarr
match: servarr
key_name: log
parser: servarr
reserve_data: true
outputs: '{{ fluent_bit_servarr_outputs }}'

View File

@@ -1,3 +1,9 @@
- import_playbook: prowlarr.yml
- import_playbook: radarr.yml
- import_playbook: sonarr.yml
- hosts: servarr
roles:
- role: fluent-bit-servarr
tags:
- fluent-bit