# Istio 1.1 中的限流问题

在 [Istio 1.1 发布](https://blog.fleeto.us/post/servicemesh-and-chasm/)之后，对 [《深入浅出 Istio》](https://item.jd.com/12527008.html)一书中的例子[进行了一遍快速的检查](https://blog.fleeto.us/post/istio-book-update-for-1-1/)，发现限流功能已经无法使用了。

在解决了 [Prometheus 的 Handler 问题](https://blog.fleeto.us/post/handler-in-istio-1-1/)之后，开始查看限流的问题。

## Mixer 日志控制的两个小技巧

Mixer 策略相关内容比较多，经常需要查看 Policy 和 Telemetry 的日志，然而这两种进程的缺省日志都是很多的，可以用一点小技巧来进行清理。

### GODEBUG

首先，Mixer 的两个 Deployment 中都会带有 `GODEBUG` 环境变量，用于开启调试信息，可以使用 `kubectl edit` 命令删除环境变量。

### ControlZ

Istio 组件都带有 ControlZ 接口，可以用于控制和查看核心组件的一些配置信息，其端口都开放在 9876，可以用端口转发的方式打开进行调整，例如：

```shell
$ kubectl port-forward -n istio-system \
> istio-telemetry-c545bb9bd-x7jpz 9876:9876
Forwarding from 127.0.0.1:9876 -> 9876
Forwarding from [::1]:9876 -> 9876
```

然后就可以用浏览器打开 `http://127.0.0.1:9876` 进行调整了。

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1746352595377/fa3a6c20-c371-4e86-8a5f-832f54aa4653.png align="center")

## 言归正传

应用书中的 YAML 代码的同时，可以打开 Mixer 的日志，会发现其中有几行错误：

```bash
error  failed to evaluate expression for field 'Dimensions[destination]'; unknown attribute destination.service
error  Instance not found: instance='dest-quota.quota'
error  No valid instances found                                                error  No valid actions found in rule
```

这里发现了一个无法识别的属性：`destination.service`。翻查文档发现，该属性在 [Istio 1.0 的 Reference](https://archive.istio.io/v1.0/docs/reference/config/policy-and-telemetry/attribute-vocabulary/#deprecated-attributes) 中声明即将过期;在 1.1 中已经停用，因此将其改为 `destination.service.host` 即可正常使用。更新代码已经上传到随书代码库的 [1.1 分支](https://github.com/fleeto/istio-for-beginner/tree/1.1)中的第八章内容里。
