Assets reference
Dynamic runtime assets are shareable, reusable packages that make it easier to deploy Sensu plugins. You can use dynamic runtime assets to provide the plugins, libraries, and runtimes you need to automate your monitoring workflows. Sensu supports dynamic runtime assets for checks, filters, mutators, and handlers.
Use the Sensu Catalog to find, configure, and install many dynamic runtime assets directly from your browser. Follow the Catalog prompts to configure the Sensu resources you need and start processing your observability data with a few clicks.
You can also discover, download, and share dynamic runtime assets using Bonsai, the Sensu asset hub. Read Use assets to install plugins to get started.
NOTE: Dynamic runtime assets are not required to use Sensu Go. You can install Sensu plugins using the sensu-install tool or a configuration management solution.
The Sensu backend executes handler, filter, and mutator dynamic runtime assets.
The Sensu agent executes check dynamic runtime assets.
At runtime, the backend or agent sequentially evaluates dynamic runtime assets that appear in the runtime_assets
attribute of the handler, filter, mutator, or check being executed.
Dynamic runtime asset example (minimum required attributes)
This example shows a dynamic runtime asset resource definition that includes the minimum required attributes:
---
type: Asset
api_version: core/v2
metadata:
name: check_script
spec:
builds:
- sha512: 4f926bf4328fbad2b9cac873d117f771914f4b837c9c85584c38ccf55a3ef3c2e8d154812246e5dda4a87450576b2c58ad9ab40c9e2edc31b288d066b195b21b
url: http://example.com/asset.tar.gz
{
"type": "Asset",
"api_version": "core/v2",
"metadata": {
"name": "check_script"
},
"spec": {
"builds": [
{
"url": "http://example.com/asset.tar.gz",
"sha512": "4f926bf4328fbad2b9cac873d117f771914f4b837c9c85584c38ccf55a3ef3c2e8d154812246e5dda4a87450576b2c58ad9ab40c9e2edc31b288d066b195b21b"
}
]
}
}
Install location for dynamic runtime assets
If you use a Sensu package, dynamic runtime assets are installed at /var/cache
.
If you use a Sensu Docker image, dynamic runtime assets are installed at /var/lib
.
Dynamic runtime asset builds
A dynamic runtime asset build is the combination of an artifact URL, SHA512 checksum, and optional Sensu query expression filters. Each asset definition may describe one or more builds.
NOTE: Dynamic runtime assets that provide url
and sha512
attributes at the top level of the spec
scope are single-build assets, and this form of asset defintion is deprecated.
We recommend using multiple-build asset defintions, which specify one or more builds
under the spec
scope.
Asset example: Multiple builds
This example shows the resource definition for the sensu/check-cpu-usage dynamic runtime asset, which has multiple builds:
---
type: Asset
api_version: core/v2
metadata:
name: check-cpu-usage
labels:
annotations:
io.sensu.bonsai.url: https://bonsai.sensu.io/assets/sensu/check-cpu-usage
io.sensu.bonsai.api_url: https://bonsai.sensu.io/api/v1/assets/sensu/check-cpu-usage
io.sensu.bonsai.tier: Community
io.sensu.bonsai.version: 0.2.2
io.sensu.bonsai.namespace: sensu
io.sensu.bonsai.name: check-cpu-usage
io.sensu.bonsai.tags: ''
spec:
builds:
- url: https://assets.bonsai.sensu.io/a7ced27e881989c44522112aa05dd3f25c8f1e49/check-cpu-usage_0.2.2_windows_amd64.tar.gz
sha512: 900cfdf28d6088b929c4bf9a121b628971edee5fa5cbc91a6bc1df3bd9a7f8adb1fcfb7b1ad70589ed5b4f5ec87d9a9a3ba95bcf2acda56b0901406f14f69fe7
filters:
- entity.system.os == 'windows'
- entity.system.arch == 'amd64'
- url: https://assets.bonsai.sensu.io/a7ced27e881989c44522112aa05dd3f25c8f1e49/check-cpu-usage_0.2.2_darwin_amd64.tar.gz
sha512: db81ee70426114e4cd4b3f180f2b0b1e15b4bffc09d7f2b41a571be2422f4399af3fbd2fa2918b8831909ab4bc2d3f58d0aa0d7b197d3a218b2391bb5c1f6913
filters:
- entity.system.os == 'darwin'
- entity.system.arch == 'amd64'
- url: https://assets.bonsai.sensu.io/a7ced27e881989c44522112aa05dd3f25c8f1e49/check-cpu-usage_0.2.2_linux_armv7.tar.gz
sha512: 400aacce297176e69f3a88b0aab0ddfdbe9dd6a37a673cb1774c8d4750a91cf7713a881eef26ea21d200f74cb20818161c773490139e6a6acb92cbd06dee994c
filters:
- entity.system.os == 'linux'
- entity.system.arch == 'armv7'
- url: https://assets.bonsai.sensu.io/a7ced27e881989c44522112aa05dd3f25c8f1e49/check-cpu-usage_0.2.2_linux_arm64.tar.gz
sha512: bef7802b121ac2a2a5c5ad169d6003f57d8b4f5e83eae998a0e0dd1e7b89678d4a62e678d153edacdd65fd1d0123b5f51308622690455e77cec6deccfa183397
filters:
- entity.system.os == 'linux'
- entity.system.arch == 'arm64'
- url: https://assets.bonsai.sensu.io/a7ced27e881989c44522112aa05dd3f25c8f1e49/check-cpu-usage_0.2.2_linux_386.tar.gz
sha512: a2dcb5324952567a61d76a2e331c1c16df69ef0e0b9899515dad8d1531b204076ad0c008f59fc2f4735a5a779afb0c1baa132268c41942b203444e377fe8c8e5
filters:
- entity.system.os == 'linux'
- entity.system.arch == '386'
- url: https://assets.bonsai.sensu.io/a7ced27e881989c44522112aa05dd3f25c8f1e49/check-cpu-usage_0.2.2_linux_amd64.tar.gz
sha512: 24539739b5eb19bbab6eda151d0bcc63a0825afdfef3bc1ec3670c7b0a00fbbb2fd006d605a7a038b32269a22026d8947324f2bc0acdf35e8563cf4cb8660d7f
filters:
- entity.system.os == 'linux'
- entity.system.arch == 'amd64'
{
"type": "Asset",
"api_version": "core/v2",
"metadata": {
"name": "check-cpu-usage",
"labels": null,
"annotations": {
"io.sensu.bonsai.url": "https://bonsai.sensu.io/assets/sensu/check-cpu-usage",
"io.sensu.bonsai.api_url": "https://bonsai.sensu.io/api/v1/assets/sensu/check-cpu-usage",
"io.sensu.bonsai.tier": "Community",
"io.sensu.bonsai.version": "0.2.2",
"io.sensu.bonsai.namespace": "sensu",
"io.sensu.bonsai.name": "check-cpu-usage",
"io.sensu.bonsai.tags": ""
}
},
"spec": {
"builds": [
{
"url": "https://assets.bonsai.sensu.io/a7ced27e881989c44522112aa05dd3f25c8f1e49/check-cpu-usage_0.2.2_windows_amd64.tar.gz",
"sha512": "900cfdf28d6088b929c4bf9a121b628971edee5fa5cbc91a6bc1df3bd9a7f8adb1fcfb7b1ad70589ed5b4f5ec87d9a9a3ba95bcf2acda56b0901406f14f69fe7",
"filters": [
"entity.system.os == 'windows'",
"entity.system.arch == 'amd64'"
]
},
{
"url": "https://assets.bonsai.sensu.io/a7ced27e881989c44522112aa05dd3f25c8f1e49/check-cpu-usage_0.2.2_darwin_amd64.tar.gz",
"sha512": "db81ee70426114e4cd4b3f180f2b0b1e15b4bffc09d7f2b41a571be2422f4399af3fbd2fa2918b8831909ab4bc2d3f58d0aa0d7b197d3a218b2391bb5c1f6913",
"filters": [
"entity.system.os == 'darwin'",
"entity.system.arch == 'amd64'"
]
},
{
"url": "https://assets.bonsai.sensu.io/a7ced27e881989c44522112aa05dd3f25c8f1e49/check-cpu-usage_0.2.2_linux_armv7.tar.gz",
"sha512": "400aacce297176e69f3a88b0aab0ddfdbe9dd6a37a673cb1774c8d4750a91cf7713a881eef26ea21d200f74cb20818161c773490139e6a6acb92cbd06dee994c",
"filters": [
"entity.system.os == 'linux'",
"entity.system.arch == 'armv7'"
]
},
{
"url": "https://assets.bonsai.sensu.io/a7ced27e881989c44522112aa05dd3f25c8f1e49/check-cpu-usage_0.2.2_linux_arm64.tar.gz",
"sha512": "bef7802b121ac2a2a5c5ad169d6003f57d8b4f5e83eae998a0e0dd1e7b89678d4a62e678d153edacdd65fd1d0123b5f51308622690455e77cec6deccfa183397",
"filters": [
"entity.system.os == 'linux'",
"entity.system.arch == 'arm64'"
]
},
{
"url": "https://assets.bonsai.sensu.io/a7ced27e881989c44522112aa05dd3f25c8f1e49/check-cpu-usage_0.2.2_linux_386.tar.gz",
"sha512": "a2dcb5324952567a61d76a2e331c1c16df69ef0e0b9899515dad8d1531b204076ad0c008f59fc2f4735a5a779afb0c1baa132268c41942b203444e377fe8c8e5",
"filters": [
"entity.system.os == 'linux'",
"entity.system.arch == '386'"
]
},
{
"url": "https://assets.bonsai.sensu.io/a7ced27e881989c44522112aa05dd3f25c8f1e49/check-cpu-usage_0.2.2_linux_amd64.tar.gz",
"sha512": "24539739b5eb19bbab6eda151d0bcc63a0825afdfef3bc1ec3670c7b0a00fbbb2fd006d605a7a038b32269a22026d8947324f2bc0acdf35e8563cf4cb8660d7f",
"filters": [
"entity.system.os == 'linux'",
"entity.system.arch == 'amd64'"
]
}
]
}
}
Asset example: Single build (deprecated)
This example shows the resource definition for a dynamic runtime asset with a single build:
---
type: Asset
api_version: core/v2
metadata:
name: check_cpu_linux_amd64
labels:
origin: bonsai
annotations:
project_url: https://bonsai.sensu.io/assets/asachs01/sensu-go-cpu-check
version: 0.0.3
spec:
url: https://assets.bonsai.sensu.io/981307deb10ebf1f1433a80da5504c3c53d5c44f/sensu-go-cpu-check_0.0.3_linux_amd64.tar.gz
sha512: 487ab34b37da8ce76d2657b62d37b35fbbb240c3546dd463fa0c37dc58a72b786ef0ca396a0a12c8d006ac7fa21923e0e9ae63419a4d56aec41fccb574c1a5d3
filters:
- entity.system.os == 'linux'
- entity.system.arch == 'amd64'
headers:
Authorization: 'Bearer {{ .annotations.asset_token | default "N/A" }}'
X-Forwarded-For: client1, proxy1, proxy2
{
"type": "Asset",
"api_version": "core/v2",
"metadata": {
"name": "check_cpu_linux_amd64",
"labels": {
"origin": "bonsai"
},
"annotations": {
"project_url": "https://bonsai.sensu.io/assets/asachs01/sensu-go-cpu-check",
"version": "0.0.3"
}
},
"spec": {
"url": "https://assets.bonsai.sensu.io/981307deb10ebf1f1433a80da5504c3c53d5c44f/sensu-go-cpu-check_0.0.3_linux_amd64.tar.gz",
"sha512": "487ab34b37da8ce76d2657b62d37b35fbbb240c3546dd463fa0c37dc58a72b786ef0ca396a0a12c8d006ac7fa21923e0e9ae63419a4d56aec41fccb574c1a5d3",
"filters": [
"entity.system.os == 'linux'",
"entity.system.arch == 'amd64'"
],
"headers": {
"Authorization": "Bearer {{ .annotations.asset_token | default \"N/A\" }}",
"X-Forwarded-For": "client1, proxy1, proxy2"
}
}
}
Dynamic runtime asset build evaluation
For each build provided in a dynamic runtime asset, Sensu will evaluate any defined filters to determine whether any build matches the agent or backend service’s environment.
If all filters specified on a build evaluate to true
, that build is considered a match.
For dynamic runtime assets with multiple builds, only the first build that matches will be downloaded and installed.
Dynamic runtime asset build download
Sensu downloads the dynamic runtime asset build on the host system where the asset contents are needed to execute the requested command. For example, if a check definition references a dynamic runtime asset, the Sensu agent that executes the check will download the asset the first time it executes the check. The dynamic runtime asset build the agent downloads will depend on the filter rules associated with each build defined for the asset.
Sensu backends follow a similar process when pipeline elements (filters, mutators, and handlers) request dynamic runtime asset installation as part of operation.
NOTE: Dynamic runtime asset builds are not downloaded until they are needed for command execution.
When Sensu finds a matching build, it downloads the build artifact from the specified URL. If the asset definition includes headers, they are passed along as part of the HTTP request. If the downloaded artifact’s SHA512 checksum matches the checksum provided by the build, it is unpacked into the Sensu service’s local cache directory.
Set the backend or agent’s local cache path with the cache-dir
configuration option.
Disable dynamic runtime assets for an agent with the agent disable-assets
configuration option.
NOTE: Dynamic runtime asset builds are unpacked into the cache directory that is configured with the cache-dir
configuration option.
Use the assets-rate-limit
and assets-burst-limit
configuration options for the agent and backend to configure a global rate limit for fetching dynamic runtime assets.
Dynamic runtime asset build execution
The directory path of each dynamic runtime asset listed in a check, event filter, handler, or mutator resource’s runtime_assets
array is appended to the PATH
before the resource’s command
is executed.
Subsequent check, event filter, handler, or mutator executions look for the dynamic runtime asset in the local cache and ensure that the contents match the configured checksum.
The following example demonstrates a use case with a Sensu check resource and an asset:
---
type: Asset
api_version: core/v2
metadata:
name: sensu-prometheus-collector
spec:
builds:
- url: https://assets.bonsai.sensu.io/ef812286f59de36a40e51178024b81c69666e1b7/sensu-prometheus-collector_1.1.6_linux_amd64.tar.gz
sha512: a70056ca02662fbf2999460f6be93f174c7e09c5a8b12efc7cc42ce1ccb5570ee0f328a2dd8223f506df3b5972f7f521728f7bdd6abf9f6ca2234d690aeb3808
filters:
- entity.system.os == 'linux'
- entity.system.arch == 'amd64'
---
type: CheckConfig
api_version: core/v2
metadata:
name: prometheus_collector
spec:
command: "sensu-prometheus-collector -prom-url http://localhost:9090 -prom-query up"
interval: 10
publish: true
output_metric_handlers:
- influxdb
output_metric_format: influxdb_line
runtime_assets:
- sensu-prometheus-collector
subscriptions:
- system
{
"type": "Asset",
"api_version": "core/v2",
"metadata": {
"name": "sensu-email-handler"
},
"spec": {
"builds": [
{
"url": "https://assets.bonsai.sensu.io/45eaac0851501a19475a94016a4f8f9688a280f6/sensu-email-handler_0.2.0_linux_amd64.tar.gz",
"sha512": "d69df76612b74acd64aef8eed2ae10d985f6073f9b014c8115b7896ed86786128c20249fd370f30672bf9a11b041a99adb05e3a23342d3ad80d0c346ec23a946",
"filters": [
"entity.system.os == 'linux'",
"entity.system.arch == 'amd64'"
]
}
]
}
}
{
"type": "CheckConfig",
"api_version": "core/v2",
"metadata": {
"name": "prometheus_collector"
},
"spec": {
"command": "sensu-prometheus-collector -prom-url http://localhost:9090 -prom-query up",
"handlers": [
"influxdb"
],
"interval": 10,
"publish": true,
"output_metric_format": "influxdb_line",
"runtime_assets": [
"sensu-prometheus-collector"
],
"subscriptions": [
"system"
]
}
}
Dynamic runtime asset format specification
Sensu expects a dynamic runtime asset to be a tar archive (optionally gzipped) that contains one or more executables within a bin folder.
Any scripts or executables should be within a bin/
folder in the archive.
Read the Sensu Go Plugin template for an example dynamic runtime asset and Bonsai configuration.
The following are injected into the execution context:
{PATH_TO_ASSET}/bin
is injected into thePATH
environment variable{PATH_TO_ASSET}/lib
is injected into theLD_LIBRARY_PATH
environment variable{PATH_TO_ASSET}/include
is injected into theCPATH
environment variable
NOTE: You cannot create a dynamic runtime asset by creating an archive of an existing project (as in previous versions of Sensu for plugins from the Sensu Plugins community). Follow the steps outlined in Contributing Assets for Existing Ruby Sensu Plugins, a Sensu Discourse guide. For further examples of Sensu users who have added the ability to use a community plugin as a dynamic runtime asset, read this Discourse post.
Default cache directory
system | sensu-backend | sensu-agent |
---|---|---|
Linux | /var/cache/sensu/sensu-backend |
/var/cache/sensu/sensu-agent |
Windows | N/A | C:\ProgramData\sensu\cache\sensu-agent |
If the requested dynamic runtime asset is not in the local cache, it is downloaded from the asset URL. The Sensu backend acts as an index of dynamic runtime asset builds, and does not provide storage or hosting for the build artifacts. Sensu expects dynamic runtime assets to be retrieved over HTTP or HTTPS.
Example dynamic runtime asset structure
sensu-example-handler_1.0.0_linux_amd64
├── CHANGELOG.md
├── LICENSE
├── README.md
└── bin
└── my-check.sh
└── lib
└── include
Dynamic runtime asset path
When you download and install a dynamic runtime asset, the asset files are saved to a local path on disk. Most of the time, you won’t need to know this path — except in cases where you need to provide the full path to dynamic runtime asset files as part of a command argument.
The dynamic runtime asset directory path includes the asset’s checksum, which changes every time underlying asset artifacts are updated.
This would normally require you to manually update the commands for any of your checks, handlers, hooks, or mutators that consume the dynamic runtime asset.
However, because the dynamic runtime asset directory path is exposed to asset consumers via environment variables and the assetPath
custom function, you can avoid these manual updates.
You can retrieve the dynamic runtime asset’s path as an environment variable in the command
context for checks, handlers, hooks, and mutators.
Token substitution with the assetPath
custom function is only available for check and hook commands.
The Sensu Windows agent uses cmd.exe
for the check execution environment.
For all other operating systems, the Sensu agent uses the Bourne shell (sh).
Environment variables for dynamic runtime asset paths
For each dynamic runtime asset, a corresponding environment variable will be available in the command
context.
Sensu generates the environment variable name by capitalizing the dynamic runtime asset’s complete name, replacing any special characters with underscores, and appending the _PATH
suffix.
The value of the variable will be the path on disk where the dynamic runtime asset build has been unpacked.
Each asset page in Bonsai lists the asset’s complete name. This example shows where the complete name for the sensu/http-checks dynamic runtime asset is located in Bonsai:
An asset’s complete name includes both the part before the forward slash (sometimes called the Bonsai namespace) and the part after the forward slash.
Consequently, the environment variable for the sensu/http-checks asset path is:
SENSU_HTTP_CHECKS_PATH
Linux environment variable example
The Linux environment interprets the content between the ${
and }
characters as an environment variable name and will substitute the value of that environment variable.
For example, to reference the path for the sensu/http-checks asset in your checks, handlers, hooks, and mutators:
${SENSU_HTTP_CHECKS_PATH}
Windows environment variable example
The Windows console environment interprets the content between paired %
characters as an environment variable name and will substitute the value of that environment variable.
For example, to reference the path for the sensu/sensu-windows-powershell-checks asset in your checks, handlers, hooks, and mutators:
%SENSU_SENSU_WINDOWS_POWERSHELL_CHECKS_PATH%
assetPath function for dynamic runtime asset paths
The assetPath
token subsitution function allows you to substitute a dynamic runtime asset’s local path on disk so that you will not need to manually update your check or hook commands every time the asset is updated.
NOTE: The assetPath
function is only available where token substitution is available: the command
attribute of a check or hook resource.
To access a dynamic runtime asset path in a handler or mutator command, you must use the environment variable.
Linux assetPath example
To use the assetPath
token substitution function in a Linux environment, place it immediately after the $
character.
For example, to use the assetPath
function to reference the path for the sensu/http-checks asset in your check or hook resources:
${{assetPath "sensu/http-checks"}}
Windows assetPath example
To use the assetPath
token substitution function in a Linux environment, place it between paired %
characters.
For example, to use the assetPath
function to reference the path for the sensu/sensu-windows-powershell-checks asset in your check or hook resources:
%{{assetPath "sensu/sensu-windows-powershell-checks"}}%
When running PowerShell plugins on Windows, the exit status codes that Sensu captures may not match the expected values.
To correctly capture exit status codes from PowerShell plugins distributed as dynamic runtime assets, use the asset path to construct the command.
The following example uses the assetPath
function for this purpose:
---
type: CheckConfig
api_version: core/v2
metadata:
name: win-cpu-check
spec:
command: powershell.exe -ExecutionPolicy ByPass -f %{{assetPath "sensu/sensu-windows-powershell-checks"}}%\bin\check-windows-cpu-load.ps1 90 95
subscriptions:
- windows
handlers:
- slack
- email
runtime_assets:
- sensu/sensu-windows-powershell-checks
interval: 10
publish: true
{
"type": "CheckConfig",
"api_version": "core/v2",
"metadata": {
"name": "win-cpu-check"
},
"spec": {
"command": "powershell.exe -ExecutionPolicy ByPass -f %{{assetPath \"sensu/sensu-windows-powershell-checks\"}}%\\bin\\check-windows-cpu-load.ps1 90 95",
"subscriptions": [
"windows"
],
"handlers": [
"slack",
"email"
],
"runtime_assets": [
"sensu/sensu-windows-powershell-checks"
],
"interval": 10,
"publish": true
}
}
Asset hello world Bourne shell example
In this example, you’ll run a script that outputs Hello World
:
hello-world.sh
#!/bin/sh
STRING="Hello World"
echo $STRING
if [ $? -eq 0 ]; then
exit 0
else
exit 2
fi
The first step is to ensure that your directory structure is in place.
As noted in Example dynamic runtime asset structure, your script could live in three potential directories in the project: /bin
, /lib
, or /include
.
For this example, put your script in the /bin
directory.
-
Create the directory
sensu-go-hello-world
:mkdir sensu-go-hello-world
-
Navigate to the
sensu-go-hello-world
directory:cd sensu-go-hello-world
-
Create the directory
/bin
:mkdir bin
-
Copy the script into the
/bin
directory:cp hello-world.sh bin/
-
Confirm that the script is in the
/bin
directory:tree
The response should list the
hello-world.sh
script in the/bin
directory:. └── bin └── hello-world.sh
If you receive a
command not found
response, installtree
and run the command again. -
Make sure that the script is marked as executable:
chmod +x bin/hello-world.sh
If you do not receive a response, the command was successful.
Now that the script is in the directory, move on to the next step: packaging the sensu-go-hello-world
directory as a dynamic runtime asset tarball.
Package the dynamic runtime asset
Dynamic runtime assets are archives, so packaging the asset requires creating a tar.gz archive of your project.
-
Navigate to the directory you want to tar up.
-
Create the tar.gz archive:
tar -C sensu-go-hello-world -cvzf sensu-go-hello-world-0.0.1.tar.gz .
-
Generate a SHA512 sum for the tar.gz archive (this is required for the dynamic runtime asset to work):
sha512sum sensu-go-hello-world-0.0.1.tar.gz | tee sha512sum.txt
From here, you can host your dynamic runtime asset wherever you’d like. To make the asset available via Bonsai, you’ll need to host it on GitHub. Learn more in The “Hello World” of Sensu Assets at the Sensu Community Forum on Discourse.
To host your dynamic runtime asset on a different platform like Gitlab or Bitbucket, upload your asset there. You can also use Artifactory or even Apache or NGINX to serve your asset. All that’s required for your dynamic runtime asset to work is the URL to the asset and the SHA512 sum for the asset to be downloaded.
Asset specification
Top-level attributes
type | |
---|---|
description | Top-level attribute that specifies the sensuctl create resource type. Dynamic runtime assets should always be type Asset . |
required | Required for asset definitions in wrapped-json or yaml format for use with sensuctl create . |
type | String |
example |
|
api_version | |
---|---|
description | Top-level attribute that specifies the Sensu API group and version. For dynamic runtime assets in this version of Sensu, the api_version should always be core/v2 . |
required | Required for asset definitions in wrapped-json or yaml format for use with sensuctl create . |
type | String |
example |
|
metadata | |
---|---|
description | Top-level collection of metadata about the dynamic runtime asset, including name , namespace , and created_by as well as custom labels and annotations . The metadata map is always at the top level of the asset definition. This means that in wrapped-json and yaml formats, the metadata scope occurs outside the spec scope. Read metadata attributes for details. |
required | Required for asset definitions in wrapped-json or yaml format for use with sensuctl create . |
type | Map of key-value pairs |
example |
|
spec | |
---|---|
description | Top-level map that includes the dynamic runtime asset spec attributes. |
required | Required for asset definitions in wrapped-json or yaml format for use with sensuctl create . |
type | Map of key-value pairs |
example (multiple builds) |
|
example (single build, deprecated) |
|
Metadata attributes
name | |
---|---|
description | Unique name of the dynamic runtime asset, validated with Go regex \A[\w\.\-]+\z . |
required | true |
type | String |
example |
|
namespace | |
---|---|
description | Sensu RBAC namespace that the dynamic runtime asset belongs to. |
required | false |
type | String |
default | default |
example |
|
created_by | |
---|---|
description | Username of the Sensu user who created the dynamic runtime asset or last updated the asset. Sensu automatically populates the created_by field when the dynamic runtime asset is created or updated. |
required | false |
type | String |
example |
|
labels | |
---|---|
description | Custom attributes to include with observation event data that you can use for response and web UI view filtering. If you include labels in your event data, you can filter API responses, sensuctl responses, and web UI views based on them. In other words, labels allow you to create meaningful groupings for your data. Limit labels to metadata you need to use for response filtering. For complex, non-identifying metadata that you will not need to use in response filtering, use annotations rather than labels. |
required | false |
type | Map of key-value pairs. Keys can contain only letters, numbers, and underscores and must start with a letter. Values can be any valid UTF-8 string. |
default | null |
example |
|
annotations | |
---|---|
description | Non-identifying metadata to include with observation event data that you can access with event filters. You can use annotations to add data that’s meaningful to people or external tools that interact with Sensu. In contrast to labels, you cannot use annotations in API response filtering, sensuctl response filtering, or web UI views. |
required | false |
type | Map of key-value pairs. Keys and values can be any valid UTF-8 string. |
default | null |
example |
|
Spec attributes
builds | |
---|---|
description | List of dynamic runtime asset builds used to define multiple artifacts that provide the named asset. |
required | true, if url , sha512 and filters are not provided |
type | Array |
example |
|
url | |
---|---|
description | URL location of the dynamic runtime asset. You can use token substitution in the URLs of your asset definitions so each backend or agent can download dynamic runtime assets from the appropriate URL without duplicating your assets (for example, if you want to host your assets at different datacenters). |
required | true, unless builds are provided |
type | String |
example |
|
sha512 | |
---|---|
description | Checksum of the dynamic runtime asset. |
required | true, unless builds are provided |
type | String |
example |
|
filters | |
---|---|
description | Set of Sensu query expressions used to determine if the dynamic runtime asset should be installed. If multiple expressions are included, each expression must return true for Sensu to install the asset.Filters for check dynamic runtime assets should match agent entity platforms. Filters for handler and filter dynamic runtime assets should match your Sensu backend platform. You can create asset filter expressions using any supported entity.system attributes, including os , arch , platform , and platform_family .
PRO TIP: Dynamic runtime asset filters let you reuse checks across platforms safely. Assign dynamic runtime assets for multiple platforms to a single check, and rely on asset filters to ensure that only the appropriate asset is installed on each agent. |
required | false |
type | Array |
example |
|
headers | |
---|---|
description | HTTP headers to apply to dynamic runtime asset retrieval requests. You can use headers to access secured dynamic runtime assets. For headers that require multiple values, separate the values with a comma. You can use token substitution in your dynamic runtime asset headers (for example, to include secure information for authentication). |
required | false |
type | Map of key-value string pairs |
example |
|
Dynamic runtime asset filters based on entity.system attributes
Use the entity.system attributes in dynamic runtime asset filters to specify which systems and configurations an asset or asset builds can be used with.
For example, the sensu/sensu-ruby-runtime dynamic runtime asset definition includes several builds, each with filters for several entity.system
attributes:
---
type: Asset
api_version: core/v2
metadata:
name: sensu-ruby-runtime
labels:
annotations:
io.sensu.bonsai.url: https://bonsai.sensu.io/assets/sensu/sensu-ruby-runtime
io.sensu.bonsai.api_url: https://bonsai.sensu.io/api/v1/assets/sensu/sensu-ruby-runtime
io.sensu.bonsai.tier: Community
io.sensu.bonsai.version: 0.0.10
io.sensu.bonsai.namespace: sensu
io.sensu.bonsai.name: sensu-ruby-runtime
io.sensu.bonsai.tags: ''
spec:
builds:
- url: https://assets.bonsai.sensu.io/5123017d3dadf2067fa90fc28275b92e9b586885/sensu-ruby-runtime_0.0.10_ruby-2.4.4_centos6_linux_amd64.tar.gz
sha512: cbee19124b7007342ce37ff9dfd4a1dde03beb1e87e61ca2aef606a7ad3c9bd0bba4e53873c07afa5ac46b0861967a9224511b4504dadb1a5e8fb687e9495304
filters:
- entity.system.os == 'linux'
- entity.system.arch == 'amd64'
- entity.system.platform_family == 'rhel'
- parseInt(entity.system.platform_version.split('.')[0]) == 6
- url: https://assets.bonsai.sensu.io/5123017d3dadf2067fa90fc28275b92e9b586885/sensu-ruby-runtime_0.0.10_ruby-2.4.4_debian_linux_amd64.tar.gz
sha512: a28952fd93fc63db1f8988c7bc40b0ad815eb9f35ef7317d6caf5d77ecfbfd824a9db54184400aa0c81c29b34cb48c7e8c6e3f17891aaf84cafa3c134266a61a
filters:
- entity.system.os == 'linux'
- entity.system.arch == 'amd64'
- entity.system.platform_family == 'debian'
- url: https://assets.bonsai.sensu.io/5123017d3dadf2067fa90fc28275b92e9b586885/sensu-ruby-runtime_0.0.10_ruby-2.4.4_alpine_linux_amd64.tar.gz
sha512: 8d768d1fba545898a8d09dca603457eb0018ec6829bc5f609a1ea51a2be0c4b2d13e1aa46139ecbb04873449e4c76f463f0bdfbaf2107caf37ab1c8db87d5250
filters:
- entity.system.os == 'linux'
- entity.system.arch == 'amd64'
- entity.system.platform == 'alpine'
- entity.system.platform_version.split('.')[0] == '3'
{
"type": "Asset",
"api_version": "core/v2",
"metadata": {
"name": "sensu-ruby-runtime",
"labels": null,
"annotations": {
"io.sensu.bonsai.url": "https://bonsai.sensu.io/assets/sensu/sensu-ruby-runtime",
"io.sensu.bonsai.api_url": "https://bonsai.sensu.io/api/v1/assets/sensu/sensu-ruby-runtime",
"io.sensu.bonsai.tier": "Community",
"io.sensu.bonsai.version": "0.0.10",
"io.sensu.bonsai.namespace": "sensu",
"io.sensu.bonsai.name": "sensu-ruby-runtime",
"io.sensu.bonsai.tags": ""
}
},
"spec": {
"builds": [
{
"url": "https://assets.bonsai.sensu.io/5123017d3dadf2067fa90fc28275b92e9b586885/sensu-ruby-runtime_0.0.10_ruby-2.4.4_centos6_linux_amd64.tar.gz",
"sha512": "cbee19124b7007342ce37ff9dfd4a1dde03beb1e87e61ca2aef606a7ad3c9bd0bba4e53873c07afa5ac46b0861967a9224511b4504dadb1a5e8fb687e9495304",
"filters": [
"entity.system.os == 'linux'",
"entity.system.arch == 'amd64'",
"entity.system.platform_family == 'rhel'",
"parseInt(entity.system.platform_version.split('.')[0]) == 6"
]
},
{
"url": "https://assets.bonsai.sensu.io/5123017d3dadf2067fa90fc28275b92e9b586885/sensu-ruby-runtime_0.0.10_ruby-2.4.4_debian_linux_amd64.tar.gz",
"sha512": "a28952fd93fc63db1f8988c7bc40b0ad815eb9f35ef7317d6caf5d77ecfbfd824a9db54184400aa0c81c29b34cb48c7e8c6e3f17891aaf84cafa3c134266a61a",
"filters": [
"entity.system.os == 'linux'",
"entity.system.arch == 'amd64'",
"entity.system.platform_family == 'debian'"
]
},
{
"url": "https://assets.bonsai.sensu.io/5123017d3dadf2067fa90fc28275b92e9b586885/sensu-ruby-runtime_0.0.10_ruby-2.4.4_alpine_linux_amd64.tar.gz",
"sha512": "8d768d1fba545898a8d09dca603457eb0018ec6829bc5f609a1ea51a2be0c4b2d13e1aa46139ecbb04873449e4c76f463f0bdfbaf2107caf37ab1c8db87d5250",
"filters": [
"entity.system.os == 'linux'",
"entity.system.arch == 'amd64'",
"entity.system.platform == 'alpine'",
"entity.system.platform_version.split('.')[0] == '3'"
]
}
]
}
}
In this example, if you install the dynamic runtime asset on a system running Linux AMD64 Alpine version 3.xx, Sensu will ignore the first two builds and install the third.
NOTE: Sensu downloads and installs the first build whose filter expressions all evaluate as true
.
If your system happens to match all of the filters for more than one build of a dynamic runtime asset, Sensu will only install the first build.
All of the dynamic runtime asset filter expressions must evaluate as true for Sensu to download and install the asset and run the check, handler, or filter that references the asset.
To continue this example, if you try to install the dynamic runtime asset on a system running Linux AMD64 Alpine version 2.xx, the entity.system.platform_version
argument will evaluate as false
.
In this case, the asset will not be downloaded and the check, handler, or filter that references the asset will fail to run.
Add dynamic runtime asset filters to specify that an asset is compiled for any of the entity.system attributes, including operating system, platform, platform version, and architecture. Then, you can rely on dynamic runtime asset filters to ensure that you install only the appropriate asset for each of your agents.
Share an asset on Bonsai
Share your open-source dynamic runtime assets on Bonsai and connect with the Sensu community. Bonsai supports dynamic runtime assets hosted on GitHub and released using GitHub releases. For more information about creating Sensu plugins, read the plugins reference.
Bonsai requires a bonsai.yml
configuration file in the root directory of your repository that includes the project description, platforms, asset filenames, and SHA-512 checksums.
For a Bonsai-compatible dynamic runtime asset template using Go and GoReleaser, review the Sensu Go plugin skeleton.
To share your dynamic runtime asset on Bonsai, log in to Bonsai with your GitHub account and authorize Sensu. After you are logged in, you can register your dynamic runtime asset on Bonsai by adding the GitHub repository, a description, and tags. Make sure to provide a helpful README for your dynamic runtime asset with configuration examples.
bonsai.yml
example
---
description: "#{repo}"
builds:
- platform: "linux"
arch: "amd64"
asset_filename: "#{repo}_#{version}_linux_amd64.tar.gz"
sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
filter:
- "entity.system.os == 'linux'"
- "entity.system.arch == 'amd64'"
- platform: "Windows"
arch: "amd64"
asset_filename: "#{repo}_#{version}_windows_amd64.tar.gz"
sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
filter:
- "entity.system.os == 'windows'"
- "entity.system.arch == 'amd64'"
bonsai.yml
specification
description | |
---|---|
description | Project description. |
required | true |
type | String |
example |
|
builds | |
---|---|
description | Array of dynamic runtime asset details per platform. |
required | true |
type | Array |
example |
|
Builds specification
platform | |
---|---|
description | Platform supported by the dynamic runtime asset. |
required | true |
type | String |
example |
|
arch | |
---|---|
description | Architecture supported by the dynamic runtime asset. |
required | true |
type | String |
example |
|
asset_filename | |
---|---|
description | File name of the archive that contains the dynamic runtime asset. |
required | true |
type | String |
example |
|
sha_filename | |
---|---|
description | SHA-512 checksum for the dynamic runtime asset archive. |
required | true |
type | String |
example |
|
filter | |
---|---|
description | Filter expressions that describe the operating system and architecture supported by the asset. |
required | false |
type | Array |
example |
|
Delete dynamic runtime assets
Delete dynamic runtime assets with a DELETE request to the /assets
API endpoint or with the sensuctl asset delete
command.
Removing a dynamic runtime asset from Sensu does not remove references to the deleted asset in any other resource (including checks, filters, mutators, handlers, and hooks).
You must also update resources and remove any reference to the deleted dynamic runtime asset.
Failure to do so will result in errors like sh: asset.sh: command not found
.
Errors as a result of failing to remove the dynamic runtime asset from checks and hooks will surface in the event data. Errors as a result of failing to remove the dynamic runtime asset reference on a mutator, handler, or filter will only surface in the backend logs.
Deleting a dynamic runtime asset does not delete the archive or downloaded files on disk. You must remove the archive and downloaded files from the asset cache manually.