eletrotupi / tcc/ ansible/roles/app/files/vector.yaml9e81281bc996022abab0d2183e9466b5b3553b51
1.1 KB | 37 lines Raw
1
# Collects Docker container logs and forwards them to VictoriaLogs
2
# Bind-mounted by docker-compose.yml (dev) and installed into /srv/app/<env>/
3
# by the Ansible `app` role (production)
4
sources:
5
  docker:
6
    type: docker_logs
7

8
transforms:
9
  parse_json_message:
10
    type: remap
11
    inputs: [docker]
12
    # pino writes one JSON object per line — when a line parses we lift its
13
    # fields to the top level so level/msg/userId become queryable in
14
    # VictoriaLogs, otherwise the raw line stays as the message
15
    source: |
16
      parsed, err = parse_json(.message)
17
      if err == null && is_object(parsed) {
18
        . = merge(., parsed) ?? .
19
      }
20

21
sinks:
22
  victorialogs:
23
    type: elasticsearch
24
    inputs: [parse_json_message]
25
    endpoints: ["http://victorialogs:9428/logs/insert/elasticsearch/"]
26
    mode: bulk
27
    api_version: v8
28
    compression: gzip
29
    healthcheck:
30
      enabled: false
31
    request:
32
      headers:
33
        VL-Stream-Fields: label.com.docker.compose.service
34
        VL-Time-Field: timestamp
35
        VL-Msg-Field: msg,message,_msg
36
        AccountID: "0"
37
        ProjectID: "0"