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.
No description
16 Replies
Percy
Percy3w ago
Project ID: N/A
Arnór
Arnór3w ago
N/A
Brody
Brody3w 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 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 deployment
Arnór
Arnór3w 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 -<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
Brody
Brody3w ago
no worries, let me know if you have any more questions or want clarification on anything
Arnór
Arnór3w 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 the - filter will come in very handy until then
Brody
Brody3w 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
Brody3w ago
locomotive ships your logs into betterstack or axiom, here's a screenshot from just the log view of axiom
No description
Arnór
Arnór3w 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 this is presumably what you are referring to? https://railway.app/template/jP9r-f
Brody
Brody3w ago
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
Arnór
Arnór3w ago
ah, nice
Brody
Brody3w ago
(but locomotive also supports plain text logs) but those aren't really useful in the grand scheme of things
Arnór
Arnór3w ago
good to know
Brody
Brody3w ago
let me know if you have any difficulties with locomotive and just keep in mind, it will ship the build logs too
Arnór
Arnór3w ago
yes, thanks this worked flawlessly, thanks
Brody
Brody3w ago
awsome, im happy to hear that