# Apply Regex on Custom Metric Series Using DQL

**URL:** <https://community.dynatrace.com/t/apply-regex-on-custom-metric-series-using-dql/49374>\
**Category:** DQL\
**Tags:** regex, dql, dynatrace-managed, notebooks\
**Created:** [December 16, 2024, 11:09am UTC](https://community.dynatrace.com/t/apply-regex-on-custom-metric-series-using-dql/49374 "2024-12-16T11:09:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![NitinOjha003](https://avatars.discourse-cdn.com/v4/letter/n/b2d939/32.png) [@NitinOjha003](https://community.dynatrace.com/u/NitinOjha003)\
**Post date:** [December 16, 2024, 11:09am UTC](https://community.dynatrace.com/t/apply-regex-on-custom-metric-series-using-dql/49374/1 "2024-12-16T11:09:24Z")

</div>

We are pushing out metrics through Otel into both Newrelic and Dynatrace. We are in process of migrating out our application metric data from newrelic to dynatrace.  
In&nbsp;**NRQL, we use these queries:  
1.** SELECT sum(`sling.cmw.b-cmwnext-player.PlayerHandler%.failure_totals`) / sum(`sling.cmw.b-cmwnext-player.PlayerHandler%.request_totals`) \* 100 as ‘Error Rate’ FROM Metric WHERE entity.name LIKE ‘%-cmwnext-player’ FACET cluster\_name SINCE 1 hour ago\*\*[For error\_rate]

2.\*\*

SELECT count(\*) FROM Metric WHERE pod\_name LIKE ‘cmwnext-profiles%’ AND metricName LIKE ‘sling.cmw.b-cmwnext-profiles%.request\_totals’

AND cluster\_name LIKE ‘b-a%’ FACET cluster\_name,metricName SINCE 1 hour ago LIMIT 200 \*\*[For throughput Handler/route wise across cluster]

We are able to use regex with string based handler routes(sling.cmw.b-cmwnext-player.PlayerHandlerScreen.request\_totals). We are unable to use regex properly here in DQL as we are able to do in NRQL.Please suggest some solution to avoid these complex queries for throughput, error\_rate etc.

For similar queries in Dynatrace , we are using these complex and bulk queries&nbsp; and at last doing aggregation to get throughput and error\_rate

IN DQL, We are using\*\*&nbsp;  
1.&nbsp;  
timeseries {  
request\_screen\_totals=sum(`sling.cmw.b-cmwnext-player.PlayerHandlerScreen.request_totals`, default: 0),  
request\_content\_totals=sum(`sling.cmw.b-cmwnext-player.PlayerHandlerContent.request_totals`, default: 0),  
request\_bar\_totals=sum(`sling.cmw.b-cmwnext-player.PlayerHandlerBar.request_totals`, default: 0),  
request\_extended\_totals=sum(`sling.cmw.b-cmwnext-player.PlayerHandlerExtended.request_totals`, default: 0),  
request\_episodes\_totals=sum(`sling.cmw.b-cmwnext-player.PlayerHandlerEpisodesRibbon.request_totals`, default: 0),  
request\_nextplay\_totals=sum(`sling.cmw.b-cmwnext-player.PlayerHandlerNextPlayInfo.request_totals`, default: 0)  
}, union: true, by: {cluster\_name}, filter: { container\_name == “cmwnext-player” }, interval:1m  
| fieldsAdd result = request\_screen\_totals[] + request\_content\_totals[] + request\_bar\_totals[] + request\_extended\_totals[] + request\_episodes\_totals[] + request\_nextplay\_totals[]  
| fieldsAdd throughput = arraySum(result)  
| fieldsRemove request\_screen\_totals, request\_content\_totals, request\_bar\_totals, request\_extended\_totals, request\_episodes\_totals, request\_nextplay\_totals  
, result **[for throughput]**

2.&nbsp;timeseries {  
request\_screen\_totals=sum(`sling.cmw.b-cmwnext-player.PlayerHandlerScreen.request_totals`, default: 0),  
request\_content\_totals=sum(`sling.cmw.b-cmwnext-player.PlayerHandlerContent.request_totals`, default: 0),  
request\_bar\_totals=sum(`sling.cmw.b-cmwnext-player.PlayerHandlerBar.request_totals`, default: 0),  
request\_extended\_totals=sum(`sling.cmw.b-cmwnext-player.PlayerHandlerExtended.request_totals`, default: 0),  
request\_episodes\_totals=sum(`sling.cmw.b-cmwnext-player.PlayerHandlerEpisodesRibbon.request_totals`, default: 0),  
request\_nextplay\_totals=sum(`sling.cmw.b-cmwnext-player.PlayerHandlerNextPlayInfo.request_totals`, default: 0)  
},union: true, by: {cluster\_name}, filter: { container\_name == “cmwnext-player” AND `sling.service.cmwnext-player.player.requesttype` != “ota\_channel” }  
| fieldsAdd match = “match”  
| join [  
timeseries {  
request\_screen\_failure=sum(`sling.cmw.b-cmwnext-player.PlayerHandlerScreen.failure_totals`, default: 0),  
request\_content\_failure=sum(`sling.cmw.b-cmwnext-player.PlayerHandlerContent.failure_totals`, default: 0),  
request\_bar\_failure=sum(`sling.cmw.b-cmwnext-player.PlayerHandlerBar.failure_totals`, default: 0),  
request\_extended\_failure=sum(`sling.cmw.b-cmwnext-player.PlayerHandlerExtended.failure_totals`, default: 0),  
request\_episodes\_failure=sum(`sling.cmw.b-cmwnext-player.PlayerHandlerEpisodesRibbon.failure_totals`, default: 0),  
request\_nextplay\_failure=sum(`sling.cmw.b-cmwnext-player.PlayerHandlerNextPlayInfo.failure_totals`, default: 0)  
}, union: true, by: {cluster\_name},filter: { container\_name == “cmwnext-player” AND `sling.service.cmwnext-player.player.requesttype` != “ota\_channel” }  
| fieldsAdd match = “match”  
], on: {match}  
| fieldsAdd result = 100 \* (  
right.request\_screen\_failure[]  
+ right.request\_content\_failure[]  
+ right.request\_bar\_failure[]  
+ right.request\_extended\_failure[]  
+ right.request\_episodes\_failure[]  
+ right.request\_nextplay\_failure[]  
) / (  
request\_screen\_totals[]  
+ request\_content\_totals[]  
+ request\_bar\_totals[]  
+ request\_extended\_totals[]  
+ request\_episodes\_totals[]  
+ request\_nextplay\_totals[]  
)  
| fields timeframe, interval, result. \*\*[for error\_rate]

Solution needed for using regex effectively for metric data in DQL?\*\*

---

<div class="post-metadata">

**Author:** ![MaciejNeumann](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@MaciejNeumann](https://community.dynatrace.com/u/MaciejNeumann)\
**Post date:** [May 16, 2025, 12:28pm UTC](https://community.dynatrace.com/t/apply-regex-on-custom-metric-series-using-dql/49374/2 "2025-05-16T12:28:21Z")

</div>

Hello&nbsp;[@NitinOjha003](https://community.dynatrace.com/user/84228),

Here are some threads around the topic of using pattern matching in DQL/DPL:  
[DQL Regex](http://DQL%20Regex)&nbsp;&nbsp;  
[Regex in DQL](https://community.dynatrace.com/post/273446)  
Hope that they’ll help you solve your use case!

---

<div class="post-metadata">

**Author:** ![marco\_irmer](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/marco_irmer/32/3038_2.png) [@marco\_irmer](https://community.dynatrace.com/u/marco_irmer)\
**Post date:** [May 16, 2025, 9:46pm UTC](https://community.dynatrace.com/t/apply-regex-on-custom-metric-series-using-dql/49374/3 "2025-05-16T21:46:53Z")

</div>

If I am reading the original post correctly, the core of the issue is that NRQL allows the user to query multiple metrics by specifying a regex pattern that will match multiple metrics, whereas the DQL timeseries command requires the user to explicitly specify each individual metric to be included, which is then followed up by more DQL to combine all the data into aggregated values.

I don’t think DQL supports this sort of thing currently. Perhaps a product idea is in order 🙂
