How to customize the charts you see on a workload

We’re excited to announce that you can now customize the time series charts that you see on a workload!

Where do the workload charts come from?

New Relic Workloads provide an aggregated view of health and activity data of all the entities that take part in providing a capability to your end clients.

The time series charts that you see on a workload adapt dynamically to the workload content. For each entity type that is included in the workload, New Relic will show a row of golden metric charts, and each chart will include a time series for each entity, no matter the sub-account where that entity lives.

The golden metrics shown for each entity type are defined in the public Github repo for Entity Synthesis Definition, and you can also fetch them with the Nerdgraph API.

For example, these are the golden metric queries for a specific AWS Lambda Function (with GUID MTY…jg5) that belongs to the New Relic demo environment:

{
  actor {
    entity(guid: "MTY...jg5") {
      goldenMetrics {
        metrics {
          query
          title
        }
        context {
          account
          guid
        }
      }
    }
  }
}

This is the response, which includes four metric names and queries:

{
  "data": {
    "actor": {
      "entity": {
        "goldenMetrics": {
          "context": {
            "account": null,
            "guid": null
          },
          "metrics": [ 
            {
              "query": "SELECT sum(provider.errors.Sum) * 100 / sum(provider.invocations.Sum) FROM ServerlessSample WHERE entityGuid IN ('MTY...jg5') AND provider='LambdaFunction' TIMESERIES",
              "title": "Error rate %"
            },
            {
              "query": "SELECT rate(sum(provider.invocations.Sum),1 minute) FROM ServerlessSample WHERE entityGuid IN ('MTY...jg5') AND provider='LambdaFunction' TIMESERIES",
              "title": "Total Invocations"
            },
            {
              "query": "SELECT max(provider.duration.Maximum) / 1000 FROM ServerlessSample WHERE entityGuid IN ('MTY...jg5') AND provider='LambdaFunction' TIMESERIES",
              "title": "Duration (99 percentile) (s)"
            },
            {
              "query": "SELECT rate(sum(provider.throttles.Sum), 1 minute) FROM ServerlessSample WHERE entityGuid IN ('MTY...jg5') AND provider='LambdaFunction' TIMESERIES",
              "title": "Throttled invocations"
            }
          ]
        }
      }
    }
  }

And this is how they show on the workloads UI:

What are the options to override the default golden metrics?

The default golden metrics are the performance indicators that New Relic prescribes to have a look first, for each entity. But sometimes you might need to customize those golden metrics to better match your business logic.

For that purpose, for each entity type you can choose to override the default golden metrics at two different levels:

  1. For all the entities on an account: Your chosen golden metrics will show on any UI representation of the entities that belong to that account. That’s basically on workloads (see image above) and on entity previews that you’ll get when you click on entities (see image below).

  2. An alternative is to override the golden metrics only for a workload overview. This is how New Relic decides which golden metrics to show for each entity type on a certain workload:

How to select metrics that are more relevant to you, either for one specific workload or for all workloads on an account

If you want some or all workloads in an account to show different golden metrics for an entity type, you’ll need to use the entityGoldenMetricsOverride Nerdgraph endpoint. The way you specify that level of customization is by using the context object:

  • Use account when you want the new metrics to show on all workloads for an account, and specify the account ID there. Remember that overriding the golden metrics at the account level will also make these metrics show on the entity previews.
  • Use guid when you want the new metrics to show only on a certain workload, and specify the workload GUID there.

Let’s see a working example: previously we saw that the default golden metrics for an AWS Lambda Function are “Error rate %”, “Total invocations”, “Duration (99 percentile) (s)” and “Throttled invocations”.

Now imagine we want to focus on the amount of concurrent executions instead of totals. This is the NRQL query we’d like to represent on the workload:

SELECT sum(provider.concurrentExecutions.Sum)
FROM ServerlessSample
WHERE entityGuid in (<new_relic_will_replace_with_the_guids_of_all_the_lambda_functions_in_the_workload>) 
AND provider=’LambdaFunction’ 
FACET entityName TIMESERIES

Note a couple of particularities that make this query suitable for a golden metric:

  • We need a query that includes the entity GUID in one of its attributes, so New Relic can scope the query to the entities in the workload,
  • We need a query that can be faceted by an entity friendly name, so those names will show on the UI.

This is the API call that we’d use to override the AWS Lambda Function golden metrics for the demo “Acme Telco - Ecommerce” workload, with GUID “MTY…MzQ”:

mutation {
  entityGoldenMetricsOverride(context: {
    guid: "MTY...MzQ"},
    metrics: [{
      name: "errorRate",
      title: "Error rate %",
      from: "ServerlessSample",
      select: "sum(provider.errors.Sum) * 100 / sum(provider.invocations.Sum)",
      where: "provider='LambdaFunction'",
      eventId: "entityGuid",
      facet: "entityName"
    },
    {
      name: "concurrentInvocations",
      title: "Concurrent invocations",
      from: "ServerlessSample",
      select: "sum(provider.concurrentExecutions.Sum)",
      where: "provider='LambdaFunction'",
      eventId: "entityGuid",
      facet: "entityName"
    },
    {
      name: "duration",
      title: "Duration (99 percentile) (s)",
      from: "ServerlessSample",
      select: "max(provider.duration.Maximum) / 1000 ",
      where: "provider='LambdaFunction'",
      eventId: "entityGuid",
      facet: "entityName"
    }, 
    {
      name: "throttledInvocations",
      title: "Throttled invocations",
      from: "ServerlessSample",
      select: "rate(sum(provider.throttles.Sum), 1 minute)",
      where: "provider='LambdaFunction'",
      eventId: "entityGuid",
      facet: "entityName"
    }],
    domainType: {
      domain: "INFRA",
      type: "AWSLAMBDAFUNCTION"
    }) {
    metrics {
      metrics {
        title
        query
      }
    }
  }
}

And this is the result on the UI, where we can see concurrent invocations now for the “Acme Telco - Ecommerce” workload, instead of total invocations:

Customization achieved!

As these changes will modify the experience for all users in the account, therefore you must have the appropriate permissions to use the golden metrics override calls.

More on the golden metrics API

You can always go back to the default golden metrics by using the entityGoldenMetricsReset API call. Please refer to the Golden metrics for entities NerdGraph API tutorial for more details.

We’re eager to know how this is working for you, please don’t hesitate to leave your comments on this post. Cheers!

3 Likes

I have used below code, and its not working , can you help me here

mutation {
entityGoldenMetricsOverride(context: {
guid: “MTQ1Njg2MXxOUjF8V09SS0xPQUR8MzQ2NzM”},
metrics: [{
name: “errorRate”,
title: “Error rate %”,
from: “ServerlessSample”,
select: “sum(provider.errors.Sum) * 100 / sum(provider.invocations.Sum)”,
where: “provider=‘LambdaFunction’”,
eventId: “MTQ1Njg2MXxJTkZSQXxOQXw2Njg0NTM0NTQzMzAwMzQ5MzU3”,
facet: “entityName”
},
{
name: “concurrentInvocations”,
title: “Concurrent invocations”,
from: “ServerlessSample”,
select: “sum(provider.concurrentExecutions.Sum)”,
where: “provider=‘LambdaFunction’”,
eventId: “MTQ1Njg2MXxJTkZSQXxOQXw2Njg0NTM0NTQzMzAwMzQ5MzU3”,
facet: “entityName”
},
{
name: “duration”,
title: “Duration (99 percentile) (s)”,
from: “ServerlessSample”,
select: "max(provider.duration.Maximum) / 1000 ",
where: “provider=‘LambdaFunction’”,
eventId: “MTQ1Njg2MXxJTkZSQXxOQXw2Njg0NTM0NTQzMzAwMzQ5MzU3”,
facet: “entityName”
},
{
name: “throttledInvocations”,
title: “Throttled invocations”,
from: “ServerlessSample”,
select: “rate(sum(provider.throttles.Sum), 1 minute)”,
where: “provider=‘LambdaFunction’”,
eventId: “MTQ1Njg2MXxJTkZSQXxOQXw2Njg0NTM0NTQzMzAwMzQ5MzU3”,
facet: “entityName”
}],
domainType: {
domain: “INFRA”,
type: “AWSLAMBDAFUNCTION”
}) {
metrics {
metrics {
title
query
}
}
}
}

Hello @aelahi!

eventId needs to be literally a field name, and in the case of Lambda Functions instrumentation (which generates the ServerlessSample NRDB event) that is entityGuid, as in the example above.

New Relic will use that field to identify which entities to show, and in the case of a workload, that will be all the lambdas that belong to the workload at each point in time, so you don’t need to hardcode the lambda guids into your query.

Let me know how it worked, please!

I tried with below, but still no luck

mutation {
entityGoldenMetricsOverride(context: {
guid: “MTQ1Njg2MXxOUjF8V09SS0xPQUR8MzQ2NzM”},
metrics: [{
name: “errorRate”,
title: “Error rate %”,
from: “ServerlessSample”,
select: “sum(provider.errors.Sum) * 100 / sum(provider.invocations.Sum)”,
where: “provider=‘LambdaFunction’”,
eventId: “entityGuid”,
facet: “entityName”
},
{
name: “concurrentInvocations”,
title: “Concurrent invocations”,
from: “ServerlessSample”,
select: “sum(provider.concurrentExecutions.Sum)”,
where: “provider=‘LambdaFunction’”,
eventId: “entityGuid”,
facet: “entityName”
},
{
name: “duration”,
title: “Duration (99 percentile) (s)”,
from: “ServerlessSample”,
select: "max(provider.duration.Maximum) / 1000 ",
where: “provider=‘LambdaFunction’”,
eventId: “entityGuid”,
facet: “entityName”
},
{
name: “throttledInvocations”,
title: “Throttled invocations”,
from: “ServerlessSample”,
select: “rate(sum(provider.throttles.Sum), 1 minute)”,
where: “provider=‘LambdaFunction’”,
eventId: “entityGuid”,
facet: “entityName”
}],
domainType: {
domain: “INFRA”,
type: “AWSLAMBDAFUNCTION”
}) {
metrics {
metrics {
title
query
}
}
}
}

Hello again @aelahi ,
In order to see the new charts for lambda functions on the workload, you need to add lambda functions to it.
Here’s the documentation that explains how to add entities to a workload, either selecting them one by one, or using tags: Create a workload.
A redesign of the workload creation/edition flow is coming soon, I’ll reach out to you directly to invite you to a design validation session.
Cheers!