diff options
author | Yash Goyal <ygoyal@wigwag.com> | 2021-01-12 22:31:51 -0800 |
---|---|---|
committer | Yash Goyal <ygoyal@wigwag.com> | 2021-01-12 22:31:51 -0800 |
commit | e14e9cb52b20a3d8c66f3bf11204d820735848f1 (patch) | |
tree | 2868b448f801e650fea39def270da5a90b90150f /recipes-extended | |
parent | 6c185f8dcecd598a95cafbc085bd2a55e36a6059 (diff) |
1. Added Fluentbit bbappend file.
1. Adding default fluentbit configuration file.
1. Adding watcher service to restart Fluenbit when configuration is updated.
Diffstat (limited to 'recipes-extended')
5 files changed, 327 insertions, 0 deletions
diff --git a/recipes-extended/fluentbit/files/td-agent-bit-watcher.service b/recipes-extended/fluentbit/files/td-agent-bit-watcher.service new file mode 100644 index 0000000..cf7084b --- /dev/null +++ b/recipes-extended/fluentbit/files/td-agent-bit-watcher.service @@ -0,0 +1,9 @@ +[Unit] +Description=Fluent-bit restart service + +[Service] +Type=oneshot +ExecStart=/bin/systemctl restart td-agent-bit.service + +[Install] +WantedBy=network.target
\ No newline at end of file diff --git a/recipes-extended/fluentbit/files/td-agent-bit.conf b/recipes-extended/fluentbit/files/td-agent-bit.conf new file mode 100644 index 0000000..f15ccd3 --- /dev/null +++ b/recipes-extended/fluentbit/files/td-agent-bit.conf @@ -0,0 +1,265 @@ +[SERVICE] + Flush 5 + Daemon off + Log_Level info + +[FILTER] + Name record_modifier + Match * + Record app_name fluentbit + Record level INFO + +@SET cpu_tag=cpu + +[INPUT] + Name cpu + Tag ${cpu_tag} +[FILTER] + Name record_modifier + Match ${cpu_tag} + Record type ${cpu_tag} +[FILTER] + Name nest + Match ${cpu_tag} + Operation nest + Wildcard user_p* + Wildcard system_p* + Wildcard cpu* + Nest_under message_json + +@SET mem_tag=memory + +[INPUT] + Name mem + Tag ${mem_tag} +[FILTER] + Name record_modifier + Match ${mem_tag} + Record type ${mem_tag} +[FILTER] + Name nest + Match ${mem_tag} + Operation nest + Wildcard Mem.* + Wildcard Swap.* + Nest_under message_json + +@SET edge_core_tag=edge-core + +[INPUT] + Name systemd + Tag ${edge_core_tag} + Systemd_Filter _SYSTEMD_UNIT=edge-core.service +[FILTER] + Name record_modifier + Match ${edge_core_tag} + Whitelist_key MESSAGE + Whitelist_key level + Record app_name edge-core + Record type systemd +[FILTER] + Name grep + Match ${edge_core_tag} + Exclude MESSAGE \[DBG +[FILTER] + Name modify + Match ${edge_core_tag} + Condition Key_value_matches MESSAGE \[DBG + Set level DEBUG +[FILTER] + Name modify + Match ${edge_core_tag} + Condition Key_value_matches MESSAGE \[INFO\] + Set level INFO +[FILTER] + Name modify + Match ${edge_core_tag} + Condition Key_value_matches MESSAGE \[WARN\] + Set level WARNING +[FILTER] + Name modify + Match ${edge_core_tag} + Condition Key_value_matches MESSAGE \[ERR + Set level ERROR +[FILTER] + Name modify + Match ${edge_core_tag} + Condition Key_value_does_not_match MESSAGE \[DBG|\[INFO\]|\[WARN\]|\[ERR + Set level TRACE +[FILTER] + Name nest + Match ${edge_core_tag} + Operation nest + Wildcard MESSAGE* + Nest_under message_json + +@SET edge_proxy_tag=edge-proxy + +[INPUT] + Name systemd + Tag ${edge_proxy_tag} + Systemd_Filter _SYSTEMD_UNIT=edge-proxy.service +[FILTER] + Name record_modifier + Match ${edge_proxy_tag} + Whitelist_key MESSAGE + Whitelist_key level + Record app_name edge-proxy + Record type systemd +[FILTER] + Name nest + Match ${edge_proxy_tag} + Operation nest + Wildcard MESSAGE* + Nest_under message_json + +@SET relay_term_tag=relay-term + +[INPUT] + Name systemd + Tag ${relay_term_tag} + Systemd_Filter _SYSTEMD_UNIT=pelion-relay-term.service +[FILTER] + Name record_modifier + Match ${relay_term_tag} + Whitelist_key MESSAGE + Whitelist_key level + Record app_name relay-term + Record type systemd +[FILTER] + Name nest + Match ${relay_term_tag} + Operation nest + Wildcard MESSAGE* + Nest_under message_json + +@SET maestro_tag=maestro + +[INPUT] + Name systemd + Tag ${maestro_tag} + Systemd_Filter _SYSTEMD_UNIT=maestro.service +[FILTER] + Name record_modifier + Match ${maestro_tag} + Whitelist_key MESSAGE + Whitelist_key level + Record app_name maestro + Record type systemd +[FILTER] + Name nest + Match ${maestro_tag} + Operation nest + Wildcard MESSAGE* + Nest_under message_json + +@SET kubelet_tag=kubelet + +[INPUT] + Name systemd + Tag ${kubelet_tag} + Systemd_Filter _SYSTEMD_UNIT=kubelet.service +[FILTER] + Name record_modifier + Match ${kubelet_tag} + Whitelist_key MESSAGE + Whitelist_key level + Record app_name kubelet + Record type systemd +[FILTER] + Name nest + Match ${kubelet_tag} + Operation nest + Wildcard MESSAGE* + Nest_under message_json + +@SET docker_tag=docker + +[INPUT] + Name systemd + Tag ${docker} + Systemd_Filter _SYSTEMD_UNIT=docker.service +[FILTER] + Name record_modifier + Match ${docker_tag} + Whitelist_key MESSAGE + Whitelist_key level + Record app_name docker + Record type systemd +[FILTER] + Name nest + Match ${docker_tag} + Operation nest + Wildcard MESSAGE* + Nest_under message_json + +@SET devicejs_tag=devicejs + +[INPUT] + Name tail + Tag ${devicejs_tag} + path /wigwag/log/devicejs.log +[FILTER] + Name record_modifier + Match ${devicejs_tag} + Whitelist_key log + Whitelist_key level + Record app_name devicejs + Record type tail + Record level info +[FILTER] + Name grep + Match ${devicejs_tag} + Exclude log \<WARN\> +[FILTER] + Name modify + Match ${devicejs_tag} + Condition Key_value_matches log \<WARN\> + Set level WARNING +[FILTER] + Name modify + Match ${devicejs_tag} + Condition Key_value_matches log \<ERROR\> + Set level ERROR +[FILTER] + Name modify + Match ${devicejs_tag} + Condition Key_value_does_not_match log \<WARN\>|\<ERROR\> + Set level TRACE +[FILTER] + Name nest + Match ${devicejs_tag} + Operation nest + Wildcard log* + Nest_under message_json + +@SET wait-for-pelion-identity_tag=wait-for-pelion-identity + +[INPUT] + Name systemd + Tag ${wait-for-pelion-identity_tag} + Systemd_Filter _SYSTEMD_UNIT=wait-for-pelion-identity.service +[FILTER] + Name record_modifier + Match ${wait-for-pelion-identity_tag} + Whitelist_key MESSAGE + Whitelist_key level + Record app_name wait-for-pelion-identity + Record type systemd +[FILTER] + Name nest + Match ${wait-for-pelion-identity_tag} + Operation nest + Wildcard MESSAGE* + Nest_under message_json + +[OUTPUT] + Name http + Match * + Host gateways.local + Port 8080 + URI /v3/device-logs + Format json + json_date_format iso8601 + json_date_key date_time + Retry_Limit 2
\ No newline at end of file diff --git a/recipes-extended/fluentbit/files/td-agent-bit.path b/recipes-extended/fluentbit/files/td-agent-bit.path new file mode 100644 index 0000000..47d16a4 --- /dev/null +++ b/recipes-extended/fluentbit/files/td-agent-bit.path @@ -0,0 +1,9 @@ +[Unit] +Description=Monitor the changes to identity.json file and restart relay-term + +[Path] +PathChanged=/etc/td-agent-bit/td-agent-bit.conf +Unit=td-agent-bit-watcher.service + +[Install] +WantedBy=network.target
\ No newline at end of file diff --git a/recipes-extended/fluentbit/files/td-agent-bit.service b/recipes-extended/fluentbit/files/td-agent-bit.service new file mode 100644 index 0000000..ef97e2f --- /dev/null +++ b/recipes-extended/fluentbit/files/td-agent-bit.service @@ -0,0 +1,10 @@ +[Unit] +Description=fast log collector + +[Service] +Restart=always +RestartSec=5s +ExecStart=/usr/bin/td-agent-bit -c /etc/td-agent-bit/td-agent-bit.conf + +[Install] +WantedBy=network.target diff --git a/recipes-extended/fluentbit/fluentbit_%.bbappend b/recipes-extended/fluentbit/fluentbit_%.bbappend new file mode 100644 index 0000000..347febe --- /dev/null +++ b/recipes-extended/fluentbit/fluentbit_%.bbappend @@ -0,0 +1,34 @@ +# Adding default Fluentbit configuration. +# Adding watcher service to restart Fluenbit when configuration is updated. + +FILESEXTRAPATHS_prepend := "${THISDIR}/files:" + +FB_PKG_NAME = "td-agent-bit" +FB_CONF_FILES_LOCATION = "/etc/${FB_PKG_NAME}" + +# To install fluentbit with systemd headers +DEPENDS_append = " systemd" + +# Enable SystemD input plugin +EXTRA_OECMAKE += "-DFLB_IN_SYSTEMD=On " + +FILES_${PN} += "\ + ${systemd_system_unitdir}/${FB_PKG_NAME}-watcher.service\ + ${systemd_system_unitdir}/${FB_PKG_NAME}.path\ + " +SRC_URI += "file://${FB_PKG_NAME}.conf \ +file://${FB_PKG_NAME}-watcher.service \ +file://${FB_PKG_NAME}.path" + +SYSTEMD_PACKAGES = "${PN}" +SYSTEMD_SERVICE_${PN} += "${FB_PKG_NAME}-watcher.service \ +${FB_PKG_NAME}.path" + +do_install_append() { + install -d ${D}${FB_CONF_FILES_LOCATION} + install -m 0644 ${WORKDIR}/${FB_PKG_NAME}.conf ${D}${FB_CONF_FILES_LOCATION}/${FB_PKG_NAME}.conf + + install -d ${D}${systemd_system_unitdir} + install -m 0644 ${WORKDIR}/${FB_PKG_NAME}-watcher.service ${D}${systemd_system_unitdir}/${FB_PKG_NAME}-watcher.service + install -m 0644 ${WORKDIR}/${FB_PKG_NAME}.path ${D}${systemd_system_unitdir}/${FB_PKG_NAME}.path +}
\ No newline at end of file |