DQL
Questions about Dynatrace Query Language
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How do I get the last values of a string using the parse command?

badgerfifteen
Organizer

Hi,

I'm having trouble understanding the DPL documentation. What I want to do is extract the last characters after a certain character, in this case it would be '/'. I am trying to extract just the filename from the string. For example,

I would just want input.csv from the following filepath/string:

/NODEA12XY/data/services/svc_rt/module/xxabc/3.4.7/in/input.csv

 

1 REPLY 1

dannemca
DynaMight Guru
DynaMight Guru

Hi @badgerfifteen 

You can achieve this with the "substring" and "lastindexof" function, https://docs.dynatrace.com/docs/platform/grail/dynatrace-query-language/functions/string-functions#s... , https://docs.dynatrace.com/docs/platform/grail/dynatrace-query-language/functions/string-functions#l... 

data record(content = "/NODEA12XY/data/services/svc_rt/module/xxabc/3.4.7/in/input.csv"),
     record(content = "/NODEA12XY/data/services/input2.csv"),
     record(content = "/NODEA12XY/input3.csv")
| fieldsAdd FileName = substring(content, from:lastIndexOf(content, "/") + 1)

Try and let us know.

Site Reliability Engineer @ Kyndryl

Featured Posts