sensu-go icon indicating copy to clipboard operation
sensu-go copied to clipboard

Add built-in mutators for timestamp precision conversion

Open amdprophet opened this issue 2 years ago • 1 comments

Feature Suggestion

Metrics handlers often require timestamps to have a certain precision (e.g. seconds, milliseconds, nanoseconds). There's currently no easy way to convert between timestamps outputted by a check with one precision to another precision required by a handler. Furthermore, big numbers are not easily supported in ES5 which makes writing JS mutators difficult (I opened https://github.com/sensu/sensu-go/issues/4685 for adding an ES6 JS VM). We should be able to detect the precision of timestamps in a function provided to the Otto VM and convert them to a specified precision as we're already doing this within the Sumologic metrics handler.

Possible Implementation

Create functions for converting timestamps to a desired precision and pass them into the Otto VM. E.g. metricsTimestampsToNanoseconds(event) and/or toNanoseconds(timestamp).

amdprophet avatar Apr 08 '22 19:04 amdprophet

Related: https://github.com/sensu/sensu-go/issues/4327

calebhailey avatar May 02 '22 17:05 calebhailey