11 Jun 2025 12:04 PM
Hi ,
I am new to Dynatrace and looking to explore logs. Looking for help to extract specific value from logs.
Query
fetch logs
| filter dt.host_group.id == "XXXX" AND log.file.path == "XXXXX"
Example log content
Looking to extract the ms value at the end of event. I tried to use parse command but not working.
Solved! Go to Solution.
11 Jun 2025 01:17 PM
Hi Agoyals,
You can do something like this:
fetch logs
| filter dt.host_group.id == "XXXX" AND log.file.path == "XXXXX"
| parse content, """
DATA
'(512M)' // Literal string just before the ms value
SPACE // Space character before the desired value
(DIGIT '.' DIGIT):value // The value column will contain the desired number, if it's always in the form X.XXX
'ms' // To end the parsing
If you want to plot the values, or handle them as a number, you can use the following command:
| fieldsAdd value = toDouble(value)
Hope this helps.
11 Jun 2025 01:52 PM
Hi,
Adding to @jmarbaix's answer, you could also use this parse in case you don't have that 512M as static:
parse content, "LD'->' LD SPACE (DIGIT'.'DIGIT):value 'ms'"
Note: if you convert it to double it will round the value to 2 decimal points. In which case, you can straight up transfomr it to double by doing: DOUBLE:value in the parse.