Any advice on extracting records from logs/messages.json


(Karl) #1

Hi all,

I’ve become interested in polling (and acting on) the data at Discourse’s /logs endpoint (from Python, not that it is relevant to the question).

TL;DR: Has anyone managed to extract filtered information from /logs/messages.json?

Full version:

I’ve established the data displayed on /logs/ comes from messages.json

Other than that I’ve also determined a couple of URLs which should do /something/ but I’ve had very little success extracting the data I want

Filtering log levels

https://example/logs/messages.json?filter=0_1_2_3_4_5

Filtering log levels is one thing that does actually do what I expect - i can remove items and the number of results changes.

filter = an underscore separated list of error levels to display (Debug to Fatal)

After

https://example/logs/messages.json?after=3dc47c8c17d56479ea737433a4b7b903

I was expecting this to return only records after that entry (which is a nonce from an SSO record) but from a look at the code it doesn’t appear the ‘after’ bit is actually wired in?

If it is wired in I assume I’m using the wrong value to filter ‘after’ on.

individual records

Based on these links I assumed I would be able to show individual records

I’ve been equally unable to show based on nonce, seeing the message “Message not found” when I visit the url.

https://example.com/logs/show/2db444fa00ee2084ab76a5034e169f76.json

regex search

I figured out I need regex_search set true

What I can’t figure out is how to use the regex - as with /show/ I’m seeing the “Message not found” or (unlike /show/) everything returned.

I can see the regex required (and that it has insensitive searching support), I haven’t figured out how to encode it for transmission - posted? url encode? Post seems wrong from looking at the code.

So, anyone have any suggestions on where I can investigate further?

thanks,