File size: 1,670 Bytes
851e5ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Ships SupoClip container logs (and the host nginx's SupoClip access/error
# logs) to Axiom. Started by docker-compose's "axiom" profile; see
# docs/observability.md.

sources:
  containers:
    type: docker_logs
    # Prefix match: only this stack's containers, not other projects on the host.
    include_containers: ["supoclip-"]
    exclude_containers: ["supoclip-vector"]

  nginx:
    type: file
    include:
      - /var/log/nginx/supoclip.access.log
      - /var/log/nginx/supoclip.error.log

transforms:
  containers_parsed:
    type: remap
    inputs: [containers]
    source: |
      .service = replace(string!(.container_name), "supoclip-", "")
      del(.label)
      del(.container_id)
      del(.container_created_at)
      del(.source_type)

      # The backend and worker log one JSON object per line (observability.py).
      parsed, err = parse_json(.message)
      if err == null && is_object(parsed) {
        . = merge!(., parsed)
        .timestamp = parse_timestamp(.timestamp, "%+") ?? now()
      }

  containers_filtered:
    type: filter
    inputs: [containers_parsed]
    # Health checks hit every 30s and say nothing.
    condition: |
      !match(string(.message) ?? "", r'(?:Incoming|Completed) request GET /health\b')

  nginx_parsed:
    type: remap
    inputs: [nginx]
    source: |
      .service = "nginx"
      del(.source_type)
      parsed, err = parse_json(.message)
      if err == null && is_object(parsed) {
        . = merge!(., parsed)
        del(.message)
      }

sinks:
  axiom:
    type: axiom
    inputs: [containers_filtered, nginx_parsed]
    dataset: "${AXIOM_DATASET:-supoclip-prod}"
    token: "${AXIOM_TOKEN}"