fluent-bit: send md alerts to ntfy
For machines that have Linux MD RAID arrays, I want to receive notifications about the status of the arrays immediately via _ntfy_. I had this before with `journal2ntfy`, but I never got around to setting it up for the current generation of machines (_nvr2_, _chromie_). Now that we have `fluent-bit` deployed, we can use its pipeline capabilities to select the subset of messages for which we want immediate alerts and send them directly to _ntfy_. We use a Lua function to transform the log record into a body compatible with _ntfy_'s JSON publish request; `fluent-bit` doesn't have any other way to set array values, as needed for the `tags` member.unifi-restore
parent
0fe296f7f3
commit
dcef009353
|
@ -147,6 +147,34 @@ fluent_bit_filters:
|
||||||
- name: grep
|
- name: grep
|
||||||
match: host.fluent-bit.service
|
match: host.fluent-bit.service
|
||||||
exclude: message \[output:http:victorialogs\] .+, HTTP status=200$
|
exclude: message \[output:http:victorialogs\] .+, HTTP status=200$
|
||||||
|
- name: rewrite_tag
|
||||||
|
alias: ntfy
|
||||||
|
match: host.*
|
||||||
|
rule: transport kernel ntfy true
|
||||||
|
- name: grep
|
||||||
|
match: ntfy
|
||||||
|
alias: ntfy.filter
|
||||||
|
regex: message ^md
|
||||||
|
- name: lua
|
||||||
|
alias: ntfy.populate
|
||||||
|
match: ntfy
|
||||||
|
code: |
|
||||||
|
function ntfy_transform(tag, timestamp, record)
|
||||||
|
record["topic"] = "alerts"
|
||||||
|
record["tags"] = {
|
||||||
|
record["hostname"],
|
||||||
|
record["syslog_identifier"],
|
||||||
|
}
|
||||||
|
return 1, timestamp, record
|
||||||
|
end
|
||||||
|
call: ntfy_transform
|
||||||
|
- name: record_modifier
|
||||||
|
alias: ntfy.clean
|
||||||
|
match: ntfy
|
||||||
|
allowlist_key:
|
||||||
|
- message
|
||||||
|
- tags
|
||||||
|
- topic
|
||||||
fluent_bit_outputs:
|
fluent_bit_outputs:
|
||||||
- name: http
|
- name: http
|
||||||
alias: victorialogs
|
alias: victorialogs
|
||||||
|
@ -161,3 +189,16 @@ fluent_bit_outputs:
|
||||||
format: json_lines
|
format: json_lines
|
||||||
json_date_format: iso8601
|
json_date_format: iso8601
|
||||||
log_response_payload: false
|
log_response_payload: false
|
||||||
|
- name: http
|
||||||
|
alias: ntfy
|
||||||
|
workers: 1
|
||||||
|
match: ntfy
|
||||||
|
host: ntfy.pyrocufflink.blue
|
||||||
|
port: 443
|
||||||
|
tls: true
|
||||||
|
tls.verify: true
|
||||||
|
tls.verify_hostname: true
|
||||||
|
uri: /
|
||||||
|
format: json_lines
|
||||||
|
json_date_key: false
|
||||||
|
log_response_payload: false
|
||||||
|
|
Loading…
Reference in New Issue