Our StatsD integration lets you easily get StatsD-format data into New Relic. You can also add any arbitrary tags (key-value pairs) to your data. Once your metrics are in New Relic, you can query your data and create custom charts and dashboards.
Want to try out our StatsD integration? Create a New Relic account for free! No credit card required.
Requirements
This integration uses our Metric API and our Event API to ingest data. To use these APIs, you'll need a .
The integration adheres to the Metric API requirements and data limits. To see if you might be hitting the rate limit, run the following NRQL query of the NrIntegrationError
event:
SELECT count(*) FROM NrIntegrationError WHERE newRelicFeature = 'Metrics' FACET category, messageLIMIT 100 SINCE 1 day ago
The integration is available as a linux container image in DockerHub for amd64 and arm64 architectures.
Install
This section will explain how to do a standard install. If you want to run StatsD in Kubernetes, see Kubernetes install.
To install the StatsD integration, run the following command and include your New Relic account ID and . This generates a TOML configuration file used by gostatsd
.
$docker run \> -d --restart unless-stopped \> --name newrelic-statsd \> -h $(hostname) \> -e NR_ACCOUNT_ID=YOUR_ACCOUNT_ID \> -e NR_API_KEY=NEW_RELIC_LICENSE_KEY \> -p 8125:8125/udp \> newrelic/nri-statsd:latest
If your organization is in the EU data center region, add this to the above command:
$-e NR_EU_REGION=true \
After installing, you can:
- Do optional additional configuration
- Define your metrics
- Add custom tags to your data
- Create alerts
Install for Kubernetes
Here are examples of Kubernetes manifests for deployment and service objects:
Did this doc help with your installation?
Configure
In the install procedure, you run nri-statsd
with environment variables, and this generates a TOML configuration file. Additionally, you can set these configuration options:
Configuration options | Description |
---|---|
string | If a metric is not updated for this amount of time, we stop reporting that metric. Default is If you want to send the metrics only if the value was updated between the flush intervals, configure this to |
list of integers | Specifies the percentiles used for metrics aggregation. Default: |
string | Indicates address on which to listen for metrics. Default: |
Tip
To ensure FedRAMP compliance when using the StatsD integration you must define the following endpoints in the custom configuration:
address = 'https://gov-insights-collector.newrelic.com/v1/accounts/$NR_ACCOUNT_ID/events'
address-metrics = 'https://gov-infra-api.newrelic.com/metric/v1'
Here are some examples of customizing configuration by overwriting the default configuration:
Metric format
The integration receives metrics using the StatsD protocol. Optionally, the sample rate can be configured and tags can be added.
Here's the metric data format we use:
<metric name>:<value>|<type>|@<sample rate>|#<tags>
Here are explanations of these fields:
Field name | Description |
---|---|
string | Required. Name of the metric. |
string | Required. The metric type:
|
float | Optional for simple counters or timer counters. When many metrics must be sent, you can use sampling to reduce network traffic. The downside is a reduction in the resolution of the data. An example of how this would work for sample rates below |
string | Optional. Tags attached to your metrics are converted into attributes (key-value pairs). For more on tagging options, see Tags. |
Metric types
Here are the types of metrics and how to format them:
Add tags (attributes)
You can add tags to your data, which we save as attributes (key-value pairs). There are two options for adding tags:
- Add default tags that apply to all metrics: These apply to all metrics. They are fixed and don't change over time.
- Add metric-level tags: These apply to specific metrics and allow the value to be changed between two submits.
Here's an example NRQL query that includes a custom tag:
SELECT count(*) FROM Metric WHERE environment = 'production'
Create alerts
You can alert on StatsD data using NRQL alert conditions.
Find and use data
To query your data, you'd use any New Relic query option. For example, you might run a NRQL query like:
SELECT count(*) FROM Metric WHERE metricName = 'myMetric' and environment = 'production'
For more on how to query the Metric
data type, see Query metric data.
Troubleshooting
Problem:
You've followed the steps to run the StatsD integration but still need to see the expected metrics in New Relic.
Solutions:
Follow the steps below to troubleshoot your configuration:
- Ensure the contains your 40 hexadecimal character license key, and it's a valid license for the selected New Relic account ID.
- Ensure the right data center, US or EU, has been selected for your New Relic account. Tip: If the license_key starts with "eu" then you must use the
NR_EU_REGION=true
flag. - Ensure there are no
NrIntegrationError
related to the StatsD integration. - Verbose logs can be enabled using the environment variable
NR_STATSD_VERBOSE
, modify the docker run command adding the following variable:-e NR_STATSD_VERBOSE=true
. - A test metric can be pushed to confirm the integration is sending metrics that are expected. Example using the NetCat
nc
utility:echo "example.gauge:123|g" | nc -u -w0 127.0.0.1 8125
(update127.0.0.1
with running container IP/address).
Check the source code
This integration is open source software. That means you can browse its source code and send improvements, or create your own fork and build it.