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.
| Variable | Controls | Format | Example |
|---|
NEW_RELIC_HOST | Java agent (timeslice metrics) | host:port | <collector-id>.collectors.sawmills.ai:10000 |
NEW_RELIC_METRICS_HOST | Telemetry SDK (dimensional metrics) | https://host:port | https://<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.
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
- Check application logs for connection to your Sawmills collector endpoint.
- Validate metrics in New Relic:
SELECT count(*) FROM Metric WHERE metricName LIKE 'system.%' SINCE 5 minutes ago
Troubleshooting
| Symptom | Fix |
|---|
| Only some metrics go through Sawmills | Set both NEW_RELIC_HOST and NEW_RELIC_METRICS_HOST |
| Dimensional metrics fail | Use a base URL only for NEW_RELIC_METRICS_HOST — don’t append /metric/v1 |
| No data arrives | Verify DNS reachability to <collector-id>.collectors.sawmills.ai from the app |
| Changes not taking effect | Restart the deployment after updating env vars |