Skip to content

Commit

Permalink
istio envoy access logging
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueHorn07 committed Mar 18, 2024
1 parent 73f89d7 commit 371ef60
Showing 1 changed file with 96 additions and 0 deletions.
96 changes: 96 additions & 0 deletions _posts/development/istio/2024-03-16-istio-envoy-logging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---
title: "Istio Envoy Logging"
toc: true
toc_sticky: true
categories: ["Kubernetes", "Istio"]
excerpt: ""
last_modified_at: 2024-03-18
---


# ์‚ฌ์ „ ์ค€๋น„

```bash
k apply -f https://raw.githubusercontent.com/istio/istio/master/samples/helloworld/helloworld.yaml
```

# Enable Access Logging

## Telemetry API

```yaml
apiVersion: telemetry.istio.io/v1alpha1
kind: Telemetry
metadata:
name: default-ns-logging
namespace: default
spec:
accessLogging:
- providers:
- name: envoy
```
```bash
$ k exec -it ... -- sh
~ $ curl http://helloworld.default.svc.cluster.local:5000/hello
---
$ k exec -it helloworld... -c istio-proxy -- sh
...
[2024-03-18T23:08:48.020Z] "GET /hello HTTP/1.1" 200 - via_upstream - "-" 0 59 52 51 "-" "curl/8.6.0" "a0698764-a04d-48c8-8914-045808d19898" "helloworld.default.svc.cluster.local:5000" "10.42.0.4:5000" inbound|5000|| 127.0.0.6:60873 10.42.0.4:5000 10.42.0.6:48352 outbound_.5000_._.helloworld.default.svc.cluster.local default
...
[2024-03-18T23:10:51.528Z] "GET /hello HTTP/1.1" 200 - via_upstream - "-" 0 59 38 37 "-" "curl/7.88.1" "5c3abfa9-c806-490b-a5ec-a6659f866490" "helloworld.default.svc.cluster.local:5000" "10.42.0.5:5000" outbound|5000||helloworld.default.svc.cluster.local 10.42.0.4:55914 10.43.135.30:5000 10.42.0.4:41438 - default
...
```

## Mesh Config

```yaml
spec:
meshConfig:
accessLogFile: /dev/stdout
```
๋˜๋Š”
```bash
$ istioctl install --set meshConfig.accessLogFile=/dev/stdout
```

## ๋‘˜๋‹ค ์จ๋ณด๊ธฐ

์ผ๋‹จ Telemetry API ๋ฐฉ์‹๊ณผ Mesh Config ๋ฐฉ์‹ ๋‘˜๋‹ค ๋…๋ฆฝ์ ์ด๋‹ค! ์ฒ˜์Œ์—” ๋‘˜๋‹ค ์„ธํŒ…์„ ํ•ด์•ผ ๋กœ๊น…์ด ๋˜๋Š” ์ค„ ์•Œ์•˜๋Š”๋ฐ, ๊ทธ๊ฒŒ ์•„๋‹ˆ๋ผ ๋‘˜ ์ค‘ ์–ด๋–ค ๋ฐฉ๋ฒ•์„ ์จ๋„ Envoy Logging์ด ๋œ๋‹ค!

๋‹ค๋งŒ, ์ฐจ์ด์ ์€ Telemetry API๋Š” ๋„ค์ž„์ŠคํŽ˜์ด์Šค์™€ ์›Œํฌ๋กœ๋“œ Selector๋ฅผ ํ†ตํ•ด ๋กœ๊น… ๋Œ€์ƒ์„ ์„ ํƒํ•  ์ˆ˜ ์žˆ์–ด์„œ ์ข€๋” ์„ธ๋ฐ€ํ•œ(fine-grained) ๋กœ๊ทธ ์ œ์–ด๊ฐ€ ๊ฐ€๋Šฅํ•˜๋‹ค.

...

# Access Log Format

Access Log๊ฐ€ ์–ด๋–ค ์ •๋ณด๋“ค์„ ๋ณด์—ฌ์ฃผ๋Š”์ง€ ์ข€๋” ์‚ดํŽด๋ณด์ž.

## inbound, outbound ๊ตฌ๋ถ„ ๊ฐ€๋Šฅ

Envoy ์šฉ์–ด๋“ค ์ž ๊น ์ •๋ฆฌ

- upstream
- host
- cluster
- local address
- downstream
- local address
- remote address

## Request ๊ธฐ๋ณธ ์ •๋ณด ํ™•์ธ ๊ฐ€๋Šฅ

## Response ์ •๋ณด ํ™•์ธ ๊ฐ€๋Šฅ


```bash
[2024-03-18T23:08:48.020Z] "GET /hello HTTP/1.1" 200 - via_upstream - "-" 0 59 52 51 "-" "curl/8.6.0" "a0698764-a04d-48c8-8914-045808d19898" "helloworld.default.svc.cluster.local:5000" "10.42.0.4:5000" inbound|5000|| 127.0.0.6:60873 10.42.0.4:5000 10.42.0.6:48352 outbound_.5000_._.helloworld.default.svc.cluster.local default
...
[2024-03-18T23:10:51.528Z] "GET /hello HTTP/1.1" 200 - via_upstream - "-" 0 59 38 37 "-" "curl/7.88.1" "5c3abfa9-c806-490b-a5ec-a6659f866490" "helloworld.default.svc.cluster.local:5000" "10.42.0.5:5000" outbound|5000||helloworld.default.svc.cluster.local 10.42.0.4:55914 10.43.135.30:5000 10.42.0.4:41438 - default
```

# ์ฐธ๊ณ ์ž๋ฃŒ

- https://istio.io/latest/docs/tasks/observability/logs/access-log/

0 comments on commit 371ef60

Please sign in to comment.