cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Timestamp in pre-execution script for HTPP monitors

iromaniuk
Newcomer

I am posting data points in pre-execution script and dont know how to create timestamp, trying Date.parse(api.date()) below, What's the correct way to do this ?


requestBody={
"type": "LB",
"series": [
{
"timeseriesId": "custom:alteon.CurrSessions",
"dimensions": {
"CUSTOM_DEVICE": "Load Balancers"
},
"dataPoints": [
[
Date.parse(api.date()),
api.randomNextInt()
]
]
}
]
};
request.setBody(requestBody);
1 REPLY 1

HannahM
Dynatrace Leader
Dynatrace Leader

I would use a variable and get the value before you start to create the requestBody. Something like this:

var timestampNow = api.date();

and then use the variable later. Or if you need it to be in a specific format you can use api.dateToFormat. You can find a couple of examples here

Synthetic SME and community advocate.

Featured Posts