Skip to main content
This guide shows how to route both New Relic metric paths from a Java app through Sawmills. For collector endpoint exposure, first complete How to send data to the Sawmills collector.

Prerequisites

  • A running Sawmills Collector with a New Relic source configured
  • A New Relic license key
  • A Java app instrumented with the New Relic Java agent and/or Telemetry SDK

Environment Variables

Set both variables to route all telemetry through Sawmills. If you only set one, part of your data bypasses Sawmills.
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
Your <collector-id> is shown in the Sawmills UI under your pipeline’s collector details.
Setting only one of these variables causes partial routing — some telemetry will go directly to New Relic instead of through Sawmills.

Configure the Java app

export NEW_RELIC_LICENSE_KEY="<your-license-key>"
export NEW_RELIC_HOST="<collector-id>.collectors.sawmills.ai:10000"
export NEW_RELIC_METRICS_HOST="https://<collector-id>.collectors.sawmills.ai:10000"
For Kubernetes, inject both values from a ConfigMap:
env:
  - name: NEW_RELIC_LICENSE_KEY
    valueFrom:
      secretKeyRef:
        name: newrelic-license
        key: license_key
  - name: NEW_RELIC_HOST
    valueFrom:
      configMapKeyRef:
        name: newrelic-config
        key: NEW_RELIC_HOST
  - name: NEW_RELIC_METRICS_HOST
    valueFrom:
      configMapKeyRef:
        name: newrelic-config
        key: NEW_RELIC_METRICS_HOST
Restart the deployment after changes:
kubectl rollout restart deployment/<your-app>

Verify

  1. Check application logs for connection to your Sawmills collector endpoint.
  2. Validate metrics in New Relic:
SELECT count(*) FROM Metric WHERE metricName LIKE 'system.%' SINCE 5 minutes ago

Troubleshooting

SymptomFix
Only some metrics go through SawmillsSet both NEW_RELIC_HOST and NEW_RELIC_METRICS_HOST
Dimensional metrics failUse a base URL only for NEW_RELIC_METRICS_HOST — don’t append /metric/v1
No data arrivesVerify DNS reachability to <collector-id>.collectors.sawmills.ai from the app
Changes not taking effectRestart the deployment after updating env vars