Skip to Content

New Relic

Added inv2.0.0-31

Artillery provides comprehensive integration with New Relic, supporting metrics, traces, and events through both native integration (New Relic API ) and OpenTelemetry.

Quick Start

plugins: publish-metrics: - type: newrelic licenseKey: "{{ $env.NR_LICENSE_KEY }}"

Configuration Methods

Native Integration

The native New Relic reporter supports sending metrics, events and traces to New Relic.

Metrics

By default, all Artillery metrics will be sent to New Relic. Each Artillery metric will create a custom New Relic metric , which may have an associated cost.

Configuration Options

config: plugins: publish-metrics: - type: newrelic # NR_LICENSE_KEY is an environment variable containing the New Relic license key licenseKey: "{{ $env.NR_LICENSE_KEY }}" region: eu prefix: "artillery.publish_metrics_plugin." attributes: - "testType:LoadTest" - "tool:Artillery"
NameDescription
licenseKey (required)The license key for the account you want to send the metrics to
regionus (default) or eu. If your account hosts data in the EU data center set the region to eu.
prefixSet a prefix for metric names created by Artillery; defaults to artillery.
attributesA list of name:value strings to use as tags for all metrics sent during a test
excludedA list of metric names which should not be sent to New Relic. Defaults to an empty list, i.e. all metrics are sent to New Relic.
includeOnlyA list of specific metrics to send to New Relic. No other metrics will be sent. Defaults to an empty list, i.e. all metrics are sent to New Relic.
eventSet to send a New Relic event when test starts/finishes. See event specific configuration
tracesSet to send traces to New Relic. See traces specific configuration

Events

The reporter supports sending a New Relic event on test start and test finish. To enable set the event option and configure it with the accountId.

Event Configuration

config: plugins: publish-metrics: - type: newrelic licenseKey: "{{ $env.NR_LICENSE_KEY }}" event: accountId: "{{ $env.NR_ACCOUNT_ID }}" eventType: "Artillery_load_test" attributes: - "alertType:info" - "priority:low" - "testId:{{ $testId }}"
NameDescription
accountId (required)Your New Relic account ID .
eventTypeSet to customize the event’s name, defaults to Artillery_io_Test. Must be a string that is a combination of alphanumeric characters, underscores, and colons.
sendSet to false to turn off the event. By default, if event is configured, it will be sent. This option makes it possible to turn event creation on/off on the fly (e.g. via an environment variable)
attributesOptional list of name:value strings to use as attributes/tags for events sent during a test.
By default Artillery sends the target: , timestamp: and phase: 'Test Started' / 'Test Finished' attributes.

Traces (Native)

New Relic tracing feature is available for both HTTP and Playwright engines, and the tracing data available is different depending on the engine used.

An additional plugins.publish-metrics.spans.exported metric will be recorded and will appear in your reports when tracing is enabled. It represents the number of spans exported to New Relic.

Added inv2.0.9

Trace Configuration Options

config: plugins: publish-metrics: - type: newrelic licenseKey: "{{ $env.NR_LICENSE_KEY }}" traces: serviceName: service_name sampleRate: 0.5 replaceSpanNameRegex: - pattern: get_user_[a-zA-Z0-9]+ as: get_user_id attributes: - testType:LoadTest - tool:Artillery
NameDescription
serviceNameName of your service. Defaults to Artillery-test
sampleRateSample rate. Percentage of traces to send represented by a value between 0 and 1. (defaults to 1 - all traces are sent)
useRequestNamesIf set to true the request names provided in test script will be used as span names
attributesCustom attributes to be added to each span in key: value pair format.
replaceSpanNameRegex
Added inv2.0.9
A list of replacement maps that consist of:
pattern - regex pattern to match against the span names
as - string to replace the matched pattern in the span names

OpenTelemetry Integration

You can also send data to New Relic using OpenTelemetry protocol. This is useful when you want standardized telemetry or are already using OpenTelemetry in your infrastructure.

Requirements

Configuration

plugins: publish-metrics: - type: 'open-telemetry' serviceName: <your-service-name> metrics: endpoint: 'https://{{ $env.NEW_RELIC_OTLP_ENDPOINT }}/v1/metrics' headers: api-key: '{{ $env.NR_LICENSE_KEY }}' traces: endpoint: 'https://{{ $env.NEW_RELIC_OTLP_ENDPOINT }}/v1/traces' headers: api-key: '{{ $env.NEW_RELIC_LICENSE_KEY }}'

Endpoints

OrganisationBase URL
US OTLPhttps://otlp.nr-data.net
EU OTLPhttps://otlp.eu01.nr-data.net
US FedRAMP OTLPhttps://gov-otlp.nr-data.net

Examples

Complete Native Integration

config: plugins: publish-metrics: - type: newrelic licenseKey: "{{ $env.NR_LICENSE_KEY }}" region: us prefix: "artillery.publish_metrics_plugin." attributes: - "testType:LoadTest" - "tool:Artillery" event: accountId: "{{ $env.NR_ACCOUNT_ID }}" eventType: "Artillery_load_test" attributes: - "alertType:info" - "priority:low" - "testId:{{ $testId }}" traces: serviceName: service_name sampleRate: 0.5 useRequestNames: true attributes: - testType:LoadTest - tool:Artillery

Debugging

Set DEBUG=plugin:publish-metrics:newrelic when running your tests to print out helpful debugging messages when sending metrics to New Relic.

DEBUG=plugin:publish-metrics:newrelic artillery run my-script.yaml

Reference

For more information, consult the New Relic documentation .

Last updated on