Skip to main content

Supported Data Types

📈 Metrics

Overview

The New Relic source accepts metrics from the New Relic Metric API and the New Relic Agent protocol. Metric API payloads are received on metrics_path, and Agent payloads use agent_base_path with a method query parameter.

Configuration

FieldTypeDefaultRequiredDescription
NameStringnonetrueUnique identifier within Sawmills.
EndpointString0.0.0.0:14275trueHTTP listen address for New Relic payloads.
Metrics PathString/metric/v1truePath for New Relic Metric API requests.
Agent Base PathString/agent_listener/invoke_raw_methodtruePath for New Relic Agent protocol requests.
Agent EndpointStringhttps://collector.newrelic.com/agent_listener/invoke_raw_methodtrueUpstream New Relic agent endpoint used to proxy preconnect and connect.

Send metrics to the collector

Point your app’s New Relic endpoints at the Sawmills collector. You need to configure two environment variables:
VariableControlsFormatExample
NEW_RELIC_HOSTJava agent (timeslice metrics)host:port<collector-id>.collectors.sawmills.ai:10000
NEW_RELIC_METRICS_HOSTTelemetry SDK (dimensional metrics)https://host:porthttps://<collector-id>.collectors.sawmills.ai:10000
Both must be set. If you only set one, part of your telemetry bypasses Sawmills. Your <collector-id> is shown in the Sawmills UI under your pipeline’s collector details. For a full Java app walkthrough, see How to send data from a New Relic Java app. Minimal Telemetry SDK example:
// NEW_RELIC_METRICS_HOST="https://<collector-id>.collectors.sawmills.ai:10000"
String host = System.getenv("NEW_RELIC_METRICS_HOST");
String licenseKey = System.getenv("NEW_RELIC_LICENSE_KEY");

MetricBatchSender sender = MetricBatchSender.create(
  MetricBatchSenderFactory.fromHttpImplementation(OkHttpPoster::new)
    .configureWith(licenseKey)
    .endpoint(new URL(host + "/metric/v1"))
    .build()
);

Attributes common = new Attributes()
  .put("service.name", appName)
  .put("environment", environment);

MetricBuffer buffer = new MetricBuffer(common);
buffer.addMetric(new Gauge(
  "service.response.time",
  0.5,
  System.currentTimeMillis(),
  new Attributes().put("cluster", "default").put("region", "us-east-1")
));

sender.sendBatch(buffer.createBatch());

Metric API Format

Supported metric types:
  • gauge
  • count (requires interval.ms)
  • summary

Agent Protocol

Supported methods:
  • preconnect
  • connect
  • metric_data
Agent metrics are converted to Summary metrics and include:
  • count
  • sum
  • min and max (as quantiles 0 and 1)
  • sawmills.scope attribute when present
  • sawmills.exclusive_time attribute
  • sawmills.sum_squares attribute

Example Payloads

Metric API

[
  {
    "common": {
      "timestamp": 1700000000000,
      "interval.ms": 10000,
      "attributes": {"host.name": "server1"}
    },
    "metrics": [
      {
        "name": "service.response.time",
        "type": "gauge",
        "value": 0.5
      },
      {
        "name": "service.requests",
        "type": "count",
        "value": 100
      }
    ]
  }
]

Agent (metric_data)

["agent-run-id", 1700000000, 1700000060, [
  [{"name": "WebTransaction/Go/handler"}, [10, 5.5, 3.2, 0.1, 2.5, 15.0]],
  [{"name": "Datastore/MySQL/query", "scope": "WebTransaction/Go/handler"}, [5, 0.5, 0.5, 0.05, 0.2, 0.1]]
]]