# convert DQL log  query to timeseries

**URL:** <https://community.dynatrace.com/t/convert-dql-log-query-to-timeseries/45077>\
**Category:** DQL\
**Tags:** dql, kubernetes, logs\
**Created:** [April 10, 2024, 12:11pm UTC](https://community.dynatrace.com/t/convert-dql-log-query-to-timeseries/45077 "2024-04-10T12:11:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![roberto\_camp1](https://avatars.discourse-cdn.com/v4/letter/r/b2d939/32.png) [@roberto\_camp1](https://community.dynatrace.com/u/roberto_camp1)\
**Post date:** [April 10, 2024, 12:11pm UTC](https://community.dynatrace.com/t/convert-dql-log-query-to-timeseries/45077/1 "2024-04-10T12:11:48Z")

</div>

So far I have the following DQL query that works:

```

fetch logs  
| filter dt.entity.kubernetes\_cluster == “KUBERNETES\_CLUSTER-ABCDEFG” or in(dt.entity.kubernetes\_cluster, “KUBERNETES\_CLUSTER-ABCDEFG”)  
| summarize total = count(), errTotal = countIf(status == “ERROR”)

| fieldsAdd errPercent = (toDouble(errTotal)\*100 / total)

```

Is it possible to convert this to a timeseries using makeTimeSeries, such that this can be graphed over time or converted to a metric that we can alert on?&nbsp; So far I can’t quite get the syntax right for `makeTimeSeries`.

---

<div class="post-metadata">

**Author:** ![MichalOlszewski](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@MichalOlszewski](https://community.dynatrace.com/u/MichalOlszewski)\
**Post date:** [April 10, 2024, 1:50pm UTC](https://community.dynatrace.com/t/convert-dql-log-query-to-timeseries/45077/2 "2024-04-10T13:50:29Z")

</div>

Hi&nbsp;[@roberto\_camp1](https://community.dynatrace.com/user/67600)

To create a timeseries from your query you cannot use the “summarize” command, because then you create a summary from all the data that the query returned in the form of a single record.

It is possible to create a timeseries that, for example, draws the number of logs with ERROR status versus the number of all logs, in your case:

fetch logs

| filter dt.entity.kubernetes\_cluster == “KUBERNETES\_CLUSTER-ABCDEFG” or in(dt.entity.kubernetes\_cluster, “KUBERNETES\_CLUSTER-ABCDEFG”)

| makeTimeseries error\_logs = countIf(loglevel == “ERROR”), all\_logs = count()

Bests  
Michal

---

<div class="post-metadata">

**Author:** ![roberto\_camp1](https://avatars.discourse-cdn.com/v4/letter/r/b2d939/32.png) [@roberto\_camp1](https://community.dynatrace.com/u/roberto_camp1)\
**Post date:** [April 10, 2024, 3:23pm UTC](https://community.dynatrace.com/t/convert-dql-log-query-to-timeseries/45077/3 "2024-04-10T15:23:49Z")

</div>

That works for coverting my basic query into timeSeries, so thank you, but my requirement remains to observe the % of error log messsages over time.&nbsp; I have tried to add that to your solution but getting errrors:

,

fetch logs

| filter dt.entity.kubernetes\_cluster == “KUBERNETES\_CLUSTER-763AC7E6FD9C1ED1” or in(dt.entity.kubernetes\_cluster, “KUBERNETES\_CLUSTER-763AC7E6FD9C1ED1”)

| makeTimeseries error\_logs = countIf(loglevel == “ERROR”), all\_logs = count(), errPercent = (toDouble(error\_logs)\*100 / all\_logs)

‘’’

ERR MSG: “Mandatory parameter has to be.The parameter has to be an expression-based timeseries aggregation.”

---

<div class="post-metadata">

**Author:** ![krzysztof\_hoja](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/krzysztof_hoja/32/34625_2.png) [@krzysztof\_hoja](https://community.dynatrace.com/u/krzysztof_hoja)\
**Post date:** [April 10, 2024, 6:30pm UTC](https://community.dynatrace.com/t/convert-dql-log-query-to-timeseries/45077/4 "2024-04-10T18:30:36Z")

</div>

You need to calculate percentage as a additional step:

```markup
| fieldsAdd errPercent = 100*toDouble(error_logs[]) / all_logs[]

```

Kris
