sensu / sensu-plugin-sdk

A framework for creating Sensu plugins
MIT License
7 stars 8 forks source link

Add UnixTime func to template expansion #41

Closed nixwiz closed 4 years ago

nixwiz commented 4 years ago

This allows for making timestamps readable and formattable using Golang's time format in a template.

Using the example contained in the test:

"Check: {{ .Check.Name }} Entity: {{ .Entity.Name }} Executed: {{(UnixTime .Check.Executed).Format \"2 Jan 2006 15:04:05\"}} !"

When expanded becomes:

"Check: check-nginx Entity: webserver01 Executed: 10 Dec 2018 20:55:19 !"

Signed-off-by: Todd Campbell todd@sensu.io

nixwiz commented 4 years ago

Looks good, but do we need documentation?

Yeah, I didn't see templating in the docs at all. An opportunity to add it now, I guess?

echlebek commented 4 years ago

We probably need it. Would you be able to add some?

nixwiz commented 4 years ago

I'll try to write something up.

nixwiz commented 4 years ago

@echlebek docs added.