Skip to content

Commit

Permalink
[frontendproxy] - add envoy access logs (#1768)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Cedric Ziel <[email protected]>
Co-authored-by: Juliano Costa <[email protected]>
Co-authored-by: Martin Thwaites <[email protected]>
  • Loading branch information
5 people authored Nov 20, 2024
1 parent 069b80b commit 3c763db
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
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"
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
48 changes: 40 additions & 8 deletions src/grafana/provisioning/dashboards/demo/demo-dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@
"mode": "thresholds"
},
"custom": {
"align": "auto",
"align": "left",
"cellOptions": {
"type": "auto"
},
Expand All @@ -422,7 +422,20 @@
]
}
},
"overrides": []
"overrides": [
{
"matcher": {
"id": "byName",
"options": "count()"
},
"properties": [
{
"id": "custom.width",
"value": 90
}
]
}
]
},
"gridPos": {
"h": 8,
Expand Down Expand Up @@ -509,7 +522,20 @@
]
}
},
"overrides": []
"overrides": [
{
"matcher": {
"id": "byName",
"options": "observedTimestamp"
},
"properties": [
{
"id": "custom.width",
"value": 222
}
]
}
]
},
"gridPos": {
"h": 8,
Expand All @@ -528,7 +554,13 @@
],
"show": false
},
"showHeader": true
"showHeader": true,
"sortBy": [
{
"desc": true,
"displayName": "observedTimestamp"
}
]
},
"pluginVersion": "11.3.0",
"targets": [
Expand Down Expand Up @@ -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"
},
{
Expand Down Expand Up @@ -1039,6 +1071,6 @@
"timezone": "",
"title": "Demo Dashboard",
"uid": "W2gX2zHVk",
"version": 2,
"version": 1,
"weekStart": ""
}

0 comments on commit 3c763db

Please sign in to comment.