Ingesting Heroku Logs into Uptrace

Ingest Heroku

You can collect logs from Heroku using Heroku's Logplex and Vector. You can then push the collected logs to Uptrace.

Heroku’s Logplex router is responsible for collating and distributing the log entries generated by your app and other components of the Heroku platform. It makes these entries available through the Logplex API and the Heroku command-line tool.

Deploying Vector to Heroku

To deploy Vector to Heroku, run the commands below:

heroku apps:create ${APP_NAME} --buildpack https://github.com/vectordotdev/vector-heroku-buildpack
heroku config:set LOGPLEX_AUTH_USERNAME ${LOGPLEX_AUTH_USERNAME}
heroku config:set LOGPLEX_AUTH_PASSWORD ${LOGPLEX_AUTH_PASSWORD}

Then you need to pull down the dyno repo and provision a configuration into it:

git clone https://git.heroku.com/${APP_NAME}.git
cd ${APP_NAME}

Vector configuration

Next, create a ./vector.toml config that contains heroku_logsopen in new window source and Uptrace sink:

[sources.heroku]
type = "heroku_logs"
address = "0.0.0.0:${PORT}"
# You can leave these as is!
# Heroku will set the environment variables that you filled while deploying.
auth.username = "${LOGPLEX_AUTH_USERNAME}"
auth.password = "${LOGPLEX_AUTH_PASSWORD}"

[sinks.uptrace]
type = "http"
method = "post"
inputs = ["heroku"]
encoding.codec = "json"
framing.method = "newline_delimited"
compression = "gzip"
request.headers.uptrace-dsn = "https://token@api.uptrace.dev/project_id"
uri = "https://api.uptrace.dev/api/v1/vector/logs"
[sources.heroku]
type = "logplex"
address = "0.0.0.0:${PORT}"
# You can leave these as is!
# Heroku will set the environment variables that you filled while deploying.
auth.username = "${LOGPLEX_AUTH_USERNAME}"
auth.password = "${LOGPLEX_AUTH_PASSWORD}"

[sinks.uptrace]
type = "http"
method = "post"
inputs = ["heroku"]
encoding.codec = "json"
framing.method = "newline_delimited"
compression = "gzip"
request.headers.uptrace-dsn = "http://project2_secret_token@localhost:14318?grpc=14317"
uri = "http://localhost:14318/api/v1/vector/logs"

When that's all done, you'll need to push up the config:

git add vector.toml
git commit -sm "Initialize Vector configuration"
git push heroku

Heroku log drain

Then, from your console, set up the log drain to sink to Vector:

heroku drains:add https://${LOGPLEX_AUTH_USERNAME}:${LOGPLEX_AUTH_PASSWORD}@${VECTOR_INSTANCE_NAME}.herokuapp.com/events -a ${YOUR_APP}
Last Updated: