Browsing logs
arnorhs
PROOP

a year ago

I have a fastify app deployed and sometimes i'll have to find log messages.. however the default request logging in fastify uses just a fixed message, so figuring out which url is being hit in railway etc is super cumbersome and querying deeploy by @req.url:"/my/api/endpoint" is a bit annoying

identifying responses with errors can also be tricky - since you can't really glance through a filtered list to see the error - but open up each one individually

Right now my request log looks like the attached screenshot

Ideally i'd like to group the log messages by the request id or something - . Would I just need to create my own application for this by ingesting the railway api ? Do you know if anybody has built a tool that makes this a little easier?

Another thing is that i'd like to filter out some things.. for example the CORS pre-flight requests - but i can't figure out the right log-filter syntax to use for omitting things.

24 Replies

arnorhs
PROOP

a year ago

N/A


brody
EMPLOYEE

a year ago

railway did want to make it so that commonly logged attributes would show up automatically as rows besides the message attribute but never got around to it, and unfortunately you can't filter logs that are printed with an attribute instead you can only filter by an attributes value.

as for identifying errors, print them with the error level and they will be coloured red, and then you can also filter by the level attribute.

this is a template for sending your logs to discord / betterstack / axiom
read the GitHub for more info

I'm not sure if the docs mention it but excluding logs would be done by adding a dash or a negative symbol to the filter like `-


brody
EMPLOYEE

a year ago

for transparency, with railways V2 builder and V2 runtime that template may have the same log issues as my bookmarklet did if you remember that issue, I'll be testing the template again soon and making any needed changes


brody
EMPLOYEE

a year ago

update: the template will ship both your build and deployment logs for a given service since there is no longer a good way to differentiate between the two types while also staying subscribed to the service itself instead of an individual deployment


arnorhs
PROOP

a year ago

> I'm not sure if the docs mention it but excluding logs would be done by adding a dash or a negative symbol to the filter like -


arnorhs
PROOP

a year ago

and thanks for the reply, sorry i didn't see it until now


brody
EMPLOYEE

a year ago

no worries, let me know if you have any more questions or want clarification on anything


arnorhs
PROOP

a year ago

i might go ahead and make a log aggregator for myself that gives me easy view over the things that i need.. it's hard to make a log viewer that handles everybody's use cases - you basically end up with your own datadog


arnorhs
PROOP

a year ago

the - filter will come in very handy until then


brody
EMPLOYEE

a year ago

would betterstack or axiom not work for you here? they both have far finer control over the logs and give you the options to make dashboards out of the data you log


brody
EMPLOYEE

a year ago

locomotive ships your logs into betterstack or axiom, here's a screenshot from just the log view of axiom

1253028949693563000


arnorhs
PROOP

a year ago

yeah, that would work - i used axiom the other day for a cloudflare functions based thing - i just wasn't aware of tools that were able to read/aggregate the railway log into it


arnorhs
PROOP

a year ago

this is presumably what you are referring to? https://railway.app/template/jP9r-f


brody
EMPLOYEE

a year ago

yep, that's the template I used to get the logs in my screenshot into axiom


brody
EMPLOYEE

a year ago

these logs where originally only printed to stdout and locomotive picked them up and shipped them to axiom


brody
EMPLOYEE

a year ago

that means your service requires no code changes at all, assuming you are already JSON logging


arnorhs
PROOP

a year ago

ah, nice


brody
EMPLOYEE

a year ago

(but locomotive also supports plain text logs) but those aren't really useful in the grand scheme of things


arnorhs
PROOP

a year ago

good to know


brody
EMPLOYEE

a year ago

let me know if you have any difficulties with locomotive


brody
EMPLOYEE

a year ago

and just keep in mind, it will ship the build logs too


arnorhs
PROOP

a year ago

yes, thanks


arnorhs
PROOP

a year ago

this worked flawlessly, thanks


brody
EMPLOYEE

a year ago

awsome, im happy to hear that


Loading...