8.4.4 查看日志

Mixer中内置了stdio适配器,这一适配器将生成的日志数据在本机上输出;为了演示如何收集和查看日志数据,按照以下步骤执行。

1)部署应用示例。仍然使用前面章节中使用的httpbin与sleep服务作为应用示例,运行以下命令部署应用示例:


$ cd mixer/stdio-adapter
$ kubectl create -f httpbin.yaml
$ kubectl create -f sleep.yaml
$ kubectl create -f destination-rule.yaml
$ kubectl create -f virtual-service-80-20.yaml

2)向示例应用发送请求。登录到sleep容器中,执行curl命令发送请求,如下所示:


curl http://httpbin:8000/get

3)查看新指标的生成和收集情况。在Kubernetes环境中,使用下面的命令在istio-telemetry pods中搜索日志:


$ kubectl logs -n istio-system -l istio-mixer-type=telemetry -c mixer | grep \"instance\":\"newlog.logentry.istio-system\"
{"level":"warn","time":"2019-02-12T06:08:50.188430Z","instance":"newlog.logentry.istio-system","destination":"telemetry","latency":"1.351686ms","responseCode":200,"responseSize":5,"source":"sleep","user":"unknown"}
{"level":"warn","time":"2019-02-12T06:08:57.075340Z","instance":"newlog.logentry.istio-system","destination":"policy","latency":"1.416861ms","responseCode":200,"responseSize":70,"source":"httpbin","user":"unknown"}
{"level":"warn","time":"2019-02-12T06:08:57.074245Z","instance":"newlog.logentry.istio-system","destination":"httpbin","latency":"5.129003ms","responseCode":200,"responseSize":404,"source":"unknown","user":"unknown"}
{"level":"warn","time":"2019-02-12T06:08:58.076634Z","instance":"newlog.logentry.istio-system","destination":"telemetry","latency":"1.97113ms","responseCode":200,"responseSize":5,"source":"policy","user":"unknown"}
{"level":"warn","time":"2019-02-12T06:08:58.079527Z","instance":"newlog.logentry.istio-system","destination":"telemetry","latency":"1.448625ms","responseCode":200,"responseSize":5,"source":"httpbin","user":"unknown"}