配置代理收集的日志文件
部署或升级日志代理时,可以配置 logs-values.yaml 文件,以包含或排除代理要处理的日志集。 默认情况下,代理将从 /var/log/containers/*.log 收集日志,并忽略 /var/log/at/*。
修改 logs-values.yaml 后,可以 升级代理 或在应用所有更改前继续修改文件。
配置自定义日志文件
可提供以下附加变量,用于包含或排除要由代理处理的日志集:
excludeLogSourcePaths:代理被配置为忽略的文件列表。 defailt 值设置为忽略/var/log/at/*selectedLogSourcePaths:代理收集并发送至 IBM Cloud Logs 的文件列表。 默认值设置为/var/log/containers/*.log。 您可以使用逗号分隔的列表定义多个路径,例如/var/log/abc/*.log,/var/log/xyz/*.log。
logs-values.yaml 文件中的条目如下:
# comma separated list, for example “/var/log/abc/*.log,/var/log/xyz/*.log”
excludeLogSourcePaths: ""
selectedLogSourcePaths: ""
配置系统组件日志
系统组件日志记录群集中发生的事件。 系统组件有两类:在容器中运行的系统组件和直接参与运行容器的系统组件。 例如,kubelet 和容器运行时并不在容器中运行。 Kubernetes 调度器、控制器管理器和 API 服务器在 pod 中运行。 如果您的集群使用 kube-proxy,则通常将其作为 DaemonSet 运行。
使用 systemLogs 设置可启用对位于 /var/log 目录中的系统组件日志的处理。 /var/log/containers/ 中的系统日志是自动收集的,除非您在 excludeLogSourcePaths 部分将其排除在外。
logs-values.yaml 文件中的条目如下:
systemLogs:
- /var/log/kube-apiserver.log. # Logs generated by the API server.
- /var/log/kube-scheduler.log # Logs generated by the scheduler. This component is responsible for making scheduling decisions.
- /var/log/kube-controller-manager.log # Logs generated by the Kube controller manager that runs most Kubernetes built-in controllers.
- /var/log/kube-proxy.log # Logs generated by the kube-proxy. This component is responsible for directing traffic to Service endpoints.
- /var/log/kubelet.log # Logs generated by the kubelet. This component is responsible for running containers on the node.
- /var/log/syslog
默认情况下,使用 kube_syslog 解析器。
一些传统的 Kubernetes 集群可能需要将 systemLogsParser 设置为 kube_syslog_classic,以便与这些系统上的时间戳格式相匹配。 您可以使用 systemLogsParser 选项来选择不同的解析器。 logs-values.yaml 文件中的条目如下:
systemLogsParser: "kube_syslog_classic"
systemLogs:
- /var/log/syslog