From 00912bfa0f53be98916a1739983a355d689ce845 Mon Sep 17 00:00:00 2001 From: Andrii Chubatiuk Date: Fri, 27 Sep 2024 16:09:36 +0300 Subject: [PATCH] docs/victorialogs: change fluentd input type in examples (#7123) ### Describe Your Changes Use fluentd logging driver in examples to have enriched data in VictoriaLogs ### Checklist The following checks are **mandatory**: - [ ] My change adheres [VictoriaMetrics contributing guidelines](https://docs.victoriametrics.com/contributing/). --- .../docker/victorialogs/fluentd/Dockerfile | 4 +++- .../docker/victorialogs/fluentd/compose.yml | 19 +++++++++++++++++++ .../fluentd/elasticsearch/fluent.conf | 8 ++++---- .../victorialogs/fluentd/jsonline/fluent.conf | 9 ++++----- .../victorialogs/fluentd/loki/fluent.conf | 19 ++++++++++++++----- 5 files changed, 44 insertions(+), 15 deletions(-) diff --git a/deployment/docker/victorialogs/fluentd/Dockerfile b/deployment/docker/victorialogs/fluentd/Dockerfile index dad82dfbc..340c15249 100644 --- a/deployment/docker/victorialogs/fluentd/Dockerfile +++ b/deployment/docker/victorialogs/fluentd/Dockerfile @@ -1,6 +1,8 @@ -FROM fluent/fluentd:v1.17 +FROM fluent/fluentd:v1.17-debian-1 USER root RUN \ + apt update && \ + apt install -y netcat-traditional && \ gem install \ fluent-plugin-datadog \ fluent-plugin-grafana-loki \ diff --git a/deployment/docker/victorialogs/fluentd/compose.yml b/deployment/docker/victorialogs/fluentd/compose.yml index 6a3e33d35..e189f506e 100644 --- a/deployment/docker/victorialogs/fluentd/compose.yml +++ b/deployment/docker/victorialogs/fluentd/compose.yml @@ -9,3 +9,22 @@ services: depends_on: [victorialogs] ports: - "5140:5140" + - "24224:24224" + healthcheck: + test: ["CMD", "nc", "-z", "-n", "-v", "127.0.0.1", "24224"] + start_period: 3s + nginx: + image: nginx:1.27 + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost"] + start_period: 3s + ports: + - "8080:80" + logging: + driver: fluentd + options: + fluentd-address: 127.0.0.1:24224 + labels: com.docker.compose.service + depends_on: + fluentd: + condition: service_healthy diff --git a/deployment/docker/victorialogs/fluentd/elasticsearch/fluent.conf b/deployment/docker/victorialogs/fluentd/elasticsearch/fluent.conf index 145c4d32d..33555c47b 100644 --- a/deployment/docker/victorialogs/fluentd/elasticsearch/fluent.conf +++ b/deployment/docker/victorialogs/fluentd/elasticsearch/fluent.conf @@ -1,13 +1,13 @@ - @type tail - format none - tag docker.testlog - path /var/lib/docker/containers/**/*.log + @type forward + port 24224 + bind 0.0.0.0 @type elasticsearch host victorialogs path /insert/elasticsearch + custom_headers {"VL-Msg-Field": "log", "VL-Stream-Fields": "com.docker.compose.service"} port 9428 diff --git a/deployment/docker/victorialogs/fluentd/jsonline/fluent.conf b/deployment/docker/victorialogs/fluentd/jsonline/fluent.conf index cac841e00..c6f5fcfc0 100644 --- a/deployment/docker/victorialogs/fluentd/jsonline/fluent.conf +++ b/deployment/docker/victorialogs/fluentd/jsonline/fluent.conf @@ -1,12 +1,11 @@ - @type tail - format none - tag docker.testlog - path /var/lib/docker/containers/**/*.log + @type forward + port 24224 + bind 0.0.0.0 @type http endpoint "http://victorialogs:9428/insert/jsonline" - headers {"VL-Msg-Field": "log", "VL-Time-Field": "time", "VL-Stream-Fields": "path"} + headers {"VL-Msg-Field": "log", "VL-Stream-Fields": "com.docker.compose.service"} diff --git a/deployment/docker/victorialogs/fluentd/loki/fluent.conf b/deployment/docker/victorialogs/fluentd/loki/fluent.conf index 460437673..381b962f5 100644 --- a/deployment/docker/victorialogs/fluentd/loki/fluent.conf +++ b/deployment/docker/victorialogs/fluentd/loki/fluent.conf @@ -1,10 +1,17 @@ - @type tail - format none - tag docker.testlog - path /var/lib/docker/containers/**/*.log + @type forward + port 24224 + bind 0.0.0.0 + + @type record_transformer + enable_ruby true + + service ${record['com.docker.compose.service']} + + + @type loki url "http://victorialogs:9428/insert" @@ -12,6 +19,8 @@ flush_interval 10s flush_at_shutdown true - custom_headers {"VL-Msg-Field": "log", "VL-Time-Field": "time", "VL-Stream-Fields": "path"} + buffer_chunk_limit 1m