automation-suite
2.2510
true
OpenShift 上的 Automation Suite 安装指南
重要 :
请注意,此内容已使用机器翻译进行了部分本地化。
新发布内容的本地化可能需要 1-2 周的时间才能完成。
配置 NLog
添加 NLog 扩展程序并在 OpenShift 上的 Orchestrator 中配置高级日志记录目标。
添加 NLog 扩展程序
Orchestrator 默认加载以下扩展程序,因此您无需将其包含在文件夹或 NLog 配置中:
NLog.Targets.ElasticSearchUiPath.Orchestrator.Logs.ElasticsearchMicrosoft.ApplicationInsights.NLogTargetNLog.Extensions.AzureEventHub
在此设置中,只能使用与 Linux 兼容的扩展程序,因此请确保您选择的 NLog 扩展程序遵守此规则。
要使扩展程序可用,必须将其上传到集群存储。uipathctl命令行工具可以通过uipathctl config orchestrator upload命令执行此操作:
uipathctl config orchestrator upload --nlog-extensions-directory /path/to/extensions/directory
uipathctl config orchestrator upload --nlog-extensions-directory /path/to/extensions/directory
如果在集群级别使用外部存储配置,则必须通过包含 --is-external-storage 参数来指明这一点。
高级 NLog 配置
创建高级 NLog 配置
-
创建包含以下标准部分的
nlog.config.json文件:扩展程序、目标和规则。扩展程序部分是一个项目数组,通过
assemblyFile和程序集的路径指定扩展程序集。如果加载了自定义 nlog 插件(如添加 NLog 扩展程序部分中所述),则将在
extensions部分中引用这些插件。 -
在
nlog.config.json文件中配置目标和规则。 -
使用
uipathctl命令行工具应用nlog.config.json文件:uipathctl config orchestrator update-config --nlog-config nlog.config.jsonuipathctl config orchestrator update-config --nlog-config nlog.config.json重要提示:此操作将覆盖现有的自定义 NLog 配置。您可以使用以下命令来检查现有配置:
uipathctl config orchestrator get-config --nlog-configuipathctl config orchestrator get-config --nlog-config
将日志写入 Azure Blob 的 nlog.config.json 文件示例:
{ "NLog": {
"extensions": [
{ "assemblyFile": "NLog.Extensions.AzureBlobStorage.dll" }
],
"targets": {
"azureBlob": {
"type": "AzureBlobStorage",
"connectionString": "DefaultEndpointsProtocol=https;AccountName=test;AccountKey=key;EndpointSuffix=core.windows.net",
"container": "orchestratorlogs",
"blobName": "${date:format=yyyy-MM-dd hh.mm}",
"layout": {
"type": "JsonLayout",
"includeAllProperties": true,
"Attributes": [
{"name": "ts","layout": "${longdate}"},
{"name": "level","layout": "${level:upperCase=true}"},
{"name": "logger","layout": "${logger}"},
{"name": "message","layout": "${message}"},
{"name": "exception","layout": "${onexception:${ui-pretty-exception}}"}
]
}
}
},
"rules": { "70_Final": { "writeTo": "stdout,azureBlob" } }
}
}
{ "NLog": {
"extensions": [
{ "assemblyFile": "NLog.Extensions.AzureBlobStorage.dll" }
],
"targets": {
"azureBlob": {
"type": "AzureBlobStorage",
"connectionString": "DefaultEndpointsProtocol=https;AccountName=test;AccountKey=key;EndpointSuffix=core.windows.net",
"container": "orchestratorlogs",
"blobName": "${date:format=yyyy-MM-dd hh.mm}",
"layout": {
"type": "JsonLayout",
"includeAllProperties": true,
"Attributes": [
{"name": "ts","layout": "${longdate}"},
{"name": "level","layout": "${level:upperCase=true}"},
{"name": "logger","layout": "${logger}"},
{"name": "message","layout": "${message}"},
{"name": "exception","layout": "${onexception:${ui-pretty-exception}}"}
]
}
}
},
"rules": { "70_Final": { "writeTo": "stdout,azureBlob" } }
}
}
将机器人日志写入 Splunk 的 nlog.config.json 文件示例:
{
"Nlog": {
"extensions": [
{ "assemblyFile": "NLog.Targets.Splunk.dll" },
{ "assembly": "UiPath.Orchestrator.Logs.DatabaseBulk.NLogTarget" }
],
"targets": {
"Splunk": {
"type": "AsyncWrapper",
"overflowAction": "Discard",
"queueLimit": 10000,
"batchSize": 200,
"timeToSleepBetweenBatches": 1,
"target": {
"type": "SplunkHttpEventCollector",
"serverUrl": "http://splunk.example.com",
"token": "splunk-token",
"channel": "",
"source": "${logger}",
"sourceType": "_json",
"index": "uipath",
"retriesOnError": "0",
"batchSizeBytes": "0",
"batchSizeCount": "0",
"includeEventProperties": "true",
"includePositionalParameters": "true",
"includeMdlc": "true",
"maxConnectionsPerServer": "10",
"ignoreSslErrors": "false",
"useProxy": "false",
"proxyUrl": "",
"proxyPassword": ""
}
}
},
"rules": {
"20_Robot_Primary": { "writeTo": "Splunk,database,insightsRobotLogs" }
}
}
}
{
"Nlog": {
"extensions": [
{ "assemblyFile": "NLog.Targets.Splunk.dll" },
{ "assembly": "UiPath.Orchestrator.Logs.DatabaseBulk.NLogTarget" }
],
"targets": {
"Splunk": {
"type": "AsyncWrapper",
"overflowAction": "Discard",
"queueLimit": 10000,
"batchSize": 200,
"timeToSleepBetweenBatches": 1,
"target": {
"type": "SplunkHttpEventCollector",
"serverUrl": "http://splunk.example.com",
"token": "splunk-token",
"channel": "",
"source": "${logger}",
"sourceType": "_json",
"index": "uipath",
"retriesOnError": "0",
"batchSizeBytes": "0",
"batchSizeCount": "0",
"includeEventProperties": "true",
"includePositionalParameters": "true",
"includeMdlc": "true",
"maxConnectionsPerServer": "10",
"ignoreSslErrors": "false",
"useProxy": "false",
"proxyUrl": "",
"proxyPassword": ""
}
}
},
"rules": {
"20_Robot_Primary": { "writeTo": "Splunk,database,insightsRobotLogs" }
}
}
}
调整 Splunk 大小 queueLimit
队列会在速度下降期间吸收 Splunk 积压。根据峰值吞吐量,而不是平均值:
queueLimit = peak_logs_per_sec × acceptable_backlog_seconds
queueLimit = peak_logs_per_sec × acceptable_backlog_seconds
| 部署 | 峰值速率 | 积压容错 | 队列限制 |
|---|---|---|---|
| 小 | 约每秒 10 个日志 | 60 秒 | 600 |
| 中 | 约 35 个日志/秒 | 300 秒 | 10000 |
| 大 | 约 200 个日志/秒 | 60 秒 | 12000 |
Splunk 目标的最佳实践
- 将
overflowAction: Discard用于次要目标。Splunk 等外部日志目标通常是分析或可观察性目标,Orchestrator 数据库是事实来源。如果外部目标无法跟上进度,与阻止应用程序线程相比,删除其副本更好。 - 为不可接受丢失的目标保留
overflowAction: Block。Block可防止事件丢失,但不能防止阻止。当队列在持续负载下变满时,它将还原为与BufferingWrapper相同的线程阻止行为。仅当外部目标符合合规性或审核要求时才使用它,并且会适当调整queueLimit大小以匹配峰值吞吐量。 - 始终将
database与任何外部目标一起保留在writeTo规则中。这可确保无论外部目标的可用性或性能如何,机器人日志都不会永久丢失。 - 关闭前刷新。
AsyncWrapper将事件保存在内存队列中。确保在正常关闭时刷新 NLog 目标,以避免在流程退出时丢失队列尾部。
更新 NLog 高级配置
更新 NLog 配置所需的uipathctl命令为:
uipathctl config orchestrator get-config --nlog-config- 以键值对 json 文件的形式导出当前配置,以供编辑。uipathctl config orchestrator update-config --nlog-config nlog.config.json- 使用您的更改更新配置。
- 使用以下命令将当前自定义 NLog 配置导出至 json 文件:
uipathctl config orchestrator get-config --nlog-config > nlog.config.jsonuipathctl config orchestrator get-config --nlog-config > nlog.config.json - 根据需要编辑导出的
nlog.config.json文件。 您可以添加、删除或更改其任何设置。备注:每次需要进行更改时,都必须重新导出文件,因为更新会覆盖所有 NLog 设置。
- 使用以下命令更新 NLog 配置:
uipathctl config orchestrator update-config --nlog-config nlog.config.json orchestrator config updateduipathctl config orchestrator update-config --nlog-config nlog.config.json orchestrator config updated