Hi, I'd like to understand if Druid is meant for m...
# general
i
Hi, I'd like to understand if Druid is meant for my use case. I'm tracking user status durations. There's a Kafka event when a user comes online and also when the user goes offline (simplified example). I want to submit a query with user_id, start_timestamp, and end_timestamp, and I would expect a result with durations (e.g., offline 40 minutes, online 20 minutes). I don't really see a way to do it (if a user is online for many hours and I'm querying a time series between the events, then it won't show up at all; the end timestamp might be outside my query interval, how to calculate a duration when I need the previous event, etc.). The only alternative I came up with is to process the events on the application side and send metrics (e.g., online 60 seconds, offline 0 seconds) to Druid every minute for every user. This does work, and I get a query granularity of 1 minute, but it does require processing on the application side. I'm wondering if there are better options?
r
Hi Indrek, in these scenarios, the best way is to implement a heartbeat with a certain interval that is meaningful for your use case that sends details of the current state (if the user is still logged in or not, etc.) Let me know if this makes sense for you. Happy to have to understand & brainstorm further.
j
Hi Indrek, I'm not sure how much it helps your specific application ... but a timeseries database maintains data in order sorted by time ... so queries phrases like:
Copy code
select max(__time) where __time <= target_time
and
Copy code
select min(__time) where __time >= target_time
and using latest() and earliest() functions, you should be able to gather up events both in and around your target timeframe.