Skip to content

Commit 3a03e84

Browse files
shimoncohenCopilotgithub-actions[bot]
authored
fix(log format): log format doesn't uphold opentelemetry field naming (MAPCO-8460) (#17)
* fix: log format doesn't uphold opentelemetry field naming * chore: simplify nginx.conf network_protocol regex * chore: quote upstream_response_length in log_format.conf * Update helm/config/log_format.conf Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update helm/config/log_format.conf * fix(log format): move host name to resources * update Helm documentation * Update helm/config/log_format.conf Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix(log format): incorrect opentelemetry span variable names * chore(log format): remove spaces before values --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent d32d99c commit 3a03e84

2 files changed

Lines changed: 25 additions & 7 deletions

File tree

helm/config/log_format.conf

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,45 @@ log_format main escape=json
1111
'"mapcolonies.http.auth.token.client_name":"$jwt_payload_sub",'
1212
{{ end }}
1313
'"http.request.method":"$request_method",'
14+
'"http.request.header.host":"$host",'
1415
'"http.request.header.referer":"$http_referer",'
16+
'"http.request.header.content-type":"$content_type",'
1517
'"http.request.body.size":"$content_length",'
16-
'"http.response.body.size":"$body_bytes_sent",'
18+
'"http.request.size": $request_length,'
19+
'"http.response.body.size": $body_bytes_sent,'
1720
'"http.response.header.x_forwarded_for":"$proxy_add_x_forwarded_for",'
1821
'"http.response.status_code":"$status",'
1922
'"user_agent.original":"$http_user_agent",'
20-
'"network.protocol":"$server_protocol",'
23+
'"network.protocol.name":"$otel_network_protocol_name",'
24+
'"network.protocol.version":"$otel_network_protocol_version",'
2125
'"mapcolonies.request_time":"$request_time",'
22-
'"mapcolonies.http.upstream_connect_time":"$upstream_connect_time",'
23-
'"mapcolonies.http.upstream_response_time":"$upstream_response_time",'
2426
'"mapcolonies.http.upstream_addr":"$upstream_addr",'
2527
'"mapcolonies.http.upstream_status_code":"$upstream_status",'
28+
'"mapcolonies.http.upstream_connect_time":"$upstream_connect_time",'
29+
'"mapcolonies.http.upstream_response_time":"$upstream_response_time",'
30+
'"mapcolonies.http.upstream_response_length":"$upstream_response_length",'
31+
'"mapcolonies.http.upstream_bytes_sent": $upstream_bytes_sent,'
32+
'"mapcolonies.http.upstream_bytes_received": $upstream_bytes_received,'
2633
'"mapcolonies.http.upstream_cache_status":"$upstream_cache_status",'
27-
'"mapcolonies.server":"$hostname",'
2834
'"server.address":"$host",'
2935
'"server.port":"$server_port",'
3036
'"client.address":"$remote_addr",'
3137
'"client.port":"$remote_port",'
3238
'"url.scheme":"$scheme",'
3339
'"url.path":"$uri",'
34-
'"url.full":"$request_uri"'
40+
'"url.full":"$request_uri",'
41+
'"url.query":"$query_string"'
3542
'},'
3643
'"Resource":{'
3744
# Additional important log details should be added here
45+
'"host.name":"$hostname",'
3846
'"service.name":"{{ .Values.image.repository }}",'
3947
'"service.version":"{{ .Values.image.tag }}"'
4048
'},'
4149
'"TraceId":"$otel_trace_id",' ## this is a byte sequence (hex-encoded in JSON)
4250
'"SpanId":"$otel_span_id",'
4351
'"SeverityText":"INFO",'
44-
'"SeverityNumber":9,'
52+
'"SeverityNumber": 9,'
4553
'"InstrumentationScope":"access.log",'
4654
'"Body":"$request"'
4755
'}';

helm/config/nginx.conf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ http {
1818
endpoint {{ .Values.opentelemetry.exporterHost }}:{{ .Values.opentelemetry.exporterPort }};
1919
}
2020

21+
map $server_protocol $otel_network_protocol_name {
22+
(.+)/.+$ $1;
23+
default "http";
24+
}
25+
26+
map $server_protocol $otel_network_protocol_version {
27+
.+/(.+)$ $1;
28+
default "1.1";
29+
}
30+
2131
include /etc/nginx/mime.types;
2232
default_type application/octet-stream;
2333

0 commit comments

Comments
 (0)