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

The New Relic data source has the following requirements:

Known limitations

  • Ad-hoc filters are not currently supported.
  • NRQL queries with multiple FACET fields are not supported.
  • NRQL queries with COMPARE WITH operator are not supported.
  • Currently only APM (Application Performance Monitoring) and Insights are 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 names Descriptions
Name Enter a name for this particular New Relic data source.
Personal API Key / User API key To 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 ID Enter your New Relic Account ID. To find your New Relic Account ID, refer to Get an API key and account ID from New Relic.
Region Enter 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

apiVersion: 1

datasources:
  - name: NewRelic
    type: grafana-newrelic-datasource
    access: proxy
    editable: true
    enabled: true
    secureJsonData:
      accountId: 1111111
      personalApiKey: Personal API Key
    version: 1

Query the data source

The service can be Metrics, Data Explorer or NRQL Editor. 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 names Descriptions
Source Select the source type either Application or Plugins and then start typing in the dropdown box to find your source.
Metric Select the metric namespace you wish to view from the expanding lists.
Value Enter the metric value you want returned.
Alias By You 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.

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 names Descriptions
From Use 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.
Select You 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.
Format This 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 time filter NRQL macro. This will use your Grafana dashboard’s time range in the query by interpolating $__timeFilter to SINCE <from> UNTIL <to> .

Example:

SELECT average(value) FROM $event_template_variable $__timeFilter TIMESERIES

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.

SELECT count(*) FROM SyntheticRequest FACET responseStatus $__timeFilter

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

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

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.

Endpoints Description
applications List of available applications
applicationNames List of available applications names
applications/{application_id}/metrics List of available metrics for an application
components List of available components
components/{component_id}/metrics List of available metrics for a component

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