I’m sending a JSON payload to the Datadog DORA metrics API, which requires the timestamp to be in nanoseconds. What is the best way to format or convert time value to nanoseconds within this JSON structure (started_at & finished_at)?
{
"data": {
"attributes": {
"team": "retails",
"service": "portal",
"env": "production",
"started_at": {{issue.customfield_12138.epochMilli}},
"finished_at": {{issue.customfield_12140.epochMilli}},
"severity": "{{issue.priority.name}}",
"name": "{{issue.key}} : {{issue.summary}}"
}
}
}
Required format: 1693491974000000000
(Human-readable date: Thursday, August 31, 2023 2:26:14 PM (UTC))
Hi @mike_atrache -- Welcome to the Atlassian Community!
Are you trying this in an automation rule? If so...
When I have tried this in the past, the format() function with nano-of-second did not work in a rule. A workaround is to create a variable for the start of epoch time (i.e., start of day 1 Jan 1970) and then perform a diff() to millis format, multiplying as needed for nanoseconds.
An example for the start of epoch time would be this:
{{now.withYear(1970).withDayOfYear(1).toDateTimeAtStartOfDay}}
Then an example of the diff() would be this, assuming the variable is named varStartOfTime:
{{varStartOfTime.toDate.diff(issue.customfield_12138).millis}}
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.