02 Jan 2024 12:50 PM
I'm struggling with making a timeseries of JSON data in a Grail Query dashboard. I'm trying to reduce it.
data json: """
[{"timestamp": "2023-03-31T05:56:42.451304000Z", "severity":"INFO", "event":"search successful", "responseTime": 22},
{"timestamp": "2023-03-31T05:57:42.451304000Z", "severity":"ERROR", "event":"failed to find product", "responseTime": 55}
]
"""
| makeTimeseries avg(responseTime), by:{severity}
I'm getting this error:
The implicit default field `timestamp` for parameter `time` specifies multiple data types which may be incompatible, you may specify it explicitly.
And if I run it I get: Function ADD does not accept (string, duration).
Solved! Go to Solution.
04 Jan 2024 09:40 AM
Hi @woodchuck ,
Spent some time looking at this and managed to get it wo work for myself few pitfalls that you may encounter but leads to the solution of the problem:
- Because this is JSON as input even though Dynatrace recognises all of these attributes as their own columns it does not recognise the data types so your timestamp is coming in as a string and not a date relavant data type to do this use:
| fieldsAdd timestamp = toTimestamp(timestamp)
- The other thing that tripped me up is that the date time was set in early 2023 and the default timeframe for a notebook that i was workong with is last 2 hours so its just something to look out for if you see no data.
I did manage to get it to work maybe adding more datapoints would make the chart a bit clearer but find the code here:
data json: """
[{"timestamp": "2024-01-01T05:56:42.451304000", "severity":"INFO", "event":"search successful", "responseTime": 22},
{"timestamp": "2023-12-01T07:57:42.451304000", "severity":"ERROR", "event":"failed to find product", "responseTime": 55}
]
"""
| fieldsAdd timestamp = toTimestamp(timestamp)
| makeTimeseries avg(responseTime) , by:{severity}
And a Screenshot:
04 Jan 2024 01:39 PM
Perfect, thanks. Works great
The JSON I took was from something I found on the Dynatrace docs and just added the response time.