How to write this subquery



  • Official comment
    Graham Watts

    Hey Alex,

    Transactionize can be very useful especially in this type of use case.

    Another way to get the duration is to use max() and min(), then do some math by each trace-id:

    | max(_messagetime), min(_messagetime) by trace-id
    | _max-_min as duration

    You may also want to do this over time to show on a dashboard, in the below case you would want to use some query logic to remove traces where the start time is before the timeslice start or the end time is after the timeslice end:

    | timeslice 10m
    | max(_messagetime), min(_messagetime) by trace-id, _timeslice
    | _max-_min as duration_ms | duration_ms/1000 as duration_sec
    | pct(duration_sec,50,95) by _timeslice

    Hope this helps!

    Comment actions Permalink
  • Avatar
    Alex Rohde

    Somebody answered me in slack. The answer is not to use a subquery, but rather the "transaction" keyword

    Comment actions Permalink

Please sign in to leave a comment.