Skip to content

Commit 3c763db

Browse files
puckpuckjulianocosta89cedriczielmartinjt
authored
[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 <julianocosta89@outlook.com> Co-authored-by: Cedric Ziel <cedric@cedric-ziel.com> Co-authored-by: Juliano Costa <juliano.costa@datadoghq.com> Co-authored-by: Martin Thwaites <github@my2cents.co.uk>
1 parent 069b80b commit 3c763db

File tree

6 files changed

+138
-10
lines changed

6 files changed

+138
-10
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ the release.
1111
([#1764](https://github.com/open-telemetry/opentelemetry-demo/pull/1764))
1212
* [chore] Move build args to .env file
1313
([#1767](https://github.com/open-telemetry/opentelemetry-demo/pull/1767))
14+
* [frontendproxy] add access logs
15+
([#1768](https://github.com/open-telemetry/opentelemetry-demo/pull/1768))
1416
* [grafana] Fix Dashboards
1517
([#1779](https://github.com/open-telemetry/opentelemetry-demo/pull/1779))
1618
* [accountingservice] bump OpenTelemetry .NET Automatic Instrumentation

docker-compose.minimal.yml

+1
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ services:
269269
- OTEL_COLLECTOR_PORT_GRPC
270270
- OTEL_COLLECTOR_PORT_HTTP
271271
- OTEL_RESOURCE_ATTRIBUTES
272+
- OTEL_SERVICE_NAME=frontend-proxy
272273
- ENVOY_PORT
273274
- FLAGD_HOST
274275
- FLAGD_PORT

docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ services:
343343
- OTEL_COLLECTOR_PORT_GRPC
344344
- OTEL_COLLECTOR_PORT_HTTP
345345
- OTEL_RESOURCE_ATTRIBUTES
346+
- OTEL_SERVICE_NAME=frontend-proxy
346347
- ENVOY_PORT
347348
- FLAGD_HOST
348349
- FLAGD_PORT

src/frontendproxy/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright The OpenTelemetry Authors
22
# SPDX-License-Identifier: Apache-2.0
33

4-
FROM envoyproxy/envoy:v1.30-latest
4+
FROM envoyproxy/envoy:v1.32-latest
55
RUN apt-get update && apt-get install -y gettext-base && apt-get clean && rm -rf /var/lib/apt/lists/*
66

77
USER envoy

src/frontendproxy/envoy.tmpl.yaml

+93-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static_resources:
2525
envoy_grpc:
2626
cluster_name: opentelemetry_collector_grpc
2727
timeout: 0.250s
28-
service_name: frontend-proxy
28+
service_name: ${OTEL_SERVICE_NAME}
2929
resource_detectors:
3030
- name: envoy.tracers.opentelemetry.resource_detectors.environment
3131
typed_config:
@@ -65,6 +65,98 @@ static_resources:
6565
- name: envoy.filters.http.router
6666
typed_config:
6767
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
68+
access_log:
69+
- name: envoy.access_loggers.open_telemetry
70+
typed_config:
71+
"@type": "type.googleapis.com/envoy.extensions.access_loggers.open_telemetry.v3.OpenTelemetryAccessLogConfig"
72+
common_config:
73+
log_name: "otel_envoy_access_log"
74+
grpc_service:
75+
envoy_grpc:
76+
cluster_name: opentelemetry_collector_grpc
77+
transport_api_version: "V3"
78+
body:
79+
# yamllint disable-line rule:line-length
80+
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"
81+
resource_attributes:
82+
values:
83+
- key: "service.name"
84+
value:
85+
string_value: ${OTEL_SERVICE_NAME}
86+
attributes:
87+
values:
88+
- key: "destination.address"
89+
value:
90+
string_value: "%UPSTREAM_REMOTE_ADDRESS_WITHOUT_PORT%"
91+
- key: "event.name"
92+
value:
93+
string_value: "proxy.access"
94+
- key: "http.connection.id"
95+
value:
96+
string_value: "%CONNECTION_ID%"
97+
- key: "http.protocol"
98+
value:
99+
string_value: "%PROTOCOL%"
100+
- key: "http.request.body.size"
101+
value:
102+
string_value: "%BYTES_RECEIVED%"
103+
- key: "http.request.header.x-forwarded-for"
104+
value:
105+
string_value: "%REQ(X-FORWARDED-FOR)%"
106+
- key: "http.request.header.x-request-id"
107+
value:
108+
string_value: "%REQ(X-REQUEST-ID)%"
109+
- key: "http.request.headers.size"
110+
value:
111+
string_value: "%REQUEST_HEADERS_BYTES%"
112+
- key: "http.request.id"
113+
value:
114+
string_value: "%STREAM_ID%"
115+
- key: "http.request.method"
116+
value:
117+
string_value: "%REQ(:METHOD)%"
118+
- key: "http.request.start_time"
119+
value:
120+
string_value: "%START_TIME%"
121+
- key: "http.response.body.size"
122+
value:
123+
string_value: "%BYTES_SENT%"
124+
- key: "http.response.headers.size"
125+
value:
126+
string_value: "%RESPONSE_HEADERS_BYTES%"
127+
- key: "http.response.status_code"
128+
value:
129+
string_value: "%RESPONSE_CODE%"
130+
- key: "http.total_duration_ms"
131+
value:
132+
string_value: "%DURATION%"
133+
- key: "server.address"
134+
value:
135+
string_value: "%DOWNSTREAM_LOCAL_ADDRESS%"
136+
- key: "source.address"
137+
value:
138+
string_value: "%DOWNSTREAM_REMOTE_ADDRESS_WITHOUT_PORT%"
139+
- key: "upstream.cluster"
140+
value:
141+
string_value: "%UPSTREAM_CLUSTER%"
142+
- key: "upstream.host"
143+
value:
144+
string_value: "%UPSTREAM_HOST%"
145+
- key: "user_agent.original"
146+
value:
147+
string_value: "%REQ(USER-AGENT)%"
148+
- key: "url.full"
149+
value:
150+
string_value: "%REQ(:SCHEME)%://%REQ(:AUTHORITY)%%REQ(:PATH)%"
151+
- key: "url.path"
152+
value:
153+
string_value: "%REQ(:PATH)%"
154+
- key: "url.query"
155+
value:
156+
string_value: "%REQ(:QUERY)%"
157+
- key: "url.template"
158+
value:
159+
string_value: "%ROUTE_NAME%"
68160

69161
clusters:
70162
- name: opentelemetry_collector_grpc

src/grafana/provisioning/dashboards/demo/demo-dashboard.json

+40-8
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@
401401
"mode": "thresholds"
402402
},
403403
"custom": {
404-
"align": "auto",
404+
"align": "left",
405405
"cellOptions": {
406406
"type": "auto"
407407
},
@@ -422,7 +422,20 @@
422422
]
423423
}
424424
},
425-
"overrides": []
425+
"overrides": [
426+
{
427+
"matcher": {
428+
"id": "byName",
429+
"options": "count()"
430+
},
431+
"properties": [
432+
{
433+
"id": "custom.width",
434+
"value": 90
435+
}
436+
]
437+
}
438+
]
426439
},
427440
"gridPos": {
428441
"h": 8,
@@ -509,7 +522,20 @@
509522
]
510523
}
511524
},
512-
"overrides": []
525+
"overrides": [
526+
{
527+
"matcher": {
528+
"id": "byName",
529+
"options": "observedTimestamp"
530+
},
531+
"properties": [
532+
{
533+
"id": "custom.width",
534+
"value": 222
535+
}
536+
]
537+
}
538+
]
513539
},
514540
"gridPos": {
515541
"h": 8,
@@ -528,7 +554,13 @@
528554
],
529555
"show": false
530556
},
531-
"showHeader": true
557+
"showHeader": true,
558+
"sortBy": [
559+
{
560+
"desc": true,
561+
"displayName": "observedTimestamp"
562+
}
563+
]
532564
},
533565
"pluginVersion": "11.3.0",
534566
"targets": [
@@ -556,13 +588,13 @@
556588
"type": "count"
557589
}
558590
],
559-
"query": "search source=otel\n| where resource.service.name=\"${service}\"",
591+
"query": "search source=otel\n| where resource.service.name=\"${service}\"| sort - observedTimestamp | head 100",
560592
"queryType": "PPL",
561593
"refId": "A",
562-
"timeField": "time"
594+
"timeField": "observedTimestamp"
563595
}
564596
],
565-
"title": "${service} Logs",
597+
"title": "${service} Logs (100 recent entries)",
566598
"type": "table"
567599
},
568600
{
@@ -1039,6 +1071,6 @@
10391071
"timezone": "",
10401072
"title": "Demo Dashboard",
10411073
"uid": "W2gX2zHVk",
1042-
"version": 2,
1074+
"version": 1,
10431075
"weekStart": ""
10441076
}

0 commit comments

Comments
 (0)