|
6 | 6 | [id="otel-forwarding-logs-to-tempostack_{context}"]
|
7 | 7 | = Forwarding logs to a LokiStack instance
|
8 | 8 |
|
9 |
| -You can deploy the OpenTelemetry Collector with Collector components to forward logs to a LokiStack instance. |
10 |
| - |
11 |
| -This use of the Loki Exporter is a temporary Technology Preview feature that is planned to be replaced with the publication of an improved solution in which the Loki Exporter is replaced with the OTLP HTTP Exporter. |
12 |
| - |
13 |
| -:FeatureName: The Loki Exporter |
14 |
| -include::snippets/technology-preview.adoc[leveloffset=+1] |
| 9 | +You can deploy the OpenTelemetry Collector to forward logs to a LokiStack instance. |
15 | 10 |
|
16 | 11 | .Prerequisites
|
17 | 12 |
|
@@ -99,80 +94,51 @@ spec:
|
99 | 94 | grpc: {}
|
100 | 95 | http: {}
|
101 | 96 | processors:
|
102 |
| - k8sattributes: |
103 |
| - auth_type: "serviceAccount" |
104 |
| - passthrough: false |
105 |
| - extract: |
106 |
| - metadata: |
107 |
| - - k8s.pod.name |
108 |
| - - k8s.container.name |
109 |
| - - k8s.namespace.name |
110 |
| - labels: |
111 |
| - - tag_name: app.label.component |
112 |
| - key: app.kubernetes.io/component |
113 |
| - from: pod |
114 |
| - pod_association: |
115 |
| - - sources: |
116 |
| - - from: resource_attribute |
117 |
| - name: k8s.pod.name |
118 |
| - - from: resource_attribute |
119 |
| - name: k8s.container.name |
120 |
| - - from: resource_attribute |
121 |
| - name: k8s.namespace.name |
122 |
| - - sources: |
123 |
| - - from: connection |
| 97 | + k8sattributes: {} |
124 | 98 | resource:
|
125 | 99 | attributes: # <1>
|
126 |
| - - key: loki.format # <2> |
127 |
| - action: insert |
128 |
| - value: json |
129 |
| - - key: kubernetes_namespace_name |
| 100 | + - key: kubernetes.namespace_name |
130 | 101 | from_attribute: k8s.namespace.name
|
131 | 102 | action: upsert
|
132 |
| - - key: kubernetes_pod_name |
| 103 | + - key: kubernetes.pod_name |
133 | 104 | from_attribute: k8s.pod.name
|
134 | 105 | action: upsert
|
135 |
| - - key: kubernetes_container_name |
| 106 | + - key: kubernetes.container_name |
136 | 107 | from_attribute: k8s.container.name
|
137 | 108 | action: upsert
|
138 | 109 | - key: log_type
|
139 | 110 | value: application
|
140 | 111 | action: upsert
|
141 |
| - - key: loki.resource.labels # <3> |
142 |
| - value: log_type, kubernetes_namespace_name, kubernetes_pod_name, kubernetes_container_name |
143 |
| - action: insert |
144 | 112 | transform:
|
145 | 113 | log_statements:
|
146 | 114 | - context: log
|
147 | 115 | statements:
|
148 | 116 | - set(attributes["level"], ConvertCase(severity_text, "lower"))
|
149 | 117 | exporters:
|
150 |
| - loki: |
151 |
| - endpoint: https://logging-loki-gateway-http.openshift-logging.svc.cluster.local:8080/api/logs/v1/application/loki/api/v1/push # <4> |
| 118 | + otlphttp: |
| 119 | + endpoint: https://logging-loki-gateway-http.openshift-logging.svc.cluster.local:8080/api/logs/v1/application/otlp |
| 120 | + encoding: json |
152 | 121 | tls:
|
153 | 122 | ca_file: "/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt"
|
154 | 123 | auth:
|
155 | 124 | authenticator: bearertokenauth
|
156 | 125 | debug:
|
157 | 126 | verbosity: detailed
|
158 | 127 | service:
|
159 |
| - extensions: [bearertokenauth] # <5> |
| 128 | + extensions: [bearertokenauth] # <2> |
160 | 129 | pipelines:
|
161 | 130 | logs:
|
162 | 131 | receivers: [otlp]
|
163 | 132 | processors: [k8sattributes, transform, resource]
|
164 |
| - exporters: [loki] # <6> |
| 133 | + exporters: [otlphttp] # <3> |
165 | 134 | logs/test:
|
166 | 135 | receivers: [otlp]
|
167 | 136 | processors: []
|
168 | 137 | exporters: [debug]
|
169 | 138 | ----
|
170 |
| -<1> Provides the following resource attributes to be used by the web console: `kubernetes_namespace_name`, `kubernetes_pod_name`, `kubernetes_container_name`, and `log_type`. If you specify them as values for this `loki.resource.labels` attribute, then the Loki Exporter processes them as labels. |
171 |
| -<2> Configures the format of Loki logs. Supported values are `json`, `logfmt` and `raw`. |
172 |
| -<3> Configures which resource attributes are processed as Loki labels. |
173 |
| -<4> Points the Loki Exporter to the gateway of the LokiStack `logging-loki` instance and uses the `application` tenant. |
174 |
| -<5> Enables the BearerTokenAuth Extension that is required by the Loki Exporter. |
175 |
| -<6> Enables the Loki Exporter to export logs from the Collector. |
| 139 | +<1> Provides the following resource attributes to be used by the web console: `kubernetes.namespace_name`, `kubernetes.pod_name`, `kubernetes.container_name`, and `log_type`. |
| 140 | +<2> Enables the BearerTokenAuth Extension that is required by the OTLP HTTP Exporter. |
| 141 | +<3> Enables the OTLP HTTP Exporter to export logs from the Collector. |
176 | 142 |
|
177 | 143 | [TIP]
|
178 | 144 | ====
|
|
0 commit comments