Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[frontendproxy] - add envoy access logs #1768

Merged
merged 17 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ the release.

* [grafana] Update grafana to 11.3.0
([#1764](https://github.com/open-telemetry/opentelemetry-demo/pull/1764))
* [frontendproxy] add access logs
([#1768](https://github.com/open-telemetry/opentelemetry-demo/pull/1768))
* [chore] Move build args to .env file
([#1767](https://github.com/open-telemetry/opentelemetry-demo/pull/1767))
* [grafana] Fix Dashboards
Expand Down
1 change: 1 addition & 0 deletions docker-compose.minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/frontendproxy/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
94 changes: 93 additions & 1 deletion src/frontendproxy/envoy.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"
puckpuck marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
10 changes: 5 additions & 5 deletions src/grafana/provisioning/dashboards/demo/demo-dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -556,13 +556,13 @@
"type": "count"
}
],
"query": "search source=otel\n| where resource.service.name=\"${service}\"",
"query": "search source=otel\n| where resource.service.name=\"${service}\" | sort - @timestamp | head 100",
"queryType": "PPL",
"refId": "A",
"timeField": "time"
"timeField": "observedTimestamp"
}
],
"title": "${service} Logs",
"title": "${service} Logs (100 recent entries)",
"type": "table"
},
{
Expand Down Expand Up @@ -1039,6 +1039,6 @@
"timezone": "",
"title": "Demo Dashboard",
"uid": "W2gX2zHVk",
"version": 2,
"version": 1,
puckpuck marked this conversation as resolved.
Show resolved Hide resolved
"weekStart": ""
}
}
Loading