UiPath Orchestrator and App Service logging with Application Insights
Target was to improve visibility and logging of UiPath Orchestrator with Application Insights which is part of Azure Monitor.
I implemented this in Azure App Service with utilizing existing Application Insights which I had enabled to monitor App Service.
When you configure UiPath Orchestrator in Azure App Service, there is option to disable/enable telemetry which UiPath uses to collect usage feedback from Orchestrator. By default, this is enabled unless you disable it. Usually you want to avoid sending diagnostics data to external networks unless you are sure and your policies allows you to do that.
However, you can utilize the same feature by routing all the diagnostics data to your own Application Insights. You can configure the Telemetry to use your own Application Insights be setting Telemetry.AppInsights.Key to point at your own Application Insights.
You can also look how to configure rest of the variables regarding the Application Insights and Orchestrator by looking at the UiPath Orchestrator Azure Marketplace deployment script here.
NLOG: As you probably are a aware, UiPath utilizes NLog for collecting log data from Orchestrator. Example you will have configuration on where to store all the logs which the Robots are sending.
NLog is widely use logging solution and there are decent amount of targets where you want to put you data, example:
- Azure Blob/Table/Queue/File Storage
- Azure CosmosDb Tables
- Azure EventHubs
…list is huge, but because I’m talking about Azure deployment, I wanted to raise only these few.
Do note, that you can forward you Robot logs also to these targets if you want to have long term storage as it is not recommended to keep Robot logs in Orchestrator database for long term.
You also have setting defining where the Orchestrator diagnostic logs are send to. There are logs about Quartz which is the component Orchestrator uses to trigger different schedules which maintain the Orchestrator and as well the execution of Automation processes.
By default, in Orchestrator web.config, these logs are configured to use local Windows\EventLog. When running Orchestrator in Virtual Machine, this should be perfectly fine and it is easy to collect logs from Windows\EventLog to some certalized loggin solution.
But, with Azure App Service getting the logs from App Service EventLog is not ideal especially if you have already configured Application Insights to monitor your instance.
SOLUTION: Configure Orchestrator to forward all logs to the Application Insights.
You will need to have the Telemetry.Enabled=true and use own Application Insights instrumentation key for the App Service.
Then as you will see in the https://github.com/Microsoft/ApplicationInsights-dotnet-logging how to configure the target, is states in section instrumentationKey “Only required if not using ApplicationInsights.config“, so as your App Service is configured to use Application Insights already, it is sufficient to have target configured simply as:
<target xsi:type="ApplicationInsightsTarget" name="aiTarget" />
And remember to add assembly reference to extensions:
<add assembly="Microsoft.ApplicationInsights.NLogTarget" />
Then just set the target rules which you want to log, example replacing EventLog targets as:
<logger name="BusinessException.*" minlevel="Info" writeTo="aiTarget" final="true" /> <logger name="Quartz.*" minlevel="Warn" writeTo="aiTarget" final="true" /> <logger name="*" minlevel="Info" writeTo="aiTarget" />
Then in Azure monitor you can query logs(Do note, that there is delay before logs will be visible in Application Insights):
Hopefully this helps you increase visibility in your platform.