2 years 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
2 years 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 `-
2 years 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
2 years 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
> 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 -
2 years ago
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
2 years 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
2 years ago
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
2 years ago
yep, that's the template I used to get the logs in my screenshot into axiom
2 years ago
these logs where originally only printed to stdout and locomotive picked them up and shipped them to axiom
2 years ago
that means your service requires no code changes at all, assuming you are already JSON logging
2 years ago
(but locomotive also supports plain text logs) but those aren't really useful in the grand scheme of things
2 years ago
let me know if you have any difficulties with locomotive
2 years ago
and just keep in mind, it will ship the build logs too
2 years ago
awsome, im happy to hear that