A Railway sidecar service for sending webhook events when new logs are received.
Nearly equivalent to Heroku's log drain, but for Railway.
With tailored support for:
Datadog
Axiom
BetterStack
Loki
Sentry
Papertrail
OpenTelemetry HTTP
And more with the standard JSON and JSON Lines modes.
Configuration
Configuration is done through environment variables. See explanation and examples below.
Notes:
Metadata such as the project, service, and environment names, along with their IDs, are automatically added to the logs that are sent under a _metadata attribute.
Metadata is gathered on startup and then approximately every 10 to 20 minutes. If a project, service, or environment name has changed, the name in the metadata will not be correct until the locomotive refreshes its metadata.
The root attributes in the HTTP logs are subject to change as Railway adds or removes attributes.
All variables:
LOCOMOTIVE_RAILWAY_API_KEY - Your Railway API token.
Upon startup, Locomotive will verify that all the services exist within the set environment. If the environment does not exist, Locomotive will exit with an API error message.
If that check fails with an unauthorized error, you are likely using the wrong kind of API token.
LOCOMOTIVE_SERVICE_IDS - The IDs of the services you want to monitor.
Required.
Supports a single service ID.
Supports multiple service IDs, separated with a comma.
Upon startup, Locomotive will verify that all the services exist within the set environment. If any services do not exist, Locomotive will exit with an error and provide a list of the missing services.
If that check fails with an unauthorized error, you are likely using the wrong kind of API token.
LOCOMOTIVE_WEBHOOK_URL - The URL to send the webhook to.
Required.
Example for Datadog: https://http-intake.logs.datadoghq.com/api/v2/logs
Example for Axiom: https://api.axiom.co/v1/datasets/<DATASET_NAME>/ingest
Example for BetterStack: https://in.logs.betterstack.com
Example for OpenTelemetry HTTP: https://<OTEL_HTTP_ENDPOINT>/v1/logs
LOCOMOTIVE_ADDITIONAL_HEADERS - Any additional headers to be sent with the request.
Optional.
Useful for authentication. The string is in the format of a cookie, meaning each key-value pair is separated by a semicolon, and each key and value are separated by an equals sign.
Example for Datadog: ADDITIONAL_HEADERS=DD-API-KEY=<DD_API_KEY>;DD-APPLICATION-KEY=<DD_APP_KEY>
Example for Axiom/BetterStack: ADDITIONAL_HEADERS=Authorization=Bearer <API_TOKEN>
The hostname can be found in the 'Client Keys (DSN)' section of the Sentry project settings; it will be the hostname of the given DSN.
The project ID can be also be found in the 'Client Keys (DSN)' section of the Sentry project settings, it will be the path in the URL of the given DSN.