Browsing logs
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.16 Replies
Project ID:
N/A
N/A
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
https://railway.app/template/jP9r-f 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
-<filter text>
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
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 deploymentI'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 -<filter text>ah, nice, thanks Brody - yeah i've seen that syntex before, but somehow just forgot about it and thanks for the reply, sorry i didn't see it until now
no worries, let me know if you have any more questions or want clarification on anything
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
the
-
filter will come in very handy until thenwould 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
locomotive ships your logs into betterstack or axiom, here's a screenshot from just the log view of axiom
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
this is presumably what you are referring to? https://railway.app/template/jP9r-f
yep, that's the template I used to get the logs in my screenshot into axiom
these logs where originally only printed to stdout and locomotive picked them up and shipped them to axiom
that means your service requires no code changes at all, assuming you are already JSON logging
ah, nice
(but locomotive also supports plain text logs) but those aren't really useful in the grand scheme of things
good to know
let me know if you have any difficulties with locomotive
and just keep in mind, it will ship the build logs too
yes, thanks
this worked flawlessly, thanks
awsome, im happy to hear that