10 Mar 2025
07:14 AM
- last edited on
10 Mar 2025
08:10 AM
by
MaciejNeumann
Hi Team,
I am using following function to fetch data but using that code I am unable to create line chart.
export default async function () {
try {
const data = JSON.parse($mpcheckoutv2);
// Check if data is not null and is an array
if (data && Array.isArray(data)) {
// Extract the data from the result
const Records = data;
return Records;
} else {
throw new Error("Invalid data format");
}
} catch (error) {
// Handle the error
console.log("Error:", error.message);
return "Error processing data";
}
}
I need similar output of following query.
| fieldsAdd success = matchesPhrase(Message, "Order raised successfully" )
| makeTimeseries count(), by: {success, OrderType}, time: toTimestamp(timestamp)
Solved! Go to Solution.
10 Mar 2025 09:39 PM
Time series charts require a special record format. The record must have the following elements:
Here is an example of a simple record containing a time series:
Raw JSON (trimmed down to 5 minutes for readability):
You will have to amend your code so that the record format produced by your code matches the format Dynatrace uses for time series data.
19 Mar 2025 08:19 AM
Hello @marco_irmer,
Thanks for your response, But my requirment is different. I have two fileds for group by, like this "" {success, OrderType} "" and the output shoud visualize like below image. I want to know what output would be for the below chart using JS code.
19 Mar 2025 01:30 PM - edited 19 Mar 2025 11:29 PM
Hi @Tarunbt,
Your code parses a JSON object and then returns it to Dynatrace as a variable named Records. You'll have to write new JavaScript code that manipulates the JSON into a format that Dynatrace can understand as a timeseries. The exact code necessary to accomplish this depends very much on the specific format of your data. If you are able to share the format of your records your code currently outputs then perhaps it would be possible to give additional pointers.