Jef Practice: Preparing to use assets

Here’s a couple of things I do to make sure when setting up my agents for the first time. I generally follow this pattern any time I’m installing on an agent on a new linux distribution variant or container image that I haven’t interacted with before. So I thought I’d share.

Double check your asset filters
Make sure the asset definition has a build definition with filters that match the entity you are trying to use the asset on. Sensu Go 5.12 introduces a new multi-build capable asset resource, so if you are using the multi-build style asset you may have multiple build each with its own filter list. For Sensu Go 5.11 and older, you just see a single filter list.

Write a diagnostic check to report back PATH and LD_LIBRARY_PATH
When prototyping a new check that uses assets, i usually write it initially so that I am just echoing out the PATH and LD_LIBRARY_PATH variables as check output. Since the asset directory encodes the sha512sum for the specific asset binary being used, I can use this information to validate that the asset binary i expected to match via the filtering rules is the one used on the agent.

If the which command is available I’ll also include the output of the which <target-command> to verify the command i want to run is in the executable path. Containers might not have this command installed, so not always possible to use this as a diagnostic.

I’ll actually keep a couple of simple diagnostic checks un an unpublished state and edit them with sensuctl if i need to test new assets that I want to include. That way I can make sure the assets load on the system before I need to use them in a check… isolating the asset configuration testing separate from the operational check.

Ruby Runtime
When using the ruby runtime asset, I’ll typically write a simple diagnostic check with a ruby command using the ruby interpreter directly to ensure basic ruby operation. Something of the form ruby -e "puts 'hello world'" or similar. o make sure basic ruby operation is working before layering additional ruby plugin assets on top.