How to install plugins using assets

Assets are shareable, reusable packages that make it easy to deploy Sensu plugins. You can use assets to provide the plugins, libraries, and runtimes you need to power your monitoring workflows. See the asset reference for more information about assets.

1. Download an asset definition from Bonsai

You can discover, download, and share assets using Bonsai, the Sensu asset index. To use an asset, select the Download button on the asset page in Bonsai to download the asset definition for your platform and architecture. Asset definitions tell Sensu how to download and verify the asset when required by a check, filter, mutator, or handler.

For example, here’s the asset definition for version 1.0.1 of the Sensu PagerDuty handler asset for Linux AMD64.

{
  "type": "Asset",
  "api_version": "core/v2",
  "metadata": {
    "name": "sensu-pagerduty-handler",
    "namespace": "default",
    "labels": {},
    "annotations": {}
  },
  "spec": {
    "url": "https://github.com/sensu/sensu-pagerduty-handler/releases/download/1.0.1/sensu-pagerduty-handler_1.0.1_linux_amd64.tar.gz",
    "sha512": "5facfb0706e5e36edc5d13993ecc813a4689c5ca502d70670268ca1c0679e9e2af79af75ee4f7a423b48f2e55524f6d81ce81485975eb3b70048cfa58f4af961",
    "filters": [
      "entity.system.os == 'linux'",
      "entity.system.arch == 'amd64'"
    ]
  }
}

Enterprise-only assets (like the ServiceNow and Jira event handlers) require an active enterprise license. For more information about enterprise-only features and to active your license, see the getting started guide.

2. Register the asset with Sensu

Once you’ve downloaded the asset definition, you can register the asset with Sensu using sensuctl.

sensuctl create --file sensu-sensu-pagerduty-handler-1.0.1-linux-amd64.json

You can use sensuctl to verify that the asset is registered and ready to use.

sensuctl asset list

3. Create a workflow

Now we can use assets in a monitoring workflow. Depending on the asset, you may want to create Sensu checks, filters, mutators, and handlers. The asset details in Bonsai are the best resource for information about asset capabilities and configuration.

For example, to use the Sensu PagerDuty handler asset, create a pagerduty handler that includes your PagerDuty service API key and sensu-pagerduty-handler as a runtime asset.

{
    "api_version": "core/v2",
    "type": "Handler",
    "metadata": {
        "namespace": "default",
        "name": "pagerduty"
    },
    "spec": {
        "type": "pipe",
        "command": "sensu-pagerduty-handler --token SECRET",
        "runtime_assets": ["sensu-pagerduty-handler"],
        "timeout": 10,
        "filters": [
            "is_incident"
        ]
    }
}

Save the definition to a file, and add to Sensu using sensuctl.

sensuctl create --file filename.json

Now that Sensu can create incidents in PagerDuty, we can automate this workflow by adding the pagerduty handler to our Sensu service checks. To get started with checks, see the guide to monitoring server resources.

You can use sensuctl to see available checks, handlers, and other Sensu resources.

sensuctl check list

sensuctl mutator list

sensuctl handler list

Next steps

See the asset reference more information about creating and sharing assets.