From 3c763db92b3b4a1590e5292dffd1e16cb239a782 Mon Sep 17 00:00:00 2001 From: Pierre Tessier Date: Wed, 20 Nov 2024 02:46:34 -0500 Subject: [PATCH] [frontendproxy] - add envoy access logs (#1768) * add envoy access logs * Update src/frontendproxy/envoy.tmpl.yaml * clean up envoy access logs * limit log panel to 100 * dashboard adjusts --------- Co-authored-by: Juliano Costa Co-authored-by: Cedric Ziel Co-authored-by: Juliano Costa Co-authored-by: Martin Thwaites --- CHANGELOG.md | 2 + docker-compose.minimal.yml | 1 + docker-compose.yml | 1 + src/frontendproxy/Dockerfile | 2 +- src/frontendproxy/envoy.tmpl.yaml | 94 ++++++++++++++++++- .../dashboards/demo/demo-dashboard.json | 48 ++++++++-- 6 files changed, 138 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 158b42d48d..6bb38ea44d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ the release. ([#1764](https://github.com/open-telemetry/opentelemetry-demo/pull/1764)) * [chore] Move build args to .env file ([#1767](https://github.com/open-telemetry/opentelemetry-demo/pull/1767)) +* [frontendproxy] add access logs + ([#1768](https://github.com/open-telemetry/opentelemetry-demo/pull/1768)) * [grafana] Fix Dashboards ([#1779](https://github.com/open-telemetry/opentelemetry-demo/pull/1779)) * [accountingservice] bump OpenTelemetry .NET Automatic Instrumentation diff --git a/docker-compose.minimal.yml b/docker-compose.minimal.yml index dcfba1123e..b71ee2a5d3 100644 --- a/docker-compose.minimal.yml +++ b/docker-compose.minimal.yml @@ -269,6 +269,7 @@ services: - OTEL_COLLECTOR_PORT_GRPC - OTEL_COLLECTOR_PORT_HTTP - OTEL_RESOURCE_ATTRIBUTES + - OTEL_SERVICE_NAME=frontend-proxy - ENVOY_PORT - FLAGD_HOST - FLAGD_PORT diff --git a/docker-compose.yml b/docker-compose.yml index 23e47d10a0..78642e2be7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -343,6 +343,7 @@ services: - OTEL_COLLECTOR_PORT_GRPC - OTEL_COLLECTOR_PORT_HTTP - OTEL_RESOURCE_ATTRIBUTES + - OTEL_SERVICE_NAME=frontend-proxy - ENVOY_PORT - FLAGD_HOST - FLAGD_PORT diff --git a/src/frontendproxy/Dockerfile b/src/frontendproxy/Dockerfile index 21d9cfed23..e9b4bfd5b6 100644 --- a/src/frontendproxy/Dockerfile +++ b/src/frontendproxy/Dockerfile @@ -1,7 +1,7 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 -FROM envoyproxy/envoy:v1.30-latest +FROM envoyproxy/envoy:v1.32-latest RUN apt-get update && apt-get install -y gettext-base && apt-get clean && rm -rf /var/lib/apt/lists/* USER envoy diff --git a/src/frontendproxy/envoy.tmpl.yaml b/src/frontendproxy/envoy.tmpl.yaml index 81c2f28a16..559ad53f3b 100644 --- a/src/frontendproxy/envoy.tmpl.yaml +++ b/src/frontendproxy/envoy.tmpl.yaml @@ -25,7 +25,7 @@ static_resources: envoy_grpc: cluster_name: opentelemetry_collector_grpc timeout: 0.250s - service_name: frontend-proxy + service_name: ${OTEL_SERVICE_NAME} resource_detectors: - name: envoy.tracers.opentelemetry.resource_detectors.environment typed_config: @@ -65,6 +65,98 @@ static_resources: - name: envoy.filters.http.router typed_config: "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router + access_log: + - name: envoy.access_loggers.open_telemetry + typed_config: + "@type": "type.googleapis.com/envoy.extensions.access_loggers.open_telemetry.v3.OpenTelemetryAccessLogConfig" + common_config: + log_name: "otel_envoy_access_log" + grpc_service: + envoy_grpc: + cluster_name: opentelemetry_collector_grpc + transport_api_version: "V3" + body: + # yamllint disable-line rule:line-length + string_value: "[%START_TIME%] \"%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%\" %RESPONSE_CODE% %RESPONSE_FLAGS% %RESPONSE_CODE_DETAILS% %CONNECTION_TERMINATION_DETAILS% \"%UPSTREAM_TRANSPORT_FAILURE_REASON%\" %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% \"%REQ(X-FORWARDED-FOR)%\" \"%REQ(USER-AGENT)%\" \"%REQ(X-REQUEST-ID)%\" \"%REQ(:AUTHORITY)%\" \"%UPSTREAM_HOST%\" %UPSTREAM_CLUSTER% %UPSTREAM_LOCAL_ADDRESS% %DOWNSTREAM_LOCAL_ADDRESS% %DOWNSTREAM_REMOTE_ADDRESS% %REQUESTED_SERVER_NAME% %ROUTE_NAME%\n" + resource_attributes: + values: + - key: "service.name" + value: + string_value: ${OTEL_SERVICE_NAME} + attributes: + values: + - key: "destination.address" + value: + string_value: "%UPSTREAM_REMOTE_ADDRESS_WITHOUT_PORT%" + - key: "event.name" + value: + string_value: "proxy.access" + - key: "http.connection.id" + value: + string_value: "%CONNECTION_ID%" + - key: "http.protocol" + value: + string_value: "%PROTOCOL%" + - key: "http.request.body.size" + value: + string_value: "%BYTES_RECEIVED%" + - key: "http.request.header.x-forwarded-for" + value: + string_value: "%REQ(X-FORWARDED-FOR)%" + - key: "http.request.header.x-request-id" + value: + string_value: "%REQ(X-REQUEST-ID)%" + - key: "http.request.headers.size" + value: + string_value: "%REQUEST_HEADERS_BYTES%" + - key: "http.request.id" + value: + string_value: "%STREAM_ID%" + - key: "http.request.method" + value: + string_value: "%REQ(:METHOD)%" + - key: "http.request.start_time" + value: + string_value: "%START_TIME%" + - key: "http.response.body.size" + value: + string_value: "%BYTES_SENT%" + - key: "http.response.headers.size" + value: + string_value: "%RESPONSE_HEADERS_BYTES%" + - key: "http.response.status_code" + value: + string_value: "%RESPONSE_CODE%" + - key: "http.total_duration_ms" + value: + string_value: "%DURATION%" + - key: "server.address" + value: + string_value: "%DOWNSTREAM_LOCAL_ADDRESS%" + - key: "source.address" + value: + string_value: "%DOWNSTREAM_REMOTE_ADDRESS_WITHOUT_PORT%" + - key: "upstream.cluster" + value: + string_value: "%UPSTREAM_CLUSTER%" + - key: "upstream.host" + value: + string_value: "%UPSTREAM_HOST%" + - key: "user_agent.original" + value: + string_value: "%REQ(USER-AGENT)%" + - key: "url.full" + value: + string_value: "%REQ(:SCHEME)%://%REQ(:AUTHORITY)%%REQ(:PATH)%" + - key: "url.path" + value: + string_value: "%REQ(:PATH)%" + - key: "url.query" + value: + string_value: "%REQ(:QUERY)%" + - key: "url.template" + value: + string_value: "%ROUTE_NAME%" clusters: - name: opentelemetry_collector_grpc diff --git a/src/grafana/provisioning/dashboards/demo/demo-dashboard.json b/src/grafana/provisioning/dashboards/demo/demo-dashboard.json index 87cf5ec142..bd0b37fba2 100644 --- a/src/grafana/provisioning/dashboards/demo/demo-dashboard.json +++ b/src/grafana/provisioning/dashboards/demo/demo-dashboard.json @@ -401,7 +401,7 @@ "mode": "thresholds" }, "custom": { - "align": "auto", + "align": "left", "cellOptions": { "type": "auto" }, @@ -422,7 +422,20 @@ ] } }, - "overrides": [] + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "count()" + }, + "properties": [ + { + "id": "custom.width", + "value": 90 + } + ] + } + ] }, "gridPos": { "h": 8, @@ -509,7 +522,20 @@ ] } }, - "overrides": [] + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "observedTimestamp" + }, + "properties": [ + { + "id": "custom.width", + "value": 222 + } + ] + } + ] }, "gridPos": { "h": 8, @@ -528,7 +554,13 @@ ], "show": false }, - "showHeader": true + "showHeader": true, + "sortBy": [ + { + "desc": true, + "displayName": "observedTimestamp" + } + ] }, "pluginVersion": "11.3.0", "targets": [ @@ -556,13 +588,13 @@ "type": "count" } ], - "query": "search source=otel\n| where resource.service.name=\"${service}\"", + "query": "search source=otel\n| where resource.service.name=\"${service}\"| sort - observedTimestamp | head 100", "queryType": "PPL", "refId": "A", - "timeField": "time" + "timeField": "observedTimestamp" } ], - "title": "${service} Logs", + "title": "${service} Logs (100 recent entries)", "type": "table" }, { @@ -1039,6 +1071,6 @@ "timezone": "", "title": "Demo Dashboard", "uid": "W2gX2zHVk", - "version": 2, + "version": 1, "weekStart": "" }