Setting up something like newrelic for railway
Anonymous
PROOP

4 months ago

Has anyone got newrelic working on their railway services? I am coming from kube where I had a lot of uses for newrelic, like the APM tracing, unified logs, service crash reporting, in app error notifications that go to slack, unified logs and searching, metrics reporting etc... so far i've lost all that on railway and I can't seem to get newrelic to work. How do others handle all this on railway?

$10 Bounty

5 Replies

Railway
BOT

4 months ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


4 months ago

I have gotten New Relic to work on Railway, it was a very long time ago so I can't remember exactly what process I took. If I remember correctly, I have 2 services to export MongoDB stuff (NRI Prometheus and some person's MongoDB exporter service made for New Relic), and for the actual services I simply used New Relic's NodeJS hook (iirc)


Anonymous
PROOP

4 months ago

I've added the newrelic agent and it actually looks like it's collecting my APM trace data, but it doesn't seem to be collecting any of my logs


4 months ago

yea I had trouble getting the logs working too, I don't think i got it working in the end


Anonymous
PROOP

4 months ago

well the AI added this script to my docker entry point file and it appears to work, I'm now collecting logs, something do with how railway issues its start command on a docker container

#!/bin/sh
set -eo pipefail
npm run migrate

# Inject -r newrelic if command contains 'node' and doesn't already have it
# This ensures New Relic is loaded before any code runs for log forwarding
CMD_STR="$*"
FINAL_CMD="$*"
if echo "$CMD_STR" | grep -q "node" && ! echo "$CMD_STR" | grep -q "\-r newrelic"; then
    echo "=== ENTRYPOINT: Injecting -r newrelic for log forwarding ==="
    # Build new command with -r newrelic after 'node' (POSIX-compatible)
    FIRST_NODE=true
    NEW_CMD=""
    for arg in "$@"; do
        if [ "$arg" = "node" ] && [ "$FIRST_NODE" = "true" ]; then
            NEW_CMD="$NEW_CMD node -r newrelic"
            FIRST_NODE=false
        else
            NEW_CMD="$NEW_CMD $arg"
        fi
    done
    # Remove leading space
    FINAL_CMD=$(echo "$NEW_CMD" | sed 's/^ //')
    echo "=== ENTRYPOINT: Modified command: $FINAL_CMD ==="
fi

exec sh -c "$FINAL_CMD"

Loading...