diff --git a/Dockerfile b/Dockerfile index 7633f2f..4e91205 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,27 @@ -FROM golang:1.18.1-alpine3.15 as builder +FROM golang:1.18.1-bullseye as builder ARG ELASTICSTACK_VERSION=8.1.2 WORKDIR /build +RUN apt update && apt upgrade -y +RUN git clone --single-branch --branch="v${ELASTICSTACK_VERSION}" --depth=1 https://github.com/elastic/beats.git + ENV GOMAXPROCS="4" -RUN apk update -RUN apk add git bash make gcc musl-dev binutils-gold -RUN git clone --single-branch --branch="v${ELASTICSTACK_VERSION}" --depth=1 https://github.com/elastic/beats.git RUN cd beats/filebeat/ && \ make - -FROM alpine:3.15 +FROM debian:bullseye-slim COPY --chown=root:filebeat filebeat.yml /usr/share/filebeat/filebeat.yml COPY --chmod=750 --from=builder /build/beats/filebeat/filebeat /usr/local/bin/filebeat COPY --chmod=750 entrypoint.sh /entrypoint.sh +ENV ELASTICSEARCH_HOSTS="" +ENV ELASTICSEARCH_USERNAME="" +ENV ELASTICSEARCH_PASSWORD_FILE="" +ENV KIBANA_HOSTS="" + ENTRYPOINT ["/entrypoint.sh"] CMD ["filebeat", "-e", "--strict.perms=false", "-c", "/usr/share/filebeat/filebeat.yml"] \ No newline at end of file diff --git a/filebeat.yml b/filebeat.yml index 299d97e..549927e 100644 --- a/filebeat.yml +++ b/filebeat.yml @@ -10,6 +10,28 @@ filebeat.autodiscover: processors: - add_cloud_metadata: ~ + - add_locale: + format: offset + - add_docker_metadata: + host: "unix:///var/run/docker.sock" + - add_host_metadata: ~ + - decode_json_fields: + fields: ["message"] + target: "json" + overwrite_keys: true + +setup: + kibana: + host: '${KIBANA_HOSTS:kibana:5601}' + ssl: + verification_mode: none + template: + enabled: true + name: "filebeat-%{[agent.version]}" + pattern: "index-%{[beat.version]}-*" + dashboards: + enabled: false + #index: "filebeat-%{[agent.version]}-*" output.elasticsearch: hosts: '[${ELASTICSEARCH_HOSTS:elasticsearch:9200}]' @@ -17,25 +39,9 @@ output.elasticsearch: password: '${ELASTICSEARCH_PASSWORD:}' ssl: verification_mode: none + indices: + - index: "filebeat-%{[agent.version]}-%{[container.name]:common}-%{+yyyy.MM.dd}" + -#filebeat.inputs: -# - type: container -# paths: -# - '/var/lib/docker/containers/*/*.log' -# -#processors: -# - add_docker_metadata: -# host: "unix:///var/run/docker.sock" -# -# - decode_json_fields: -# fields: ["message"] -# target: "json" -# overwrite_keys: true -# -#output.elasticsearch: -# hosts: ["elasticsearch:9200"] -# indices: -# - index: "filebeat-%{[agent.version]}-%{+yyyy.MM.dd}" -# #logging.json: true #logging.metrics.enabled: false \ No newline at end of file