<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Latency calculation based on logs timestamp in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Latency-calculation-based-on-logs-timestamp/m-p/274152#M1883</link>
    <description>&lt;P&gt;This can be accomplished by first sumamrizing on the transaction id, then calculating the duration, and finally using the makeTimeSeries command to plot this over time.&lt;/P&gt;&lt;P&gt;Here's some sample DQL to get you started&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// dummy data for testing purposes
data record(transaction_id="tx1", logpoint="response-in", timestamp = now()-20m),
     record(transaction_id="tx1", logpoint="request-out", timestamp = now()-21m),
     record(transaction_id="tx2", logpoint="response-in", timestamp = now()-10m),
     record(transaction_id="tx2", logpoint="request-out", timestamp = now()-12m)

// summarize to create a single record containing the start and end time of each transaction
| summarize { timestamp.start = min(timestamp), 
              timestamp.end = max(timestamp)
            },
            by: { transaction_id }

// calculate duration
| fieldsAdd duration = timestamp.end - timestamp.start

// create a timeseries
| makeTimeseries {interval.start = start(),
                  interval.end = end(),
                  duration = avg(duration)
                  },
                  time:timestamp.start,
                  nonempty:true,
                  interval: 1m,
                  by:{ transaction_id }&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 01 Apr 2025 23:06:24 GMT</pubDate>
    <dc:creator>marco_irmer</dc:creator>
    <dc:date>2025-04-01T23:06:24Z</dc:date>
    <item>
      <title>Latency calculation based on logs timestamp</title>
      <link>https://community.dynatrace.com/t5/DQL/Latency-calculation-based-on-logs-timestamp/m-p/274052#M1879</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I have some logs with this general structure:&lt;/P&gt;&lt;P&gt;{timestamp: t1, logpoint:"request-out", transaction-id: tx1, other stuff}&lt;/P&gt;&lt;P&gt;{timestamp: t2, logpoint:"response-in", transaction-id: tx1, other stuff}&lt;/P&gt;&lt;P&gt;{timestamp: t3, logpoint:"request-out", transaction-id: tx2, other stuff}&lt;/P&gt;&lt;P&gt;{timestamp: t4, logpoint:"response-in", transaction-id: tx2, other stuff}&lt;/P&gt;&lt;P&gt;I need to plot a chart with the latency (duration) of each transaction-id, so essentially the difference between timestamps t2 and t1 for tx1, then t4 - t3 for tx2, and so on. Therefore I would need a query that returns a timeseries containing the values for the latency on the y axis, and either transaction-ids or just timestamp for response-in on the y axis.&lt;/P&gt;&lt;P&gt;Any suggestion is appreciated. Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 01 Apr 2025 11:19:30 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Latency-calculation-based-on-logs-timestamp/m-p/274052#M1879</guid>
      <dc:creator>VladS</dc:creator>
      <dc:date>2025-04-01T11:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: Latency calculation based on logs timestamp</title>
      <link>https://community.dynatrace.com/t5/DQL/Latency-calculation-based-on-logs-timestamp/m-p/274152#M1883</link>
      <description>&lt;P&gt;This can be accomplished by first sumamrizing on the transaction id, then calculating the duration, and finally using the makeTimeSeries command to plot this over time.&lt;/P&gt;&lt;P&gt;Here's some sample DQL to get you started&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// dummy data for testing purposes
data record(transaction_id="tx1", logpoint="response-in", timestamp = now()-20m),
     record(transaction_id="tx1", logpoint="request-out", timestamp = now()-21m),
     record(transaction_id="tx2", logpoint="response-in", timestamp = now()-10m),
     record(transaction_id="tx2", logpoint="request-out", timestamp = now()-12m)

// summarize to create a single record containing the start and end time of each transaction
| summarize { timestamp.start = min(timestamp), 
              timestamp.end = max(timestamp)
            },
            by: { transaction_id }

// calculate duration
| fieldsAdd duration = timestamp.end - timestamp.start

// create a timeseries
| makeTimeseries {interval.start = start(),
                  interval.end = end(),
                  duration = avg(duration)
                  },
                  time:timestamp.start,
                  nonempty:true,
                  interval: 1m,
                  by:{ transaction_id }&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 01 Apr 2025 23:06:24 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Latency-calculation-based-on-logs-timestamp/m-p/274152#M1883</guid>
      <dc:creator>marco_irmer</dc:creator>
      <dc:date>2025-04-01T23:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: Latency calculation based on logs timestamp</title>
      <link>https://community.dynatrace.com/t5/DQL/Latency-calculation-based-on-logs-timestamp/m-p/274159#M1884</link>
      <description>&lt;P&gt;Thank you very much! Exactly what I needed&lt;/P&gt;</description>
      <pubDate>Wed, 02 Apr 2025 05:35:30 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Latency-calculation-based-on-logs-timestamp/m-p/274159#M1884</guid>
      <dc:creator>VladS</dc:creator>
      <dc:date>2025-04-02T05:35:30Z</dc:date>
    </item>
  </channel>
</rss>

