Automation Suite
2023.10
False
横幅背景图像
EKS/AKS 上的 Automation Suite 安装指南
上次更新日期 2024年5月20日

将机器人日志保存到 Elasticsearch

Orchestrator 默认设置为将机器人日志存储在数据库中。 但是,如果您想将此存储切换到 Elasticsearch,则可以使用基本配置流程:只需提供所需的 URL、用户名和密码。 此设置足以满足大多数用例。 要进一步自定义,您可以在基本设置的基础上利用高级配置机制。

基本配置

如果选择此配置,则允许将机器人日志写入 Elasticsearch 目标而不是数据库,并设置 Orchestrator 以从 Elasticsearch 检索日志。

您可以通过编辑 input.json 文件将机器人日志配置为保存到 Elasticsearch 服务器。

基本配置支持 Elasticsearch 版本 7.x。 对于 Elasticsearch 8.x,您需要使用高级配置。

下表列出了 orchestrator.orchestrator_robot_logs_elastic 参数:

参数

描述

orchestrator_robot_logs_elastic

Elasticsearch 部分配置。 这包含以下属性: uriusernamepassword

elastic_uri

应使用的 Elasticsearch 实例的地址。应以 URI 的形式提供。如已提供,则还需要用户名和密码。

elastic_auth_username

用于身份验证的 Elasticsearch 用户名。

elastic_auth_password

用于身份验证的 Elasticsearch 密码。

通过 uipathctl 安装程序应用配置

更新 input.json 以在 orchestrator下添加 orchestrator_robot_logs_elastic 部分。
{
    ...
    "orchestrator": {
        ...
        "orchestrator_robot_logs_elastic": {
            "elastic_uri": "uri",
            "elastic_auth_username": "user",
            "elastic_auth_password": "pass"
        }
        ...
    }
    ...
}{
    ...
    "orchestrator": {
        ...
        "orchestrator_robot_logs_elastic": {
            "elastic_uri": "uri",
            "elastic_auth_username": "user",
            "elastic_auth_password": "pass"
        }
        ...
    }
    ...
}
要运行 uipathctl 安装程序以应用配置,请使用以下命令:
uipathctl manifest apply input.json --only orchestrator --versions versions.jsonuipathctl manifest apply input.json --only orchestrator --versions versions.json

高级配置

要访问高级配置设置,您必须先完成基本配置。此流程允许您自定义与 Elasticsearch 通信的 NLog 目标的属性。但是,重定向机器人日志需要其他设置。这些必要的调整会由基本配置执行。

重要提示:

按照以下步骤进行的任何更改都可能对整个系统的功能和稳定性产生负面影响。 建议您仅在了解更改后果的情况下进行更改。

高级配置允许您完全自定义 NLog.config 目标:

  1. 请遵循 基本配置 步骤。

  2. 编辑 nlog.json 示例参数,以使用所需的配置更新 robotElasticBuffer 目标。 有关 nlog.json的示例,请参阅以下部分。
  3. 更新 nlog.json 参数:
    uipathctl config orchestrator update-config --nlog-config nlog.jsonuipathctl config orchestrator update-config --nlog-config nlog.json

nlog.json

Orchestrator 包含一个用于机器人日志的预设 NLog 目标,称为 robotElasticBuffer。 您可以使用自定义 nlog.json 文件修改此目标的任何属性。 无需提供完整的目标配置;而是仅添加或更新所需的值。

Elasticsearch 7.x 配置示例

您可以跳过 urirequireAuthusernamepassword 字段的配置,因为它们已经在基本配置步骤中设置好了。
{
  "Nlog": {
    "targets": {
      "robotElasticBuffer": {
        "flushTimeout": 1000,
        "bufferSize": 1000,
        "slidingTimeout": false,
        "target": {
          "uri": "https://elastic.example.com:9200",
          "requireAuth": true,
          "username": "elastic-user",
          "password": "elastic-password",
          "index": "${event-properties:item=indexName}-${date:format=yyyy.MM}",
          "documentType": "logEvent",
          "includeAllProperties": true,
          "layout": "${message}",
          "excludedProperties": "agentSessionId,tenantId,indexName"
        }
      }
    }
  }
}{
  "Nlog": {
    "targets": {
      "robotElasticBuffer": {
        "flushTimeout": 1000,
        "bufferSize": 1000,
        "slidingTimeout": false,
        "target": {
          "uri": "https://elastic.example.com:9200",
          "requireAuth": true,
          "username": "elastic-user",
          "password": "elastic-password",
          "index": "${event-properties:item=indexName}-${date:format=yyyy.MM}",
          "documentType": "logEvent",
          "includeAllProperties": true,
          "layout": "${message}",
          "excludedProperties": "agentSessionId,tenantId,indexName"
        }
      }
    }
  }
}

Elasticsearch 8.x 配置示例

您可以跳过 urirequireAuthusernamepassword 字段的配置,因为它们已经在基本配置步骤中设置好了。
{
  "Nlog": {
    "targets": {
      "robotElasticBuffer": {
        "flushTimeout": 1000,
        "bufferSize": 1000,
        "slidingTimeout": false,
        "target": {
          "uri": "https://elastic.example.com:9200",
          "requireAuth": true,
          "username": "elastic-user",
          "password": "elastic-password",
          "index": "${event-properties:item=indexName}-${date:format=yyyy.MM}",
          "documentType": "",
          "includeAllProperties": true,
          "layout": "${message}",
          "excludedProperties": "agentSessionId,tenantId,indexName"
        }
      }
    }
  }
}{
  "Nlog": {
    "targets": {
      "robotElasticBuffer": {
        "flushTimeout": 1000,
        "bufferSize": 1000,
        "slidingTimeout": false,
        "target": {
          "uri": "https://elastic.example.com:9200",
          "requireAuth": true,
          "username": "elastic-user",
          "password": "elastic-password",
          "index": "${event-properties:item=indexName}-${date:format=yyyy.MM}",
          "documentType": "",
          "includeAllProperties": true,
          "layout": "${message}",
          "excludedProperties": "agentSessionId,tenantId,indexName"
        }
      }
    }
  }
}

管理 Orchestrator 自定义配置

本节提供有关如何向 Orchestrator 提供自定义配置的其他信息。

当现有配置方案不足以满足所需的用例时,还有另一种方法可以更改 Orchestrator 配置: uipathctl config orchestrator

Orchestrator 配置

appsettings 或 NLog 的 Orchestrator 配置是从依次加载的多个配置文件中加载的。 每个新加载的文件都会覆盖以前的密钥。 文件的加载顺序为:
  • Orchestrator 映像中的内置配置文件

  • orchestrator 配置映射
  • orchestrator 密码
  • orchestrator-customconfig 配置映射
NLog 的内置配置文件包含用于将机器人日志写入数据库的目标,并将 NLog 机器人日志规则配置为使用此目标。 内置的 appsettings 文件将 Orchestrator 配置为在需要显示机器人日志时从此目标读取机器人日志。 NLog 内置配置文件还包含 robotElasticBuffer 目标,该目标已部分配置且未使用。
orchestrator 配置映射和密码由 ArgoCD 通过 Helm 图表管理。 每次 ArgoCD 同步应用程序时,都会使用 orchestrator ArgoCD 应用程序的当前参数和值重新生成这些配置。
当基本配置启用 Elasticsearch 时,将更改 argo 参数,并更新 orchestrator 配置映射和密码,以提供启用 robotElasticBuffer所需的最终配置。
高级配置意味着在 orchestrator-customconfig 配置映射中添加覆盖。 每个新值或修改的值都会合并到现有配置中,但无法删除值(可以将它们设置为空,但不要完全删除)。

NLog 默认配置

Orchestrator 为 NLog 提供的默认配置包括预配置的 robotElasticBuffer 目标。
{
  "NLog": {
    "targets": {
      "robotElasticBuffer": {
        "type": "BufferingWrapper",
        "flushTimeout": 5000,
        "target": {
          "type": "ElasticSearch",
          "name": "robotElastic",
          "requireAuth": false,
          "uri": "",
          "username": "",
          "password": "",
          "index": "${event-properties:item=indexName}-${date:format=yyyy.MM}",
          "documentType": "logEvent",
          "includeAllProperties": true,
          "layout": "${message}",
          "excludedProperties": "agentSessionId,tenantId,indexName"
        }
      },
    }
  }
}{
  "NLog": {
    "targets": {
      "robotElasticBuffer": {
        "type": "BufferingWrapper",
        "flushTimeout": 5000,
        "target": {
          "type": "ElasticSearch",
          "name": "robotElastic",
          "requireAuth": false,
          "uri": "",
          "username": "",
          "password": "",
          "index": "${event-properties:item=indexName}-${date:format=yyyy.MM}",
          "documentType": "logEvent",
          "includeAllProperties": true,
          "layout": "${message}",
          "excludedProperties": "agentSessionId,tenantId,indexName"
        }
      },
    }
  }
}

通过 uipathctl 自定义配置

要查看有关更新 Orchestrator 自定义配置的更多信息,请运行以下命令:

uipathctl config orchestrator --helpuipathctl config orchestrator --help

输出:

Configure orchestrator custom config

Usage:
  uipathctl config orchestrator [command]

Available Commands:
  get-config    Get the current orchestrator custom config
  update-config Update orchestrator config

Flags:
  -h, --help   help for orchestrator

Global Flags:
      --context string      name of the kubeconfig context to use
      --kubeconfig string   kubectl configuration file (default: ~/.kube/config)
      --log-format string   log format. one of [text,json] (default "text")
      --log-level string    set log level. one of [trace,debug,info,error] (default "error")
  -q, --quiet               suppress all output except for errors and warnings
      --timeout duration    timeout of the command (default 1h0m0s)Configure orchestrator custom config

Usage:
  uipathctl config orchestrator [command]

Available Commands:
  get-config    Get the current orchestrator custom config
  update-config Update orchestrator config

Flags:
  -h, --help   help for orchestrator

Global Flags:
      --context string      name of the kubeconfig context to use
      --kubeconfig string   kubectl configuration file (default: ~/.kube/config)
      --log-format string   log format. one of [text,json] (default "text")
      --log-level string    set log level. one of [trace,debug,info,error] (default "error")
  -q, --quiet               suppress all output except for errors and warnings
      --timeout duration    timeout of the command (default 1h0m0s)
注意: 高级配置还支持 Elasticsearch 8.x。
  • 基本配置
  • 通过 uipathctl 安装程序应用配置
  • 高级配置
  • nlog.json
  • 管理 Orchestrator 自定义配置

此页面是否有帮助?

获取您需要的帮助
了解 RPA - 自动化课程
UiPath Community 论坛
Uipath 白色徽标
信任与安全
© 2005-2024 UiPath. All rights reserved.