However, in my sensu-backend logs i get this error: {"component":"pipelined","error":"error evaluating /var/cache/sensu/sensu-backend/86464c27f32c261d19fb2b1997d70ba35a71d6e3a6fc49db3053104e963317d0e5153453877995b58ae990329678840bc16b30941bb133031c484ba06066622d/lib/._moment.min.js: (anonymous): Line 1:1 Unexpected token ILLEGAL (and 216 more errors)","level":"error","msg":"error executing JS","time":"2020-08-10T16:53:30Z"}
Reading through the sensu-go source code i found out that sensu uses the Otto javascript interpreter. So i installed it on my own system and tried to execute the library using it. However, that resulted in no errors. Everything seemed to work when i did it manually.
Is there something im missing? The javascript code is proper, is it the otto version bundled in sensu that is outdated?
Reading the web site for the library, I understand what it’s supposed to do. However, pasting the code from moment.min.js into https://jshint.com/ and http://www.jslint.com/ both produced a lot of warnings/errors.
I’m not entirely sure why when running with otto directly it doesn’t produce any errors. And I am no JS expert, but the Otto README does state:
* Otto targets ES5. ES6 features (eg: Typed Arrays) are not supported.
So I would be curious to know if that has any effect on it.
I did not myself specify the _.moment.min.js file. That must’ve been the script itself trying to import it. I believe however that i have got it working now. I bundled the non-minified version now and there are no longer any syntax errors in the logs.
However, if anyone else is interested in the momentjs library for their own filters. There are some issues with momentjs and momentjs-timezone. The order in which they are loaded is important. So i will have to create some workaround for that. As sensu-go seems to load all assets in random order.