Hi,
We have a need to include “old” metrics currently not in grail in new dashboards, however, when returning data based on the timeseries data type current documentation, the dashboard charts are not enabled, so I wonder what is the right way to pass the data.
For example, take a look at the following code:
///endpoint/module being used for metric requests, different when pulling other data
import { metricsClient } from "@dynatrace-sdk/client-classic-environment-v2";
export default async function main() {
//configuration for metric request
let config = {
acceptType: "application/json; charset=utf-8",
metricSelector: "builtin:service.response.server:splitBy(\"dt.entity.service\"):sort(value(auto,descending)):limit(20)",
from: Date.parse($dt_timeframe_from).toString(),
to: Date.parse($dt_timeframe_to).toString(),
// resolution: "10m",
};
//runs the metric request query
const data = await metricsClient.query(config);
//returns nothing if there is not data in the timeframe that matches given filters
if(data.result[0].data.length == 0){
return []
}
// variables used to specify data type to be charted
const data_type = "double";
//variables used for final return
const mappings = {
timestamp: { type: 'timestamp' },
};
const mergedData = <any>[];
//console.log("Before: ", data.result[0].data);
(data.result[0].data).forEach((item) => {
const datapoints_arr = <any>[];
for (let i=0;i<item.timestamps.length;i++) {
datapoints_arr.push({
start: new Date(item.timestamps[i]),
value: item.values[i]
})
}
const output = {
name: [item.dimensions[0]],
datapoints: datapoints_arr
}
mergedData.push(output);
});
console.log("Merged data", mergedData);
return mergedData;
}
Where do I get things wrong?
Gil.