UiPath Documentation
automation-suite
2023.10
false
Linux 版 Automation Suite 安装指南
重要 :
新发布内容的本地化可能需要 1-2 周的时间才能完成。

如何将应用程序日志转发到 Splunk

将 Automation Suite 2023.10.6 版及更早版本的应用程序日志转发到 Splunk。

备注:

Splunk-Fluentd 堆栈是一个集中式日志记录解决方案,可用于搜索、分析和可视化日志数据。Fluentd 收集日志并将其发送到 Splunk。Splunk 会检索日志,并让您可视化和分析数据。

要配置 Splunk,请执行以下步骤:

  1. Select Settings in the top navigation bar, and then select Indexes.

  2. Select New Index and then Create an index.

  3. Select Settings in the top navigation bar, and then select Data inputs.

  4. 选择“HTTP 事件收集器”

  5. To enable the new token creation, select Global Settings.

  6. 启用并保存“全局设置”。

  7. To create the token, select New Token.

  8. Enter a name for the HTTP Event Collector and select Next.

  9. Select New and enter Source Type details.

  10. Scroll down and select Index from the available list of indexes, and select Next in the top navigation bar.

  11. Verify the data and select Submit.

  12. 创建后,获取令牌 ID索引来源来源类型的详细信息。您需要这些值来设置“集群输出”。

使用令牌创建密码

使用 Splunk 用户界面中生成的 HTTP 事件收集器 (HEC) 令牌创建 Kubernetes 密码。此令牌用于 Automation Suite 和 Splunk 之间的身份验证。

kubectl -n cattle-logging-system create secret generic splunk-hec-token --from-literal=splunk_hec_token=<splunk_hec_token>
kubectl -n cattle-logging-system create secret generic splunk-hec-token --from-literal=splunk_hec_token=<splunk_hec_token>

集群输出到 Splunk

ClusterOutput 定义日志的接收方,并描述配置和身份验证详细信息。

要为 Splunk 配置集群输出,请运行以下命令:

kubectl -n cattle-logging-system apply -f - <<"EOF"
apiVersion: logging.banzaicloud.io/v1beta1
kind: ClusterOutput
metadata:
  name: splunk-output
spec:
  splunkHec:
    buffer:
      tags: '[]'
      timekey: <splunk_hec_timekey>
      timekey_use_utc: true
      timekey_wait: 10s
      type: file
    hec_host: <splunk_hec_host>
    hec_port: <splunk_hec_port>
    hec_token:
      valueFrom:
        secretKeyRef:
          key: splunk_hec_token
          name: splunk-hec-token
    index: <splunk_hec_index>
    insecure_ssl: true
    protocol: <splunk_hec_protocol>
    source: <splunk_hec_source>
    sourcetype: <splunk_hec_source_type>
EOF
kubectl -n cattle-logging-system apply -f - <<"EOF"
apiVersion: logging.banzaicloud.io/v1beta1
kind: ClusterOutput
metadata:
  name: splunk-output
spec:
  splunkHec:
    buffer:
      tags: '[]'
      timekey: <splunk_hec_timekey>
      timekey_use_utc: true
      timekey_wait: 10s
      type: file
    hec_host: <splunk_hec_host>
    hec_port: <splunk_hec_port>
    hec_token:
      valueFrom:
        secretKeyRef:
          key: splunk_hec_token
          name: splunk-hec-token
    index: <splunk_hec_index>
    insecure_ssl: true
    protocol: <splunk_hec_protocol>
    source: <splunk_hec_source>
    sourcetype: <splunk_hec_source_type>
EOF
备注:

将尖括号&lt; &gt;之间的属性替换为 Splunk 配置中使用的相应值。 有关详细信息,请参见下表:

属性描述
splunk_hec_hostSplunk 实例的网络主机。 这通常是 Splunk 的 IP 地址或 FQDN。
splunk_hec_port用于客户端通信的 Splunk 端口。 此端口通常与启动 Splunk 仪表板的端口不同。 Splunk 的传统 HEC 端口为8088
secret_keySplunk 令牌的密钥。这是您在上一步中创建的密码中密钥的名称,用于保存 Splunk HEC 令牌。提供的清单已包含以下密钥: splunk_hec_token 。如果尚未更改创建密码的命令,则无需更改此值。
splunk_hec_timekey 中的值 splunkHec.buffer输出频率,或您希望推送日志的频率。 我们建议使用 30 秒 ( 30s ) 间隔。
protocolURL 协议。 有效值为httphttps 。 如果在 Splunk 上启用了 SSL 通信,则必须使用 HTTPS 协议。
splunk_hec_indexSplunk 索引的标识符。 用于为事件编制索引。
splunk_hec_source事件的来源字段。
splunk_hec_source_type事件的来源类型字段。

以下示例基于此页面上显示的配置。

FluentD 中的集群流程

使用ClusterFlow定义:

  • 要收集和筛选的日志;
  • 用于接收日志的 ClusterOutput

要在 Fluentd 中配置“集群流程” ,请运行以下命令:

kubectl -n cattle-logging-system apply -f - <<"EOF"
apiVersion: logging.banzaicloud.io/v1beta1
kind: ClusterFlow
metadata:
  name: splunk-flow
  namespace: cattle-logging-system
spec:
  filters:
  - tag_normaliser:
      format: ${namespace_name}/${pod_name}.${container_name}
  globalOutputRefs:
  - splunk-output
  match:
  - select:
      container_names:
      - istio-proxy
      namespaces:
      - istio-system
  - exclude:
      container_names:
      - istio-proxy
      - istio-init
      - aicenter-hit-count-update
      - istio-configure-executor
      - on-prem-tenant-license-update
      - curl
      - recovery
      - aicenter-oob-scheduler
      - cert-trustor
  - exclude:
      namespaces:
      - fleet-system
      - cattle-gatekeeper-system
      - default
  - exclude:
      labels:
        app: csi-snapshotter
  - exclude:
      labels:
        app: csi-resizer
  - select: {}
EOF
kubectl -n cattle-logging-system apply -f - <<"EOF"
apiVersion: logging.banzaicloud.io/v1beta1
kind: ClusterFlow
metadata:
  name: splunk-flow
  namespace: cattle-logging-system
spec:
  filters:
  - tag_normaliser:
      format: ${namespace_name}/${pod_name}.${container_name}
  globalOutputRefs:
  - splunk-output
  match:
  - select:
      container_names:
      - istio-proxy
      namespaces:
      - istio-system
  - exclude:
      container_names:
      - istio-proxy
      - istio-init
      - aicenter-hit-count-update
      - istio-configure-executor
      - on-prem-tenant-license-update
      - curl
      - recovery
      - aicenter-oob-scheduler
      - cert-trustor
  - exclude:
      namespaces:
      - fleet-system
      - cattle-gatekeeper-system
      - default
  - exclude:
      labels:
        app: csi-snapshotter
  - exclude:
      labels:
        app: csi-resizer
  - select: {}
EOF

在 Splunk 中搜索

  1. 选择“搜索和报告”

  2. 按照来源索引来源类型进行搜索。

故障排除

如果由于某种原因未将应用程序日志推送到 Splunk,请执行以下步骤:

  1. 将 Fluentd 日志级别更改为“调试”。
  2. 查询 Fluentd Pod:
    kubectl patch loggings.logging.banzaicloud.io rancher-logging-root --type=json -p '[{"op":"add","path":"/spec/fluentd/logLevel","value":debug}]'
    kubectl -n cattle-logging-system exec -it sts/rancher-logging-root-fluentd cat /fluentd/log/out
    kubectl patch loggings.logging.banzaicloud.io rancher-logging-root --type=json -p '[{"op":"add","path":"/spec/fluentd/logLevel","value":debug}]'
    kubectl -n cattle-logging-system exec -it sts/rancher-logging-root-fluentd cat /fluentd/log/out
    
    备注:

    Fluentd 日志应指明数据未推送到 Splunk 的原因。

  3. 修复问题后,恢复 Fluentd 日志 级别:
    kubectl patch loggings.logging.banzaicloud.io rancher-logging-root --type=json -p '[{"op":"remove","path":"/spec/fluentd/logLevel"}]'
    kubectl patch loggings.logging.banzaicloud.io rancher-logging-root --type=json -p '[{"op":"remove","path":"/spec/fluentd/logLevel"}]'
    

此页面有帮助吗?

连接

需要帮助? 支持

想要了解详细内容? UiPath Academy

有问题? UiPath 论坛

保持更新