Menu

Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.

New Relic data source for Grafana
Enterprise

New Relic data source for Grafana

The New Relic data source plugin allows you to query and visualize New Relic APM (Application Performance Monitoring) and Insights from within Grafana.

Requirements

This plugin has the following requirements:

  • A New Relic account
  • One of the following account types:
    • Grafana Cloud: Pro customers, Advanced customers, or Pro trial users with the Enterprise plugin add-on enabled
    • Grafana Enterprise: Customers with an activated license and a user with Grafana server or organization administration permissions
  • The Enterprise plugin add-on enabled

Known limitations

  • Ad-hoc filters are not currently supported.
  • NRQL queries with multiple FACET fields are not supported.

Install the New Relic data source plugin

To install the data source, refer to Installation.

Get an API key and account ID from New Relic

You will need your personal API key/user API key, refer to New Relic API Key. You will also need your account ID from New Relic, refer to Account ID.

Configure the data source in Grafana

Add a data source by filling in the following fields:

Field namesDescriptions
NameEnter a name for this particular New Relic data source.
Personal API Key / User API keyTo find your New Relic API key, refer to Get an API key and account ID from New Relic.Enter a name for this particular New Relic data source.
Account IDEnter your New Relic Account ID. To find your New Relic Account ID, refer to Get an API key and account ID from New Relic.
RegionEnter your region hosting your service.

Configure the data source with provisioning

Data sources can be configured with Grafana’s provisioning system. You can read more about how it works and all the settings you can set for data sources on Provisioning Grafana.

Here is an example for provisioning this data source

yaml
apiVersion: 1
datasources:
  - name: New Relic
    type: grafana-newrelic-datasource
    jsonData:
      region: EU
    secureJsonData:
      accountId: 1111111
      personalApiKey: Personal API Key

Query the data source

The service can be Metrics, Data Explorer, NRQL Editor, Logs or Traces. To learn more about NRQL Editor/Insights, refer to Insights.

Metrics

If you do not find an option in these dropdown boxes you can still select the option by selecting Create: (your text).

Field namesDescriptions
ApplicationSelect the source application. Start typing in the dropdown box to find your source.
MetricSelect the metric namespace you wish to view from the expanding lists.
ValueEnter the metric value you want returned.
Alias ByYou can combine plain text with the following variables: $__nr_metric is the metric name e.g. CPU/User time. $__nr_metric_value is the metric value e.g. average_value.

There is a little search icon next to Application/Metric selectors. When you have lots of applications or metrics, you can use them to search those. Search icon wil result relevant 1000 results at any time. You can use name filter to filter out the results if you have more than 1000 applications/metrics. Note: Search is case-sensitive.

Data Explorer - BETA

Data explorer allows you to query New Relic Insights data without writing raw NRQL.

Once you switch to Data Explorer mode, the query editor will be pre-configured with a default query. You can make your own data explorer query by customizing the following fields:

Field namesDescriptions
FromUse this field to specify the data type you wish to query. If this field is updated, the remaining part of the query will be reset to default.
SelectYou can specify one or more aggregation. in the SELECT section. This can be also used to perform arithmetic operation over two aggregated fields. Optionally, Each item in the SELECT can be filtered using NRQL FILTER queries.
Where(optional) Specify the raw condition of NRQL filter. Example appName = 'something' AND serverName in ('server1','server2') AND city in (${cities:singlequote}). This field accepts grafana variables.
Facet(optional) Use this field to separate and group your results by attribute values. Use FACET BY CASES to break out your data by more complex conditions than possible with FACET
Time Filter(optional) Configure this field to filter the data based on time range. Select Dashboard time to filter the data based on Grafana’s selected time range. By default, Grafana’s time range is used.
FormatThis can be one of TimeSeries or Table. The default is TimeSeries. If TimeSeries is chosen, then the TIMESERIES keyword is added to the query and your data will be in time series format broken out by a specified period of time. If the Table is chosen, then data will not be aggregated by time. Use Table mode, in case if you want a summary.
Interval(optional) When selecting the timeseries format above, you can optionally configure the interval of your time series aggregation.
Slide By(optional) When selecting timeseries format and custom interval, optionally use slide by field to specify the sliding time window range.

You can preview the NRQL query based on your options in the Preview section. If you want to further customize the query, you can switch to the raw NRQL editor by clicking Switch to NRQL Editor.

Read more about NRQL syntax in the New Relic documentation page.

NRQL editor (Insights)

For a New Relic Query Language intro, refer to Introduction to NRQL.

Code completion will be displayed once typing begins. To select a completion option, highlight the desired option with the arrow keys and press Tab to select.

The editor supports the following macros.

Macro syntaxDescriptions
$__timeFilterThis will use your Grafana dashboard’s time range in the query by interpolating $__timeFilter to SINCE <from> UNTIL <to> .
$__timeSeries(time range,corresponding aggregation,default aggregation)This macro can be used to set the aggregation dynamically based on timerange. Example: $__timeSeries(60m,1 MINUTE,MAX). This macro will expand to TIMESERIES 1 MINUTE when the dashboard interval is less than or equal to 60 mins. Otherwise it will expand to TIMESERIES MAX.

Example:

sql
SELECT average(value) FROM $event_template_variable $__timeFilter TIMESERIES

Make sure to include $__timeFilter macro in your NRQL query. Otherwise your results will not sync to grafana dashboards’ timerange.

Synthetics Queries

New Relic Synthetics data can be queried from the SyntheticCheck and SyntheticRequest tables using NRQL Editor/Insights.

For example, the query below returns the count of all requests by response status.

sql
SELECT count(*) FROM SyntheticRequest FACET responseStatus $__timeFilter

The query below returns the success rate of all the monitors.

sql
SELECT (
    filter(count(*),WHERE result = 'SUCCESS')
    / filter(count(*), WHERE result IN ('SUCCESS','FAILED'))
    * 100
) as 'Success Rate' FROM SyntheticCheck
FACET monitorName $__timeFilter TIMESERIES

For more details about the Synthetic monitoring querying, refer to Events reported by synthetic monitoring

Logs

The logs service of the plugin allows you to query and view the logs stored in New Relic Log table. The plugin uses NerdGraph NRQL queries to perform the search. Plugin uses SELECT * FROM Log WHERE <xxxx> SINCE <xxxxx> UNTIL <xxxxx> ORDER BY <xxxxx> LIMIT MAX query to perform the logs search and presents the results in grafana log format. Logs are filtered automatically the dashboard time range. You can optionally configure the following fields to filter the data

FieldDescription
QueryProvide NRQL filter query when searching for logs. Ex: message LIKE '%ERROR%' AND container_name = 'petclinic'
order ByBy default results will be ordered by timestamp descending. You can optionally change this to ascending.

Maximum of 2000 records will be returned in the logs search query (NRQL API limitations). But logs volume panel in the explore can give you hints about the existence of more logs in the entire time range and then you can narrow down the explore’s timerange to specific period.

If a log row find a field such as traceId/traceid/trace.id, logs panel will give you a link to corresponding trace view.

Traces

The traces service of the plugin allows you to query and view the traces stored in New Relic. This can be done by searching for traces individually, or through a list.

FieldDescription
Trace IDProvide the trace id here when using the Trace view. Ex: 951ae3313c093aa3278cbc27c0714c94
QueryProvide NRQL filter query when searching for traces. Ex: parentId IS NULL AND duration > 0.05 AND appName = 'petclinic'

You can find more about the New Relic tracing API at the New Relic documentation site.

Templates and variables

To add a new New Relic query variable, refer to Add a query variable. Use your New Relic data source as your data source for the following available queries.

EndpointsDescription
applicationsList of available applications
applicationNamesList of available applications names
applications/{application_id}/metricsList of available metrics for an application

New Relic query can return relative endpoints (excluding file extensions). For more information, refer to New Relic REST API

After creating a variable you can use it in your New Relic queries by using variable syntax. For more information refer to Variable syntax. For more information about variables, refer to Templates and variables.

Import a dashboard for New Relic

Follow these instructions for importing a dashboard.

Imported dashboards can be found in Configuration > Data Sources > select your New Relic data source > select the Dashboards tab to see available pre-made dashboards.

Get the most out of the plugin