sensu-go
sensu-go copied to clipboard
Add built-in mutators for timestamp precision conversion
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)
.
Related: https://github.com/sensu/sensu-go/issues/4327