summaryrefslogtreecommitdiff
path: root/f3s/loki/alloy-values.yaml
blob: f53fd12d43f9724679430d60f4c859e0e58591c1 (plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
alloy:
  service:
    ports:
      otlp-grpc:
        enabled: true
        port: 4317
        targetPort: 4317
        protocol: TCP
      otlp-http:
        enabled: true
        port: 4318
        targetPort: 4318
        protocol: TCP

  configMap:
    content: |
      discovery.kubernetes "pods" {
        role = "pod"
      }

      discovery.relabel "pods" {
        targets = discovery.kubernetes.pods.targets

        rule {
          source_labels = ["__meta_kubernetes_namespace"]
          target_label  = "namespace"
        }

        rule {
          source_labels = ["__meta_kubernetes_pod_name"]
          target_label  = "pod"
        }

        rule {
          source_labels = ["__meta_kubernetes_pod_container_name"]
          target_label  = "container"
        }

        rule {
          source_labels = ["__meta_kubernetes_pod_label_app"]
          target_label  = "app"
        }
      }

      loki.source.kubernetes "pods" {
        targets    = discovery.relabel.pods.output
        forward_to = [loki.write.default.receiver]
      }

      loki.write "default" {
        endpoint {
          url = "http://loki.monitoring.svc.cluster.local:3100/loki/api/v1/push"
        }
      }

      // ========================================
      // TRACES COLLECTION
      // ========================================

      // OTLP receiver for traces via gRPC and HTTP
      // Accepts traces from applications instrumented with OpenTelemetry
      otelcol.receiver.otlp "default" {
        // Accept OTLP over gRPC on port 4317 (standard OTLP port)
        grpc {
          endpoint = "0.0.0.0:4317"
        }

        // Accept OTLP over HTTP on port 4318 (standard OTLP HTTP port)
        http {
          endpoint = "0.0.0.0:4318"
        }

        output {
          traces = [otelcol.processor.batch.default.input]
        }
      }

      // Batch processor for efficient trace forwarding to Tempo
      // Reduces network calls by batching spans before sending
      otelcol.processor.batch "default" {
        // Send batch every 5 seconds
        timeout = "5s"

        // Or when 100 spans have accumulated
        send_batch_size = 100

        // Maximum batch size as safety limit
        send_batch_max_size = 200

        output {
          traces = [otelcol.exporter.otlp.tempo.input]
        }
      }

      // OTLP exporter to send traces to Tempo
      otelcol.exporter.otlp "tempo" {
        client {
          endpoint = "tempo.monitoring.svc.cluster.local:4317"

          // Tempo doesn't use TLS for internal cluster communication
          tls {
            insecure = true
          }

          // Enable compression for efficiency
          compression = "gzip"
        }
      }