Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Ability to query clickhouse to get user session messages #180

Open
Mohit21GoJs opened this issue Nov 8, 2024 · 4 comments
Open
Labels
question Further information is requested

Comments

@Mohit21GoJs
Copy link

Hi Team,

I would like to know is it recommended to query the clickhouse to query the user session history, we have an app which would like to retrieve history of messages in a session, i believe it can be achieved through clickhouse, is this a recommended practice?

@dinmukhamedm
Copy link
Member

No, I don't think that's the way to go.

While we do store session id in Clickhouse, Clickhouse is primarily an analytics tool for statistical queries such as session duration, message count per session etc. With Laminar, we store sessions in Postgres as well, and you can see them in our frontend in the sessions view. I will improve the doc with screenshots later this weekend, but here's a good starting point: https://docs.lmnr.ai/tracing/structure#grouping-traces

If you need other features in the sessions view than what we currently offer, we are always looking for feedback!

@dinmukhamedm dinmukhamedm added the question Further information is requested label Nov 8, 2024
@Mohit21GoJs
Copy link
Author

@dinmukhamedm Thanks a lot for the guidance, so for my use case we are associating session with traces and hence we are looking for query the traces for a particular session, afaik i see an endpoint to get all sessions which is reading sessions from database but in our case we need something like GET /sessions/:sessionId which returns us all the traces of a particular session as we would like to use it in our dashboard for our app. Do you think it makes sense here?

@dinmukhamedm
Copy link
Member

dinmukhamedm commented Nov 12, 2024

@Mohit21GoJs I get what you mean. This data can be queried from Postgres. It would essentially be something (roughly) like:

SELECT * FROM traces
-- optionally JOIN spans ON spans.trace_id = traces.id
WHERE session_id = '<YOUR_SESSION_ID>'

The traces table is already indexed on session_id with B-Tree index, so this query should be fast, though hash index may make a little bit more sense for this case.

I didn't quite get from your message though – is this something you would like to see in Laminar or something you would want to implement yourself using Laminar's data stores?

@Mohit21GoJs
Copy link
Author

@dinmukhamedm Thanks for the solution. I believe the database query will work but in my opinion this is a feature that should be owned by lmnr app server as it is owning the database and if you believe this api can help laminar vision i can create a task and create a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants