diff --git a/docker-compose.build.yml b/docker-compose.build.yml index 534814c0..7b1a2e75 100644 --- a/docker-compose.build.yml +++ b/docker-compose.build.yml @@ -1,32 +1,37 @@ version: '3' services: swoole: build: context: ./docker/swoole/ image: apheleia/swoole almalinux8: build: context: ./docker/base/ dockerfile: almalinux8 image: apheleia/almalinux8 almalinux9: build: context: ./docker/base/ dockerfile: almalinux9 image: apheleia/almalinux9 tests: build: context: ./docker/tests/ container_name: kolab-tests image: kolab-tests + fluentbit: + build: + context: ./docker/fluentbit/ + container_name: fluentbit + image: fluentbit utils: build: context: ./docker/utils/ container_name: kolab-utils image: kolab-utils dns: 172.18.0.11 extra_hosts: - "${APP_DOMAIN}:172.18.0.7" networks: kolab: ipv4_address: 172.18.0.27 diff --git a/docker/fluentbit/Dockerfile b/docker/fluentbit/Dockerfile new file mode 100644 index 00000000..4a728ebd --- /dev/null +++ b/docker/fluentbit/Dockerfile @@ -0,0 +1,42 @@ +FROM apheleia/almalinux9 + +RUN dnf -y install ca-certificates gcc gcc-c++ cmake make bash \ + wget unzip systemd-devel wget flex bison \ + postgresql-libs postgresql-devel postgresql-server postgresql \ + cyrus-sasl-lib cyrus-sasl-devel openssl openssl-libs openssl-devel \ + libyaml-devel zlib-devel && \ + dnf clean all + +WORKDIR /tmp/fluent-bit/ +ENV VERSION=2.2.2 +RUN wget https://github.com/fluent/fluent-bit/archive/refs/tags/v${VERSION}.tar.gz && tar xzf v${VERSION}.tar.gz && rm *.tar.gz +RUN cd /tmp/fluent-bit/fluent-bit-${VERSION}/ && \ + cmake3 -DCMAKE_INSTALL_PREFIX="/opt/fluent-bit/" \ + -DCMAKE_INSTALL_SYSCONFDIR="/etc" \ + -DFLB_RELEASE="On" \ + -DFLB_TRACE="On" \ + -DFLB_SQLDB="On" \ + -DFLB_HTTP_SERVER="On" \ + -DFLB_OUT_KAFKA="On" \ + -DFLB_OUT_PGSQL="On" \ + -DFLB_JEMALLOC_OPTIONS="--with-lg-page=16 --with-lg-quantum=3" \ + -DFLB_JEMALLOC="On" \ + -DFLB_CHUNK_TRACE="On" \ + ./ && \ + make -j 4 && \ + make install && \ + cd / && \ + rm -rf /tmp/fluent-bit && \ + chgrp -R 0 /opt/fluent-bit && \ + chmod -R g=u /opt/fluent-bit + +COPY fluent-bit.yaml /etc/fluent-bit/fluent-bit.yaml +COPY parsers.conf /etc/fluent-bit/parsers.conf + +RUN chgrp -R 0 /etc/fluent-bit && \ + chmod -R g=u /etc/fluent-bit +USER 1001 +WORKDIR / +VOLUME /data + +CMD [ "/opt/fluent-bit/bin/fluent-bit", "--config=/etc/fluent-bit/fluent-bit.yaml"] diff --git a/docker/fluentbit/fluent-bit.yaml b/docker/fluentbit/fluent-bit.yaml new file mode 100644 index 00000000..8906c467 --- /dev/null +++ b/docker/fluentbit/fluent-bit.yaml @@ -0,0 +1,42 @@ +service: + http_server: "on" + Health_Check: "on" + log_level: info + parsers_file: /etc/fluent-bit/parsers.conf + +pipeline: + inputs: + - name: tail + path: /var/log/containers/*.log + path_key: tailed_path + exclude_path: "/var/log/containers/fluent*,/var/log/containers/loki*" + skip_empty_lines: "On" + tag_regex: (?[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)_(?[^_]+)_(?.+)\.log$ + tag: "kube..." + multiline.parser: docker, cri + + filters: + - name: parser + match: "kube.*" + key_name: "tailed_path" + reserve_data: true + parser: kube-path + - name: parser + match: "kube.kolab.roundcube*" + key_name: "log" + reserve_data: true + parser: apache + parser: logfmt + - name: parser + match: "kube.kolab.proxy*" + key_name: "log" + reserve_data: true + parser: nginx + + outputs: + - name: stdout + match: '*' + - name: loki + host: 'loki.kolab' + port: 3100 + labels: $pod_name, $namespace_name diff --git a/docker/fluentbit/parsers.conf b/docker/fluentbit/parsers.conf new file mode 100644 index 00000000..68c255b1 --- /dev/null +++ b/docker/fluentbit/parsers.conf @@ -0,0 +1,140 @@ +[PARSER] + Name apache + Format regex + Regex ^(?[^ ]*) [^ ]* (?[^ ]*) \[(?