1

We have Sitecore multi-site set up where 3 websites are running from single sitecore instance. In new relic we want to track monitoring data for each site individually. If websites are hosted under different root directory then it's simple but how can we achieve the same for Sitecore multisite project where multiple sites are running under same root directory. Sites count may increase to 15 as well.

2

New Relic APM agent collects data at IIS worker process level. Multiple sites running in the same Sitecore instance share the same process and for this reason their APM data is collected under the same application name. Using different New Relic APM application names for sites hosted under the same IIS web application is not possible.

You can distinguish the APM data for each site enriching their transaction data with a custom attribute that can be defined and populated using the New Relic APM .NET Agent API in a custom Sitecore processor (that inherits the HttpRequestProcessor class) in the httpRequestBegin Sitecore pipeline after the ItemResolver processor is executed.

This is just an example of how this processor can be implemented:

class NewRelicCustomAttributesProcessor : HttpRequestProcessor
{
    public override void Process(HttpRequestArgs args)
    {
        Item currentItem = Sitecore.Context.Item;
        if (currentItem == null)
            return;

        IAgent agent = NewRelic.Api.Agent.NewRelic.GetAgent(); 
        ITransaction transaction = agent.CurrentTransaction;
        transaction.AddCustomAttribute("sc_site", Sitecore.Context.GetSiteName());
    }
}

Unfortunately the New Relic APM UI doesn't have a filter based on a custom attribute for the data displayed in the OOTB charts and tables. You will need to build your own custom dashboard to display data based on a specific value of your custom attribute.

Additional Note

The New Relic APM .NET Agent API has a method called SetApplicationName that can be used to set the name of the APM application when the web application starts. This method is meant to be called only once in the application lifecycle (when it starts), as described in the official documentation:

Updating the app name forces the agent to restart. The agent discards any unreported data associated with previous app names. Changing the app name multiple times during the lifecycle of an application is not recommended due to the associated data loss.

1
  • thank you. This means Sites specific transactions will be tagged to values( site1,site2 etc. ) being passed in sc_site attribute and in new relic dashboard, we can filter all transactions by values ( site1,site2 etc. ) itself.
    – Sukhjeevan
    Oct 14 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.