配置日志管理

WhizardTelemetry 日志支持通过配置扩展组件实现收集指定日志、按项目创建日志索引等功能。

说明

更多配置信息,请参阅扩展中心 “WhizardTelemetry 日志”扩展组件的详情页说明。

收集指定日志

WhizardTelemetry 日志支持设置过滤条件,以收集包含或排除指定 namespace 的日志,可减少日志数量。

在 WhizardTelemetry 日志的扩展组件配置中,编辑如下参数:

vector-logging:
  filter:
    extraLabelSelector: "app.kubernetes.io/name!=kube-events-exporter"
    extraNamespaceLabelSelector: ""
    # When includeNamespaces and excludeNamespaces are set at the same time, only excludeNamespaces will take effect.
    includeNamespaces: []
    excludeNamespaces: []
  • extraLabelSelector:只收集带此标签的 pod 的日志。

  • extraNamespaceLabelSelector:只收集带此标签的 namespace 下的 pod 日志。

  • includeNamespaces:只收集指定 namespace 下的 pod 日志。

  • excludeNamespaces:不收集指定 namespace 下的 pod 日志。

按照 namespace 创建日志索引

WhizardTelemetry 日志支持为每个项目(namespace)创建一个索引,既可确定某个 namespace 的日志占用空间,方便整改业务,又便于进行日志分析。

前提条件

版本要求:WhizardTelemetry 日志 >= 1.2.0,WhizardTelemetry 平台服务 >= 1.1.0。

操作步骤

  1. 修改 WhizardTelemetry 日志扩展组件配置。无需修改 prefix 中的参数。

    vector-logging:
      sinks:
        opensearch:
          index:
            prefix: "{{ .cluster }}-{{ .kubernetes.namespace_name }}-logs"
            timestring: "%Y.%m.%d"
  2. 修改 WhizardTelemetry 平台服务扩展组件配置。无需修改 indexPrefix 中的参数。

    whizard-telemetry:
      config:
        logging:
          enable: true
          servers:
            - elasticsearch:
                endpoints:
                  - https://opensearch-cluster-data.kubesphere-logging-system:9200
                indexPrefix: "{{ .cluster }}-{{ .kubernetes.namespace_name }}-logs"
                timestring: "%Y.%m.%d"

通过邮件接收 KubeSphere 最新的技术博客与产品更新的通知


感谢您的反馈。如果您有关于如何使用 KubeSphere 的具体问题,请在 Slack 上提问。如果您想报告问题或提出改进建议,请在 GitHub 存储库中打开问题。