Automation Suite
2022.10
バナーの背景画像
Automation Suite インストール ガイド
最終更新日 2024年4月24日

アプリケーション ログを Splunk に転送する

注:
  • このセクションでは、POD ログのエクスポートについて説明します。ロボット ログをエクスポートする方法については、『Orchestrator ガイド』の「ログについて」をご覧ください。

  • Splunk は外部ツールであり、UiPath® から Splunk の設定内容について指示することはできません。HTTP イベント コレクターの詳細については、Splunk の公式ドキュメントをご覧ください。

Splunk-Fluentd スタックは、ログ データの検索、分析、可視化を可能にする一元化されたログ ソリューションです。Fluentd はログを収集して Splunk に送信します。Splunk はログを取得し、データの可視化や分析を可能にします。

Splunk を構成するには、次の手順に従います。

  1. 上部のナビゲーション バーの [設定] をクリックし、[インデックス] を選択します。


  2. [新規インデックス] をクリックしてから、[保存] をクリックしてインデックスを作成します。




  3. 上部のナビゲーション バーの [設定] をクリックし、[データ入力] を選択します。


  4. [HTTP イベントコレクタ] をクリックします。


  5. 新しいトークンの作成を有効化するには、[グローバル設定] をクリックします。


  6. 有効化して、[グローバル設定] を保存します。


  7. トークンを作成するには、[新規トークン] をクリックします。


  8. HTTP イベント コレクターの名前を入力し、[次へ] をクリックします。


  9. [新規] をクリックして、ソース タイプの詳細を入力します。


  10. 下にスクロールして、利用可能なインデックスのリストからインデックスを選択し、上部のナビゲーション バーで [次へ] をクリックします。


  11. データを検証して、[実行] をクリックします。


  12. 作成されたら、トークン IDインデックスソースソース タイプの詳細を取得します。これらの値は ClusterOutput を設定するために必要になります。


トークンを含むシークレットを作成する

Splunk の UI で生成した 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

ClusterOutput でログの送信先を定義します。また、構成と認証の詳細も記述します。

Splunk の ClusterOutput を構成するには、次のコマンドを実行します。

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>
EOFkubectl -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
注: 角括弧 < > で囲まれた属性を、Splunk 構成で使用されている対応する値に置き換えます。詳しくは、以下の表をご覧ください。

属性

説明

splunk_hec_host

Splunk インスタンスのネットワーク ホストです。通常は、Splunk の IP アドレスまたは FQDN です。

splunk_hec_port

クライアント通信用の Splunk ポートです。通常、このポートは Splunk のダッシュボードを起動するポートとは異なります。Splunk で一般的に使われる HEC ポートは 8088 です。

secret_key

Splunk トークンのシークレット キーです。これは前の手順で作成したシークレットのキーの名前で、ここに Splunk HEC トークンが保持されています。

提示されたマニフェストには、既にキー splunk_hec_token が含まれています。シークレットを作成するコマンドを変更していない場合、この値を変更する必要はありません。
splunk_hec_timekey 値、次の属性内: splunkHec.buffer
出力頻度、つまりログをプッシュする頻度です。30 秒 (30s) の間隔を使用することをお勧めします。

protocol

URL プロトコルです。有効な値は http および https です。Splunk で SSL 通信を有効化している場合は、HTTPS プロトコルを使用する必要があります。

splunk_hec_index

Splunk インデックスの識別子です。イベントのインデックス作成に使用します。

splunk_hec_source

イベントのソース フィールドです。

splunk_hec_source_type

イベントのソースの種類のフィールドです。

次の例は、このページで示す構成を基にしています。



FluentD 内の ClusterFlow

ClusterFlow を使用して、以下を定義します。
  • 収集およびフィルター処理するログ
  • ログの送信先の ClusterOutput です。

Fluentd に ClusterFlow を構成するには、次のコマンドを実行します。

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:
        longhorn.io/job-task: backup
  - exclude:
      labels:
        app: csi-resizer
  - select: {}
EOFkubectl -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:
        longhorn.io/job-task: backup
  - exclude:
      labels:
        app: csi-resizer
  - select: {}
EOF

Splunk で検索する

  1. [サーチとレポート] をクリックします。



  2. SourceIndexSourceType に基づいて検索します。





トラブルシューティング

何らかの理由でアプリケーション ログが Splunk にプッシュされない場合は、以下を試してください。

  1. Fluentd のログ レベルを debug に変更します。
  2. Fluentd ポッドに以下のクエリを実行する
    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/outkubectl 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"}]'

Was this page helpful?

サポートを受ける
RPA について学ぶ - オートメーション コース
UiPath コミュニティ フォーラム
UiPath ロゴ (白)
信頼とセキュリティ
© 2005-2024 UiPath. All rights reserved.