zh-translation: remove stale document (#10619)

This commit is contained in:
jxlwqq 2021-12-17 20:39:37 +08:00 committed by GitHub
parent 323594a289
commit 8816ff87bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 454 deletions

View File

@ -1,97 +0,0 @@
---
title: 收集日志
description: 本任务向您展示如何配置 Istio 来收集和定制日志。
weight: 10
keywords: [telemetry,logs]
aliases:
- /zh/docs/tasks/telemetry/logs/collecting-logs/
---
本任务展示如何配置 Istio 来自动地收集网格中服务的遥测指标。任务的最后,将为调用网格内部的服务打开一个新的日志流。
全文以 [Bookinfo](/zh/docs/examples/bookinfo/) 作为示例应用。
## 开始之前{#before-you-begin}
* 在集群中[安装 Istio](/zh/docs/setup) 并部署一个应用。本任务假定在默认配置(`--configDefaultNamespace=istio-system`)中安装了 Mixer。如果您使用了不同的配置请更新本任务中配置文件和命令的对应项与之匹配。
## 收集新的日志数据{#collecting-new-logs-data}
1. 为新日志流生效一个 YAML 配置文件Istio 将自动生成并收集日志信息。
{{< text bash >}}
$ kubectl apply -f @samples/bookinfo/telemetry/log-entry.yaml@
{{< /text >}}
{{< warning >}}
如果您使用 Istio 1.1.2 或更早前的版本,请使用下面的配置文件:
{{< text bash >}}
$ kubectl apply -f @samples/bookinfo/telemetry/log-entry-crd.yaml@
{{< /text >}}
{{< /warning >}}
1. 向示例应用发送流量。
以 Bookinfo 为例,在浏览器中访问 `http://$GATEWAY_URL/productpage` 或执行如下命令:
{{< text bash >}}
$ curl http://$GATEWAY_URL/productpage
{{< /text >}}
1. 验证是否已经生成了日志流并且正向其中不断增添请求。
在 Kubernetes 环境中,搜索 `istio-telemetry` pods 的日志信息,如下所示:
{{< text bash json >}}
$ kubectl logs -n istio-system -l istio-mixer-type=telemetry -c mixer | grep "newlog" | grep -v '"destination":"telemetry"' | grep -v '"destination":"pilot"' | grep -v '"destination":"policy"' | grep -v '"destination":"unknown"'
{"level":"warn","time":"2018-09-15T20:46:36.009801Z","instance":"newlog.xxxxx.istio-system","destination":"details","latency":"13.601485ms","responseCode":200,"responseSize":178,"source":"productpage","user":"unknown"}
{"level":"warn","time":"2018-09-15T20:46:36.026993Z","instance":"newlog.xxxxx.istio-system","destination":"reviews","latency":"919.482857ms","responseCode":200,"responseSize":295,"source":"productpage","user":"unknown"}
{"level":"warn","time":"2018-09-15T20:46:35.982761Z","instance":"newlog.xxxxx.istio-system","destination":"productpage","latency":"968.030256ms","responseCode":200,"responseSize":4415,"source":"istio-ingressgateway","user":"unknown"}
{{< /text >}}
## 理解日志配置文件{#understanding-the-logs-configuration}
在本任务中,您新增了 Istio 配置来通知 Mixer 自动生成并报告一个新的日志流,以记录网格内的所有请求。
新增配置控制 Mixer 的三项功能:
1. 基于 Istio 的属性信息,生成 *实例* (本示例中,指的是日志项)。
1. 创建 *handler* (配置好的 Mixer 适配器),处理生成的 *实例*
1. 根据一组 *规则* ,将 *实例* 分配给 *handler*
日志配置文件指示 Mixer 将日志项发送到标准输出。其中使用了三段(或块)配置:*实例* 配置,*handler* 配置以及 *规则* 配置。
配置段 `kind: instance` 为生成的日志项(或 *实例* )定义了一个模式,名为 `newlog`。实例配置通知 Mixer 如何基于 Envoy 报告的属性信息,为请求生成日志项。
参数 `severity` 用于为生成的 `logentry` 标识日志级别。在本示例中,使用了一个字面表达,值为 “warn”。`logentry` *handler* 将把该字面值映射为其支持的日志级别。
参数 `timestamp` 提供所有日志项的时间信息。在本示例中,根据 Envoy 提供的信息,时间为属性 `request.time` 的值。
参数 `variables` 允许运维人员配置应该在每个 `logentry` 中显示的信息。一组表达式负责管理从 Istio 属性值和字面值到构成 `logentry` 对应值的映射关系。在本示例中,每个 `logentry` 实例都包含一个域名 `latency`,其对应着属性 `response.duration` 的值。如果没有已知的 `response.duration` 属性值,则将 `latency` 域值设置为 `0ms`
配置段 `kind: handler` 定义了一个名为 `newloghandler`*handler* 。Handler `spec` 负责配置 `stdio` 编译的适配器代码如何处理接收到的 `logentry` 实例。参数 `severity_levels` 负责管理 `logentry``severity` 域值如何映射到所支持的日志级别。本示例中“warn” 映射为日志级别 “WARNING”。参数 `outputAsJson` 指示适配器生成 JSON 格式的日志行。
配置段 `kind: rule` 定义了一个新 *规则* ,名为 `newlogstdio`。该规则指示 Mixer 将所有 `newlog` 实例发送给 handler `newloghandler`。由于参数 `match` 被设置为 `true`,该规则对网格中的所有请求都生效。
规则规范中的 `match: true` 表达式无需对所有请求配置一个执行规则。删掉 `spec` 中的 `match` 参数等价于设置了 `match: true`。本案例中将其包含在 `spec` 中,是为了说明如何使用 `match` 表达式来控制执行规则。
## 清除{#cleanup}
* 删除新的日志配置:
{{< text bash >}}
$ kubectl delete -f @samples/bookinfo/telemetry/log-entry.yaml@
{{< /text >}}
若使用 Istio 1.1.2 或更早版本:
{{< text bash >}}
$ kubectl delete -f @samples/bookinfo/telemetry/log-entry-crd.yaml@
{{< /text >}}
* 若无后续任务,请参考
[Bookinfo cleanup](/zh/docs/examples/bookinfo/#cleanup) 命令关掉应用。

View File

@ -1,357 +0,0 @@
---
title: 使用 Fluentd 进行日志收集
description: 此任务向您展示如何配置 Istio 以连接到 Fluentd 守护程序进行日志收集。
weight: 90
keywords: [telemetry,logging]
aliases:
- /zh/docs/tasks/telemetry/fluentd/
- /zh/docs/tasks/telemetry/logs/fluentd/
---
此任务展示如何配置 Istio 以创建自定义日志条目,并将其发送到 [Fluentd](https://www.fluentd.org/) 守护程序。
Fluentd 是一个开源的日志收集器,它支持许多[数据输出](https://www.fluentd.org/dataoutputs)并具有可插拔的体系结构。
一个常见的日志收集后端是 [Elasticsearch](https://www.elastic.co/products/elasticsearch)
和作为查看器的 [Kibana](https://www.elastic.co/products/kibana)。
接下来,将启用新的日志流,并把日志发送到示例堆栈 Fluentd / Elasticsearch / Kibana。
整个任务中,使用 [Bookinfo](/zh/docs/examples/bookinfo/) 作为示例应用程序。
## 开始之前{#before-you-begin}
* 在您的集群中[安装 Istio](/zh/docs/setup/) 并部署应用程序。
此任务假定已将 Mixer 设置为默认配置(`--configDefaultNamespace=istio-system`)。
如果使用其它值,此任务中请更新配置和命令以匹配该值。
## 安装 Fluentd{#setup-Fluentd}
在您的集群中,您可能已经在运行 Fluentd 守护程序,例如
[此处](https://kubernetes.io/docs/tasks/debug-application-cluster/logging-elasticsearch-kibana/)和
[此处](https://kubernetes.io/docs/tasks/debug-application-cluster/logging-elasticsearch-kibana/)所述的插件,
或其他定制化的相关程序。这可能配置为将日志发送到 Elasticsearch 系统或日志收集程序。
您可以使用这些 Fluentd 守护程序或任何其他已设置的 Fluentd 守护程序,只要它们正在侦听转发的日志,
并且 Istio 的 Mixer 可以连接到它们。为了使 Mixer 连接到正在运行的 Fluentd 守护程序,您可能需要为 Fluentd 添加 [service](https://kubernetes.io/docs/concepts/services-networking/service/)。
以下是侦听转发日志的 Fluentd 配置:
{{< text xml >}}
<source>
type forward
</source>
{{< /text >}}
将 Mixer 连接到所有可能的 Fluentd 配置的完整细节不在此任务的讨论范围。
### 示例堆栈 Fluentd、Elasticsearch、Kibana{#example-Fluentd-Elasticsearch-Kibana-Stack}
出于此任务的目的,您可以部署提供的示例堆栈。该堆栈包括 FluentdElasticsearch 和 Kibana
它们位于非生产就绪的一组 [Services](https://kubernetes.io/docs/concepts/services-networking/service/) 和 [Deployments](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/) 中,
其全部部署到一个名为 `logging` 的新 [Namespace](https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/) 中。
将以下内容另存为 `logging-stack.yaml`
{{< text yaml >}}
# Logging Namespace. All below are a part of this namespace.
apiVersion: v1
kind: Namespace
metadata:
name: logging
---
# Elasticsearch Service
apiVersion: v1
kind: Service
metadata:
name: elasticsearch
namespace: logging
labels:
app: elasticsearch
spec:
ports:
- port: 9200
protocol: TCP
targetPort: db
selector:
app: elasticsearch
---
# Elasticsearch Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: elasticsearch
namespace: logging
labels:
app: elasticsearch
spec:
replicas: 1
selector:
matchLabels:
app: elasticsearch
template:
metadata:
labels:
app: elasticsearch
annotations:
sidecar.istio.io/inject: "false"
spec:
containers:
- image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.1.1
name: elasticsearch
resources:
# need more cpu upon initialization, therefore burstable class
limits:
cpu: 1000m
requests:
cpu: 100m
env:
- name: discovery.type
value: single-node
ports:
- containerPort: 9200
name: db
protocol: TCP
- containerPort: 9300
name: transport
protocol: TCP
volumeMounts:
- name: elasticsearch
mountPath: /data
volumes:
- name: elasticsearch
emptyDir: {}
---
# Fluentd Service
apiVersion: v1
kind: Service
metadata:
name: fluentd-es
namespace: logging
labels:
app: fluentd-es
spec:
ports:
- name: fluentd-tcp
port: 24224
protocol: TCP
targetPort: 24224
- name: fluentd-udp
port: 24224
protocol: UDP
targetPort: 24224
selector:
app: fluentd-es
---
# Fluentd Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: fluentd-es
namespace: logging
labels:
app: fluentd-es
spec:
replicas: 1
selector:
matchLabels:
app: fluentd-es
template:
metadata:
labels:
app: fluentd-es
annotations:
sidecar.istio.io/inject: "false"
spec:
containers:
- name: fluentd-es
image: gcr.io/google-containers/fluentd-elasticsearch:v2.0.1
env:
- name: FLUENTD_ARGS
value: --no-supervisor -q
resources:
limits:
memory: 500Mi
requests:
cpu: 100m
memory: 200Mi
volumeMounts:
- name: config-volume
mountPath: /etc/fluent/config.d
terminationGracePeriodSeconds: 30
volumes:
- name: config-volume
configMap:
name: fluentd-es-config
---
# Fluentd ConfigMap, contains config files.
kind: ConfigMap
apiVersion: v1
data:
forward.input.conf: |-
# Takes the messages sent over TCP
<source>
type forward
</source>
output.conf: |-
<match **>
type elasticsearch
log_level info
include_tag_key true
host elasticsearch
port 9200
logstash_format true
# Set the chunk limits.
buffer_chunk_limit 2M
buffer_queue_limit 8
flush_interval 5s
# Never wait longer than 5 minutes between retries.
max_retry_wait 30
# Disable the limit on the number of retries (retry forever).
disable_retry_limit
# Use multiple threads for processing.
num_threads 2
</match>
metadata:
name: fluentd-es-config
namespace: logging
---
# Kibana Service
apiVersion: v1
kind: Service
metadata:
name: kibana
namespace: logging
labels:
app: kibana
spec:
ports:
- port: 5601
protocol: TCP
targetPort: ui
selector:
app: kibana
---
# Kibana Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: kibana
namespace: logging
labels:
app: kibana
spec:
replicas: 1
selector:
matchLabels:
app: kibana
template:
metadata:
labels:
app: kibana
annotations:
sidecar.istio.io/inject: "false"
spec:
containers:
- name: kibana
image: docker.elastic.co/kibana/kibana-oss:6.1.1
resources:
# need more cpu upon initialization, therefore burstable class
limits:
cpu: 1000m
requests:
cpu: 100m
env:
- name: ELASTICSEARCH_URL
value: http://elasticsearch:9200
ports:
- containerPort: 5601
name: ui
protocol: TCP
---
{{< /text >}}
创建资源:
{{< text bash >}}
$ kubectl apply -f logging-stack.yaml
namespace "logging" created
service "elasticsearch" created
deployment "elasticsearch" created
service "fluentd-es" created
deployment "fluentd-es" created
configmap "fluentd-es-config" created
service "kibana" created
deployment "kibana" created
{{< /text >}}
## 配置 Istio{#configure-Istio}
现在有了一个正在运行的 Fluentd 守护进程,用一个新的日志类型配置 Istio并将这些日志发送到侦听守护进程。
应用配置 Istio 自动生成和收集日志流的 YAML 文件:
{{< text bash >}}
$ kubectl apply -f @samples/bookinfo/telemetry/fluentd-istio.yaml@
{{< /text >}}
{{< warning >}}
如果您使用的是 Istio 1.1.2 或更早版本,请改用以下配置:
{{< text bash >}}
$ kubectl apply -f @samples/bookinfo/telemetry/fluentd-istio-crd.yaml@
{{< /text >}}
{{< /warning >}}
请注意,处理程序配置中的 `address: "fluentd-es.logging:24224"` 指向我们在示例堆栈中设置的 Fluentd 守护程序。
## 查看新日志{#view-the-new-logs}
1. 将流量发送到示例应用程序。
对于 [Bookinfo](/zh/docs/examples/bookinfo/#determine-the-ingress-IP-and-port) 示例,
请在您的浏览器中访问 `http://$GATEWAY_URL/productpage`,或使用以下命令在命令行中发送请求:
{{< text bash >}}
$ curl http://$GATEWAY_URL/productpage
{{< /text >}}
1. 在 Kubernetes 环境中,通过执行以下命令来设置 Kibana 的端口转发:
{{< text bash >}}
$ kubectl -n logging port-forward $(kubectl -n logging get pod -l app=kibana -o jsonpath='{.items[0].metadata.name}') 5601:5601 &
{{< /text >}}
运行命令以可以访问 Kibana UI当完成访问时注意在命令行中用 Ctrl-C 退出。
1. 导航到 [Kibana UI](http://localhost:5601/)然后单击右上角的“Set up index patterns”。
1. 使用 `*` 指标类型然后单击“Next step”。
1. 选择 `@timestamp` 作为“时间过滤器”字段名称然后单击“Create index pattern”。
1. 现在单击左侧菜单上的“Discover”然后开始浏览生成的日志。
## 清除{#cleanup}
* 删除新的遥测配置:
{{< text bash >}}
$ kubectl delete -f @samples/bookinfo/telemetry/fluentd-istio.yaml@
{{< /text >}}
如果您使用的是 Istio 1.1.2 或更早版本:
{{< text bash >}}
$ kubectl delete -f @samples/bookinfo/telemetry/fluentd-istio-crd.yaml@
{{< /text >}}
* 删除示例堆栈 Fluentd、Elasticsearch 和 Kibana:
{{< text bash >}}
$ kubectl delete -f logging-stack.yaml
{{< /text >}}
* 删除所有可能仍在运行的 `kubectl port-forward` 进程:
{{< text bash >}}
$ killall kubectl
{{< /text >}}
* 如果您不打算继续探索后续任务,请参考 [Bookinfo 清除](/zh/docs/examples/bookinfo/#cleanup)以关闭应用程序。