<?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 Making timeseries from logs in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Making-timeseries-from-logs/m-p/253848#M1143</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I would like to generate a simple line chart showing a connection status which goes from 0(closed) to 1(open). Quite simple but...&lt;/P&gt;&lt;P&gt;I tried something like below but it did not work as I want. I think the problem I have is that the connection metric does not stay at value "1" till "closed" is emitted.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;data record(timestamp = toTimestamp("2024-08-17T09:30:00.000-0400"), msg ="opened"),
     record(timestamp = toTimestamp("2024-08-18T09:31:00.000-0400"), msg ="closed"),
     record(timestamp = toTimestamp("2024-08-19T09:30:00.000-0400"), msg ="opened"),
     record(timestamp = toTimestamp("2024-08-20T09:31:00.000-0400"), msg ="closed"),
     record(timestamp = toTimestamp("2024-08-21T09:31:30.000-0400"), msg ="opened"),
     record(timestamp = toTimestamp("2024-08-21T22:32:00.000-0400"), msg ="closed")
| makeTimeseries {
   opened=countIf(msg=="opened",default: 0),
   closed=countIf(msg=="closed",default: 0) }
| fieldsAdd connection=opened[]-closed[]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Any help would much appreciated.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
    <pubDate>Wed, 21 Aug 2024 21:03:09 GMT</pubDate>
    <dc:creator>PiotrJS</dc:creator>
    <dc:date>2024-08-21T21:03:09Z</dc:date>
    <item>
      <title>Making timeseries from logs</title>
      <link>https://community.dynatrace.com/t5/DQL/Making-timeseries-from-logs/m-p/253848#M1143</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I would like to generate a simple line chart showing a connection status which goes from 0(closed) to 1(open). Quite simple but...&lt;/P&gt;&lt;P&gt;I tried something like below but it did not work as I want. I think the problem I have is that the connection metric does not stay at value "1" till "closed" is emitted.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;data record(timestamp = toTimestamp("2024-08-17T09:30:00.000-0400"), msg ="opened"),
     record(timestamp = toTimestamp("2024-08-18T09:31:00.000-0400"), msg ="closed"),
     record(timestamp = toTimestamp("2024-08-19T09:30:00.000-0400"), msg ="opened"),
     record(timestamp = toTimestamp("2024-08-20T09:31:00.000-0400"), msg ="closed"),
     record(timestamp = toTimestamp("2024-08-21T09:31:30.000-0400"), msg ="opened"),
     record(timestamp = toTimestamp("2024-08-21T22:32:00.000-0400"), msg ="closed")
| makeTimeseries {
   opened=countIf(msg=="opened",default: 0),
   closed=countIf(msg=="closed",default: 0) }
| fieldsAdd connection=opened[]-closed[]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Any help would much appreciated.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 21:03:09 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Making-timeseries-from-logs/m-p/253848#M1143</guid>
      <dc:creator>PiotrJS</dc:creator>
      <dc:date>2024-08-21T21:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: Making timeseries from logs</title>
      <link>https://community.dynatrace.com/t5/DQL/Making-timeseries-from-logs/m-p/254434#M1147</link>
      <description>&lt;P&gt;I would be possible if we had a function to calculate cumulative sum for given array. Because we do not have such function we can use arrayMovingSum which will work for timeseries no longer then 60 elements. Result of query with such addition:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;data record(timestamp = toTimestamp("2024-08-17T09:30:00.000-0400"), msg ="opened"),
     record(timestamp = toTimestamp("2024-08-18T09:31:00.000-0400"), msg ="closed"),
     record(timestamp = toTimestamp("2024-08-19T00:00:00.000-0400"), msg ="opened"),
     record(timestamp = toTimestamp("2024-08-19T02:00:00.000-0400"), msg ="closed"),
     record(timestamp = toTimestamp("2024-08-19T09:30:00.000-0400"), msg ="opened"),
     record(timestamp = toTimestamp("2024-08-20T09:31:00.000-0400"), msg ="closed"),
     record(timestamp = toTimestamp("2024-08-21T09:31:30.000-0400"), msg ="opened"),
     record(timestamp = toTimestamp("2024-08-21T22:32:00.000-0400"), msg ="closed")
| makeTimeseries {
   opened=countIf(msg=="opened",default: 0),
   closed=countIf(msg=="closed",default: 0) }, 
   from: toTimestamp("2024-08-17T00:00:00.000-0400"), to: toTimestamp("2024-08-22T00:00:00.000-0400"), interval:2h
| fieldsAdd opened=arrayMovingSum(opened, 60), closed=arrayMovingSum(closed, 60)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;looks like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="krzysztof_hoja_0-1724877492321.png" style="width: 859px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/22073i546DFD63759E2BDE/image-dimensions/859x277?v=v2" width="859" height="277" role="button" title="krzysztof_hoja_0-1724877492321.png" alt="krzysztof_hoja_0-1724877492321.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Now substation&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| fields connection=opened[]-closed[], interval, timeframe&lt;/LI-CODE&gt;&lt;P&gt;should give expected effect:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="krzysztof_hoja_1-1724877626342.png" style="width: 907px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/22074iD266171ACAC460B2/image-dimensions/907x275?v=v2" width="907" height="275" role="button" title="krzysztof_hoja_1-1724877626342.png" alt="krzysztof_hoja_1-1724877626342.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Please to that this method has some limitations:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;changes from "Closed" to "Open" and back to "Closed" in same interval is invisible.&lt;/LI&gt;&lt;LI&gt;lost event/log line will produce results hard to explain&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Kris&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2024 20:43:31 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Making-timeseries-from-logs/m-p/254434#M1147</guid>
      <dc:creator>krzysztof_hoja</dc:creator>
      <dc:date>2024-08-28T20:43:31Z</dc:date>
    </item>
  </channel>
</rss>

