Istioでアクセスログのフォーマットを変更する

この記事は「[イエソド アウトプット筋 トレーニング Advent Calendar 2020](https://adventar.org/calendars/5888)」19日目の記事です。

# はじめに
MeshConfigを設定することでenvoyのアクセスログフォーマットを変更することができます。
今回は最新のIstiov1.8とローカルのk8sで検証をしています。

# インストール
事前に[istioctl](https://istio.io/latest/docs/setup/getting-started/#download)はダウンロードしておいてください。
まずインストール前にIstioOperatorリソースで　Istioの設定を定義していきます。
ログのフォーマットの定義の仕方については[こちらのページ](https://www.envoyproxy.io/docs/envoy/latest/configuration/observability/access_log/usage#format-rules)を参考にしてください
この設定ファイルを今回はconfig.yamlとして保存します。

```yaml
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
spec:
  meshConfig:
    accessLogFile: /dev/stdout
    accessLogFormat: "[%START_TIME%] \"%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%%PROTOCOL%\" %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)%
                       \"%REQ(X-FORWARDED-FOR)%\" \"%REQ(USER-AGENT)%\" \"%REQ(X-REQUEST-ID)%\"
                       \"%UPSTREAM_HOST%\" %UPSTREAM_CLUSTER% %UPSTREAM_LOCAL_ADDRESS% %DOWNSTREAM_LOCAL_ADDRESS%
                       %DOWNSTREAM_REMOTE_ADDRESS% %DYNAMIC_METADATA(envoy.lb)% \n"

```

`istioctl install -f config.yaml`でインストールを実行します。

```bash
istioctl install -f config.yaml 
This will install the Istio default profile with ["Istio core" "Istiod" "Ingress gateways"] components into the cluster. Proceed? (y/N) y
Detected that your cluster does not support third party JWT authentication. Falling back to less secure first party JWT. See https://istio.io/v1.8/docs/ops/best-practices/security/#configure-third-party-service-account-tokens for details.
✔ Istio core installed                                                                                                                           
✔ Istiod installed                                                                                                                               
✔ Ingress gateways installed                                                                                                                     
✔ Installation complete

kubectl label namespace default istio-injection=enabled

```

よく使うsamplebookのアプリをdeployします。

```bash
kubectl apply -f ./istio-1.8.1/samples/bookinfo/platform/kube/bookinfo.yaml 
service/details unchanged
serviceaccount/bookinfo-details unchanged
deployment.apps/details-v1 created
service/ratings unchanged
serviceaccount/bookinfo-ratings unchanged
deployment.apps/ratings-v1 created
service/reviews unchanged
serviceaccount/bookinfo-reviews unchanged
deployment.apps/reviews-v1 created
deployment.apps/reviews-v2 created
deployment.apps/reviews-v3 created
service/productpage unchanged
serviceaccount/bookinfo-productpage unchanged
deployment.apps/productpage-v1 created

kubectl apply -f ./istio-1.8.1/samples/bookinfo/networking/bookinfo-gateway.yaml
gateway.networking.istio.io/bookinfo-gateway created
virtualservice.networking.istio.io/bookinfo created
```

`http://localhost/productpage`に何度かアクセスしてログを確認してみる

```bash
kubectl logs productpage-v1-65576bb7bf-5wz2q istio-proxy 
[2020-12-19T02:28:01.386Z] "GET /reviews/0HTTP/1.1" 200 - 0 379 27 26 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "31659673-ad1b-46a1-9bd6-dbfea94496eb" "10.1.1.153:9080" outbound|9080||reviews.default.svc.cluster.local 10.1.1.156:58398 10.98.248.27:9080 10.1.1.156:43198 - 
[2020-12-19T02:28:01.369Z] "GET /productpageHTTP/1.1" 200 - 0 5183 47 45 "192.168.65.3" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "31659673-ad1b-46a1-9bd6-dbfea94496eb" "127.0.0.1:9080" inbound|9080|| 127.0.0.1:38954 10.1.1.156:9080 192.168.65.3:0 - 
[2020-12-19T02:28:01.505Z] "GET /details/0HTTP/1.1" 200 - 0 178 3 3 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "ee43a0b4-e64e-4956-bc46-59f204c68ebd" "10.1.1.151:9080" outbound|9080||details.default.svc.cluster.local 10.1.1.156:60376 10.97.129.188:9080 10.1.1.156:55076 - 
[2020-12-19T02:28:01.514Z] "GET /reviews/0HTTP/1.1" 200 - 0 295 5 5 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "ee43a0b4-e64e-4956-bc46-59f204c68ebd" "10.1.1.152:9080" outbound|9080||reviews.default.svc.cluster.local 10.1.1.156:46034 10.98.248.27:9080 10.1.1.156:43208 - 
[2020-12-19T02:28:01.500Z] "GET /productpageHTTP/1.1" 200 - 0 4183 24 23 "192.168.65.3" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "ee43a0b4-e64e-4956-bc46-59f204c68ebd" "127.0.0.1:9080" inbound|9080|| 127.0.0.1:38964 10.1.1.156:9080 192.168.65.3:0 - 
[2020-12-19T02:28:01.766Z] "GET /details/0HTTP/1.1" 200 - 0 178 3 2 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "47666088-d6a8-4899-becf-706b48a3bbec" "10.1.1.151:9080" outbound|9080||details.default.svc.cluster.local 10.1.1.156:60454 10.97.129.188:9080 10.1.1.156:55084 - 
[2020-12-19T02:28:01.775Z] "GET /reviews/0HTTP/1.1" 200 - 0 379 17 17 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "47666088-d6a8-4899-becf-706b48a3bbec" "10.1.1.153:9080" outbound|9080||reviews.default.svc.cluster.local 10.1.1.156:58498 10.98.248.27:9080 10.1.1.156:43216 - 
[2020-12-19T02:28:01.761Z] "GET /productpageHTTP/1.1" 200 - 0 5183 35 34 "192.168.65.3" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "47666088-d6a8-4899-becf-706b48a3bbec" "127.0.0.1:9080" inbound|9080|| 127.0.0.1:38972 10.1.1.156:9080 192.168.65.3:0 - 
[2020-12-19T02:28:01.915Z] "GET /details/0HTTP/1.1" 200 - 0 178 2 2 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "378dbb1b-25ff-445b-8f54-3621c3c838fb" "10.1.1.151:9080" outbound|9080||details.default.svc.cluster.local 10.1.1.156:60454 10.97.129.188:9080 10.1.1.156:55094 - 
[2020-12-19T02:28:01.923Z] "GET /reviews/0HTTP/1.1" 200 - 0 375 15 14 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "378dbb1b-25ff-445b-8f54-3621c3c838fb" "10.1.1.154:9080" outbound|9080||reviews.default.svc.cluster.local 10.1.1.156:49094 10.98.248.27:9080 10.1.1.156:43226 - 
[2020-12-19T02:28:01.908Z] "GET /productpageHTTP/1.1" 200 - 0 5179 32 31 "192.168.65.3" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "378dbb1b-25ff-445b-8f54-3621c3c838fb" "127.0.0.1:9080" inbound|9080|| 127.0.0.1:38982 10.1.1.156:9080 192.168.65.3:0 - 
[2020-12-19T02:28:02.051Z] "GET /details/0HTTP/1.1" 200 - 0 178 3 3 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "a3977bb9-9677-4c50-9666-d850528df488" "10.1.1.151:9080" outbound|9080||details.default.svc.cluster.local 10.1.1.156:60454 10.97.129.188:9080 10.1.1.156:55102 - 
[2020-12-19T02:28:02.059Z] "GET /reviews/0HTTP/1.1" 200 - 0 375 18 18 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "a3977bb9-9677-4c50-9666-d850528df488" "10.1.1.154:9080" outbound|9080||reviews.default.svc.cluster.local 10.1.1.156:49168 10.98.248.27:9080 10.1.1.156:43234 - 
[2020-12-19T02:28:02.044Z] "GET /productpageHTTP/1.1" 200 - 0 5179 37 36 "192.168.65.3" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "a3977bb9-9677-4c50-9666-d850528df488" "127.0.0.1:9080" inbound|9080|| 127.0.0.1:38990 10.1.1.156:9080 192.168.65.3:0 - 
[2020-12-19T02:28:02.197Z] "GET /details/0HTTP/1.1" 200 - 0 178 2 2 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "cb275504-3d0f-4bb9-86f1-0974defaaa91" "10.1.1.151:9080" outbound|9080||details.default.svc.cluster.local 10.1.1.156:60454 10.97.129.188:9080 10.1.1.156:55112 - 
[2020-12-19T02:28:02.205Z] "GET /reviews/0HTTP/1.1" 200 - 0 295 4 4 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "cb275504-3d0f-4bb9-86f1-0974defaaa91" "10.1.1.152:9080" outbound|9080||reviews.default.svc.cluster.local 10.1.1.156:46034 10.98.248.27:9080 10.1.1.156:43244 - 
[2020-12-19T02:28:02.191Z] "GET /productpageHTTP/1.1" 200 - 0 4183 21 20 "192.168.65.3" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "cb275504-3d0f-4bb9-86f1-0974defaaa91" "127.0.0.1:9080" inbound|9080|| 127.0.0.1:39000 10.1.1.156:9080 192.168.65.3:0 - 
[2020-12-19T02:28:02.456Z] "GET /details/0HTTP/1.1" 200 - 0 178 3 2 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "55fad882-0c38-4275-8c12-0d0f0c5cf920" "10.1.1.151:9080" outbound|9080||details.default.svc.cluster.local 10.1.1.156:60376 10.97.129.188:9080 10.1.1.156:55126 - 
[2020-12-19T02:28:02.467Z] "GET /reviews/0HTTP/1.1" 200 - 0 379 32 32 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "55fad882-0c38-4275-8c12-0d0f0c5cf920" "10.1.1.153:9080" outbound|9080||reviews.default.svc.cluster.local 10.1.1.156:58498 10.98.248.27:9080 10.1.1.156:43258 - 
[2020-12-19T02:28:02.445Z] "GET /productpageHTTP/1.1" 200 - 0 5183 56 55 "192.168.65.3" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "55fad882-0c38-4275-8c12-0d0f0c5cf920" "127.0.0.1:9080" inbound|9080|| 127.0.0.1:39012 10.1.1.156:9080 192.168.65.3:0 - 
[2020-12-19T02:28:02.674Z] "GET /details/0HTTP/1.1" 200 - 0 178 3 3 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "3ceffb46-e609-41b7-aebd-576ee253d540" "10.1.1.151:9080" outbound|9080||details.default.svc.cluster.local 10.1.1.156:60454 10.97.129.188:9080 10.1.1.156:55132 - 
[2020-12-19T02:28:02.682Z] "GET /reviews/0HTTP/1.1" 200 - 0 375 15 15 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "3ceffb46-e609-41b7-aebd-576ee253d540" "10.1.1.154:9080" outbound|9080||reviews.default.svc.cluster.local 10.1.1.156:49094 10.98.248.27:9080 10.1.1.156:43264 - 
[2020-12-19T02:28:02.668Z] "GET /productpageHTTP/1.1" 200 - 0 5179 32 31 "192.168.65.3" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "3ceffb46-e609-41b7-aebd-576ee253d540" "127.0.0.1:9080" inbound|9080|| 127.0.0.1:39020 10.1.1.156:9080 192.168.65.3:0 - 
[2020-12-19T02:28:02.834Z] "GET /details/0HTTP/1.1" 200 - 0 178 3 2 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "c2e9c03e-0263-40fa-a121-c45d72f3050f" "10.1.1.151:9080" outbound|9080||details.default.svc.cluster.local 10.1.1.156:60454 10.97.129.188:9080 10.1.1.156:55142 - 
[2020-12-19T02:28:02.842Z] "GET /reviews/0HTTP/1.1" 200 - 0 295 4 4 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "c2e9c03e-0263-40fa-a121-c45d72f3050f" "10.1.1.152:9080" outbound|9080||reviews.default.svc.cluster.local 10.1.1.156:46034 10.98.248.27:9080 10.1.1.156:43274 - 
[2020-12-19T02:28:02.828Z] "GET /productpageHTTP/1.1" 200 - 0 4183 23 22 "192.168.65.3" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "c2e9c03e-0263-40fa-a121-c45d72f3050f" "127.0.0.1:9080" inbound|9080|| 127.0.0.1:39030 10.1.1.156:9080 192.168.65.3:0 - 
[2020-12-19T02:28:03.018Z] "GET /details/0HTTP/1.1" 200 - 0 178 3 2 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "93e0348d-bcd6-437e-a95b-2ba4b9c344b9" "10.1.1.151:9080" outbound|9080||details.default.svc.cluster.local 10.1.1.156:60454 10.97.129.188:9080 10.1.1.156:55150 - 
[2020-12-19T02:28:03.026Z] "GET /reviews/0HTTP/1.1" 200 - 0 379 20 19 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "93e0348d-bcd6-437e-a95b-2ba4b9c344b9" "10.1.1.153:9080" outbound|9080||reviews.default.svc.cluster.local 10.1.1.156:58498 10.98.248.27:9080 10.1.1.156:43282 - 
[2020-12-19T02:28:03.012Z] "GET /productpageHTTP/1.1" 200 - 0 5183 38 37 "192.168.65.3" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "93e0348d-bcd6-437e-a95b-2ba4b9c344b9" "127.0.0.1:9080" inbound|9080|| 127.0.0.1:39038 10.1.1.156:9080 192.168.65.3:0 - 
[2020-12-19T02:28:03.244Z] "GET /details/0HTTP/1.1" 200 - 0 178 4 3 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "7985acf7-c9d8-481a-b045-ad569ac75c2f" "10.1.1.151:9080" outbound|9080||details.default.svc.cluster.local 10.1.1.156:60376 10.97.129.188:9080 10.1.1.156:55158 - 
[2020-12-19T02:28:03.252Z] "GET /reviews/0HTTP/1.1" 200 - 0 375 27 26 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "7985acf7-c9d8-481a-b045-ad569ac75c2f" "10.1.1.154:9080" outbound|9080||reviews.default.svc.cluster.local 10.1.1.156:49094 10.98.248.27:9080 10.1.1.156:43290 - 
[2020-12-19T02:28:03.236Z] "GET /productpageHTTP/1.1" 200 - 0 5179 46 45 "192.168.65.3" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "7985acf7-c9d8-481a-b045-ad569ac75c2f" "127.0.0.1:9080" inbound|9080|| 127.0.0.1:39046 10.1.1.156:9080 192.168.65.3:0 - 
[2020-12-19T02:28:03.490Z] "GET /details/0HTTP/1.1" 200 - 0 178 2 2 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "bd94ab09-78ba-40bf-bc8f-6fbe05ed39d1" "10.1.1.151:9080" outbound|9080||details.default.svc.cluster.local 10.1.1.156:60454 10.97.129.188:9080 10.1.1.156:55174 - 
[2020-12-19T02:28:03.497Z] "GET /reviews/0HTTP/1.1" 200 - 0 295 3 3 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "bd94ab09-78ba-40bf-bc8f-6fbe05ed39d1" "10.1.1.152:9080" outbound|9080||reviews.default.svc.cluster.local 10.1.1.156:46034 10.98.248.27:9080 10.1.1.156:43306 - 
[2020-12-19T02:28:03.484Z] "GET /productpageHTTP/1.1" 200 - 0 4183 19 18 "192.168.65.3" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "bd94ab09-78ba-40bf-bc8f-6fbe05ed39d1" "127.0.0.1:9080" inbound|9080|| 127.0.0.1:39062 10.1.1.156:9080 192.168.65.3:0 - 
[2020-12-19T02:28:03.659Z] "GET /details/0HTTP/1.1" 200 - 0 178 3 2 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "df9be44b-ea15-4795-ad49-a308cc84c888" "10.1.1.151:9080" outbound|9080||details.default.svc.cluster.local 10.1.1.156:60376 10.97.129.188:9080 10.1.1.156:55184 - 
[2020-12-19T02:28:03.667Z] "GET /reviews/0HTTP/1.1" 200 - 0 379 16 15 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "df9be44b-ea15-4795-ad49-a308cc84c888" "10.1.1.153:9080" outbound|9080||reviews.default.svc.cluster.local 10.1.1.156:58498 10.98.248.27:9080 10.1.1.156:43316 - 
[2020-12-19T02:28:03.653Z] "GET /productpageHTTP/1.1" 200 - 0 5183 31 31 "192.168.65.3" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "df9be44b-ea15-4795-ad49-a308cc84c888" "127.0.0.1:9080" inbound|9080|| 127.0.0.1:39072 10.1.1.156:9080 192.168.65.3:0 - 
[2020-12-19T02:28:03.875Z] "GET /details/0HTTP/1.1" 200 - 0 178 3 2 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "4dbe23f6-2ceb-4e33-8d8a-cf7e2e62c8c8" "10.1.1.151:9080" outbound|9080||details.default.svc.cluster.local 10.1.1.156:60454 10.97.129.188:9080 10.1.1.156:55198 - 
[2020-12-19T02:28:03.883Z] "GET /reviews/0HTTP/1.1" 200 - 0 295 4 3 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "4dbe23f6-2ceb-4e33-8d8a-cf7e2e62c8c8" "10.1.1.152:9080" outbound|9080||reviews.default.svc.cluster.local 10.1.1.156:45932 10.98.248.27:9080 10.1.1.156:43330 - 
[2020-12-19T02:28:03.869Z] "GET /productpageHTTP/1.1" 200 - 0 4183 20 20 "192.168.65.3" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "4dbe23f6-2ceb-4e33-8d8a-cf7e2e62c8c8" "127.0.0.1:9080" inbound|9080|| 127.0.0.1:39086 10.1.1.156:9080 192.168.65.3:0 - 
```

# まとめ
meshConfigを設定してアクセスログフォーマットを変更することができました。
他にもaccessLogEncodingを設定することでJSON形式でアクセスログを出力することも可能です。
istioのインストール時にはこの辺りの[オプション](https://istio.io/latest/docs/reference/config/istio.mesh.v1alpha1/#MeshConfig)は確認しておきたいですね。

来年からはアドベントカレンダーで技術に関係ないことも書きたいので、何か適当なブログでも作ろうと思います。