Connecting UiPath with New Relic

Connecting UiPath with New Relic

While working on a RPA project, I realised that an important aspect of any automation process is to monitor its functionality. Organisations now a days are moving rapidly towards automation and its very important for them to have a clear visibility on their automation processes. Although most RPA tools have their own monitoring and alerting platforms, some businesses may prefer to get their monitoring and alerting setup on a single tool. In this article I have tried to showcase how we can integrate an Automation tool with another Application Monitoring tool. We will be discussing about UiPath which is a Robotic Process Automation tool and New Relic which is APM tool. With the aim of keeping this article precise, I won’t be deep diving into the UiPath workflow and orchestrator design, but we will be focusing only on connecting these two tools. If you are new to RPA(Robotic Process Automation) or these tools I would highly recommend to check out these links so that you can better understand this article:

The article is structured with an assumption that you are already having your UiPath environment and New Relic account setup. The deployment architecture looks like:

UiPath+New Relic Deployment Architecture

The Automation Setup:

I have setup a couple of jobs that run on a specific server at certain times during the day. My setup is as below:

  • Workflows are created using UiPath Studio
  • These workflows are published on the Cloud Orchestrator as packages
  • These packages are then used to create the jobs
  • The jobs are triggered using process triggers which are scheduled as per requirement

There are also some other steps involved with the RPA setup like creating environments, machines and configuring robots etc.

Tweaks on Automation Side:

While executing a process on the host/machine, UiPath will save the logs locally to this location: “C:\Users\pranav\AppData\Local\UiPath\Logs”. These logs are saved with a format of “Time Stamp | Log Level | Message”. Now our aim is to get rid of the Time Stamp & Log Level so that we have our log message in Json format. The reason behind this is logs with Json format can be easily parsed in New Relic. To do this, we append the nlog.config file on this location: “C:\Program Files (x86)\UiPath\Studio”

The nlog.config file looks like:

<?xml version="1.0" encoding="utf-8" ?><nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<variable name="WorkflowLoggingDirectory" value="${specialfolder:folder=LocalApplicationData}/UiPath/Logs" />
<rules>
<logger name="WorkflowLogging" writeTo="WorkflowLogFiles" final="true" />
<logger minLevel="Info" writeTo="EventLog" />
</rules>
<targets>
<target type="File" name="WorkflowLogFiles" fileName="${WorkflowLoggingDirectory}/${shortdate}_Execution.log"layout="${time} ${level} ${message}" keepFileOpen="true" openFileCacheTimeout="5" concurrentWrites="true" encoding="utf-8" writeBom="true" />
<target type="EventLog" name="EventLog" layout="${processname} ${assembly-version} ${newline}${message}" source="UiPath" log="Application" />
</targets>
</nlog>

All we need to do is remove ${time} ${level} parameters from the layout part in the <targets> section so that it just has ${message} in it. Please refer the below image:

Layout section in the config file which needs to be appended
Layout Section in the config file after appending

Monitoring Setup:

We are using New Relic as out APM tool and to get the logs forwarded from the host/machine onto New Relic, we will be using the New Relic Infrastructure agent. This agent is installed locally on the host/machine. More information on the setup and configuration of NRI Agent can be found here: NRI Agent. Once the agent is setup on the server, we configure the “newrelic-infra.yml” file located at: “C:\Program Files\New Relic\newrelic-infra” so that it will forward the UiPath execution logs to New Relic. A sample YAML script to get started:

logs:
-name: "nriagent_test_log"
file: 'C:\Users\pranav\AppData\Local\UiPath\Logs\*.log'
pattern: Info|Warn
attributes:
application: UiPath

Please note that the above script is just for reference purpose and while I have used a wild card * here, best practices recommend not using wild card with a file extension. Once this is configured, restart the New Relic Infrastructure Agent service. From now, all the logs which will be saved on the location mentioned in your “newrelic-infra.yml” file should be forwarded onto New Relic.

Visibility on New Relic:

Once you login to your New Relic account, you use NRQL(New Relic Query Language) to look for the logs. For a better visibility, we can create a dashboard which will show us the automation run activities on the machine for our processes. For more info on creating dashboards please refer to NRI Dashboards. In my case for example, I am running two different processes on the same machine at different times during the day, so I have created my Dashboard with three charts to showing me:

New Relic Custom Dashboard

Sample NRQL for Process 1

FROM Log SELECT message WHERE hostname = ‘MyServerName’ and processName = ‘Process1’ SINCE 1 day ago

Sample NRQL for Process 2

FROM Log SELECT message WHERE hostname = ‘MyServerName’ and processName = ‘Process2’ SINCE 1 day ago

Sample NRQL for my host

FROM Log SELECT message WHERE hostname = ‘MyServerName’

After studying the docs,community forums and other resources I have come up with this solution but, I am aware that there can be other ways to get this setup done. If you are aware of any, I would love to hear it. Also, any feedback on this will only help me improve in future so please feel free to reach out.

References:

AWS Certified Solutions Architect Associate | IT Technologist | Enthusiast Writer