diff --git a/addon-promtail-main/build.yaml b/addon-promtail-main/build.yaml deleted file mode 100644 index be4d420..0000000 --- a/addon-promtail-main/build.yaml +++ /dev/null @@ -1,9 +0,0 @@ ---- -build_from: - amd64: ghcr.io/hassio-addons/debian-base/amd64:7.5.1 - armhf: ghcr.io/hassio-addons/debian-base/armhf:7.5.1 - armv7: ghcr.io/hassio-addons/debian-base/armv7:7.5.1 - aarch64: ghcr.io/hassio-addons/debian-base/aarch64:7.5.1 -codenotary: - base_image: codenotary@frenck.dev - signer: codenotary@degatano.com diff --git a/addon-promtail-main/rootfs/etc/promtail/default-scrape-config.yaml b/addon-promtail-main/rootfs/etc/promtail/default-scrape-config.yaml deleted file mode 100644 index 6e3f112..0000000 --- a/addon-promtail-main/rootfs/etc/promtail/default-scrape-config.yaml +++ /dev/null @@ -1,27 +0,0 @@ ---- -- job_name: journal - journal: - json: false - max_age: 12h - labels: - job: systemd-journal - path: "${JOURNAL_PATH}" - relabel_configs: - - source_labels: - - __journal__systemd_unit - target_label: unit - - source_labels: - - __journal__hostname - target_label: nodename - - source_labels: - - __journal_syslog_identifier - target_label: syslog_identifier - - source_labels: - - __journal_container_name - target_label: container_name - pipeline_stages: - - match: - selector: '{container_name=~"homeassistant|hassio_supervisor"}' - stages: - - multiline: - firstline: '^\x{001b}' diff --git a/loki/rootfs/etc/loki/default-config.yaml b/loki/rootfs/etc/loki/default-config.yaml index 18819f3..06b02ae 100644 --- a/loki/rootfs/etc/loki/default-config.yaml +++ b/loki/rootfs/etc/loki/default-config.yaml @@ -1,45 +1,33 @@ ---- + +# This is a complete configuration to deploy Loki backed by the filesystem. +# The index will be shipped to the storage via tsdb-shipper. + auth_enabled: false -server: {} +server: + http_listen_port: 3100 -ingester: - lifecycler: - address: 127.0.0.1 - ring: - kvstore: - store: inmemory - replication_factor: 1 - final_sleep: 0s - chunk_idle_period: 1h - max_chunk_age: 1h - chunk_target_size: 1048576 - chunk_retain_period: 30s - wal: - dir: /data/loki/wal +common: + ring: + instance_addr: 127.0.0.1 + kvstore: + store: inmemory + replication_factor: 1 + path_prefix: /tmp/loki schema_config: configs: - - from: 2020-11-09 - store: tsdb # Changed to tsdb - object_store: filesystem - schema: v13 # Changed to v13 - index: - prefix: index_ - period: 24h + - from: 2020-05-15 + store: tsdb + object_store: filesystem + schema: v13 + index: + prefix: index_ + period: 24h storage_config: - tsdb_shipper: - active_index_directory: /data/loki/tsdb-active # Set this path - cache_location: /data/loki/tsdb-cache # Set this path filesystem: - directory: /data/loki/chunks - -compactor: - working_directory: /data/loki/tsdb-shipper-compactor - retention_enabled: true - delete_request_store: filesystem # Added this line - + directory: /tmp/loki/chunks limits_config: reject_old_samples: true reject_old_samples_max_age: 168h diff --git a/addon-promtail-main/.README.j2 b/promtail/.README.j2 similarity index 100% rename from addon-promtail-main/.README.j2 rename to promtail/.README.j2 diff --git a/addon-promtail-main/DOCS.md b/promtail/DOCS.md similarity index 100% rename from addon-promtail-main/DOCS.md rename to promtail/DOCS.md diff --git a/addon-promtail-main/Dockerfile b/promtail/Dockerfile similarity index 74% rename from addon-promtail-main/Dockerfile rename to promtail/Dockerfile index 7c6712d..2036b5a 100644 --- a/addon-promtail-main/Dockerfile +++ b/promtail/Dockerfile @@ -1,6 +1,3 @@ -# https://github.com/mdegat01/promtail-journal/releases -#FROM ghcr.io/mdegat01/promtail-journal/${BUILD_ARCH}:1.6.0 as build_promtail - # https://github.com/hassio-addons/addon-debian-base/releases # hadolint ignore=DL3006 ARG BUILD_FROM @@ -8,19 +5,22 @@ FROM ${BUILD_FROM} # https://github.com/mikefarah/yq/releases ARG YQ_VERSION=4.44.3 +ARG PROMTAIL_VERSION=3.2.1 ARG BUILD_ARCH + +COPY rootfs / + # Add yq and tzdata (required for the timestamp stage) -RUN echo "deb http://deb.debian.org/debian bullseye-backports main" >> /etc/apt/sources.list -RUN apt-get update && apt-get install -t bullseye-backports -qy libsystemd-dev RUN set -eux; \ - apt-get update; \ - apt-get install -qy --no-install-recommends \ - tar=1.34+dfsg-1 \ - ; \ - update-ca-certificates; \ + apk update; \ \ - case "${BUILD_ARCH}" in \ + apk add --no-cache --virtual .build-deps \ + tar; +RUN apk add --no-cache \ + ca-certificates; +RUN update-ca-certificates; +RUN case "${BUILD_ARCH}" in \ amd64) BINARCH='amd64' ;; \ armhf) BINARCH='arm' ;; \ armv7) BINARCH='arm' ;; \ @@ -35,16 +35,27 @@ RUN set -eux; \ rm /tmp/yq.tar.gz; \ yq --version; \ \ - apt-get clean; \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*; \ chmod +x /etc/cont-init.d/promtail_setup.sh; \ chmod +x /etc/services.d/promtail/*; -# Add promtail -COPY --from=grafana/promtail:latest /usr/bin/promtail /usr/bin/promtail -RUN promtail --version +# Install dependencies for building Promtail +RUN apk add --no-cache go git build-base -COPY rootfs / +# Download the Promtail source code +RUN git clone --branch "v${PROMTAIL_VERSION}" https://github.com/grafana/loki.git /promtail-src + +# Build Promtail +WORKDIR /promtail-src/clients/cmd/promtail +RUN go build -o /usr/bin/promtail + +# Clean up source and unnecessary packages +RUN apk del go git build-base && \ + rm -rf /promtail-src + +# Verify the installation +RUN /usr/bin/promtail -version + WORKDIR /data/promtail # Build arguments diff --git a/addon-promtail-main/apparmor.txt b/promtail/apparmor.txt similarity index 100% rename from addon-promtail-main/apparmor.txt rename to promtail/apparmor.txt diff --git a/promtail/build.yaml b/promtail/build.yaml new file mode 100644 index 0000000..1a9f6a3 --- /dev/null +++ b/promtail/build.yaml @@ -0,0 +1,9 @@ +--- +build_from: + amd64: ghcr.io/hassio-addons/base/amd64:16.3.4 + armhf: ghcr.io/hassio-addons/base/armhf:16.3.4 + armv7: ghcr.io/hassio-addons/base/armv7:16.3.4 + aarch64: ghcr.io/hassio-addons/base/aarch64:16.3.4 +codenotary: + base_image: codenotary@frenck.dev + signer: codenotary@degatano.com diff --git a/addon-promtail-main/config.yaml b/promtail/config.yaml similarity index 85% rename from addon-promtail-main/config.yaml rename to promtail/config.yaml index 30fba64..899bdef 100644 --- a/addon-promtail-main/config.yaml +++ b/promtail/config.yaml @@ -11,10 +11,15 @@ arch: description: Promtail for Home Assistant codenotary: codenotary@degatano.com init: false -journald: true +hassio_api: true +homeassistant_api: true +auth_api: true +docker_api: true +host_network: true +host_pid: true map: - - config - - share + - config:rw + - share:rw - ssl watchdog: http://[HOST]:[PORT:9080]/ready ports: diff --git a/addon-promtail-main/icon.png b/promtail/icon.png similarity index 100% rename from addon-promtail-main/icon.png rename to promtail/icon.png diff --git a/addon-promtail-main/logo.png b/promtail/logo.png similarity index 100% rename from addon-promtail-main/logo.png rename to promtail/logo.png diff --git a/addon-promtail-main/rootfs/etc/cont-init.d/promtail_setup.sh b/promtail/rootfs/etc/cont-init.d/promtail_setup.sh similarity index 100% rename from addon-promtail-main/rootfs/etc/cont-init.d/promtail_setup.sh rename to promtail/rootfs/etc/cont-init.d/promtail_setup.sh diff --git a/addon-promtail-main/rootfs/etc/promtail/base_config.yaml b/promtail/rootfs/etc/promtail/base_config.yaml similarity index 100% rename from addon-promtail-main/rootfs/etc/promtail/base_config.yaml rename to promtail/rootfs/etc/promtail/base_config.yaml diff --git a/promtail/rootfs/etc/promtail/default-scrape-config.yaml b/promtail/rootfs/etc/promtail/default-scrape-config.yaml new file mode 100644 index 0000000..8520214 --- /dev/null +++ b/promtail/rootfs/etc/promtail/default-scrape-config.yaml @@ -0,0 +1,9 @@ +--- +- job_name: home_assistant_logs + static_configs: + - targets: + - localhost # Target for the logs, can be anything since it's just a label + labels: + job: home_assistant # Job label for your logs in Loki + host: home_assistant # Optional label for host, useful if running multiple Home Assistant instances + __path__: /config/home-assistant.log # Path to Home Assistant log file \ No newline at end of file diff --git a/addon-promtail-main/rootfs/etc/services.d/promtail/finish b/promtail/rootfs/etc/services.d/promtail/finish similarity index 100% rename from addon-promtail-main/rootfs/etc/services.d/promtail/finish rename to promtail/rootfs/etc/services.d/promtail/finish diff --git a/addon-promtail-main/rootfs/etc/services.d/promtail/run b/promtail/rootfs/etc/services.d/promtail/run similarity index 100% rename from addon-promtail-main/rootfs/etc/services.d/promtail/run rename to promtail/rootfs/etc/services.d/promtail/run