# Sensu

Follow the steps below to configure a service so as to extract its related alert data from Sensu.

Squadcast will then process this information to create incidents for this service as per your preferences.

### Using Sensu as an Alert Source

1. Navigate to **Services** -> **Service Overview** -> select or search for your Service. Expand the accordion -> In the Alert Sources section, click **Add**.

![](https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-4fbd74e7ca0b30173c47a1d58ed6a0804a0465aa%2FAlert_Sources.png?alt=media\&token=aaca6610-9d18-4dd4-9cf5-320042f326f1)

2\. Select **Sensu.** Copy the displayed **Webhook URL** to [configure](#on-your-sensu-server) it within **Sensu**. Finish by clicking **Add Alert Source** -> **Done.**

![](https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-e1e4514529aa213ad688a6bd43ab32fe572f166f%2FSensu.png?alt=media\&token=101ebcd7-1502-4d3a-8f72-7b2c3bbaa5c2)

{% hint style="warning" %}
**Important:**

When an alert source turns Active, it’ll show up under Configured Alert Sources, you can either generate a test alert from the integration or wait for a real-time alert to be generated by the Alert Source. An Alert Source is active if there is a recorded incident via that Alert Source for the Service.
{% endhint %}

### On Your Sensu Server

**Note**: This guide was written and tested on Ubuntu 16.04 and Amazon Linux 2016.09, with Sensu 0.20.2-1 and 0.26.5-2. Paths may be different for other operating systems or Sensu versions. Note that all commands provided are intended to be run as the "root" user.

Save the Squadcast Sensu handler in your Sensu installation's plugins directory.

```
sudo wget -O /etc/sensu/plugins/squadcast-handler.rb https://raw.githubusercontent.com/squadcastHub/sensu_handler/master/squadcast-handler.rb
```

Make sure that the downloaded file has execute permission if not then provide the same using:

```
sudo chmod +x /etc/sensu/plugins/squadcast-handler.rb
```

Using the above file create a Sensu handler in the directory `/etc/sensu/conf.d` `/etc/sensu/conf.d/squadcast-handler.json`

```json
{            
    "handlers": {
        "squadcast": {
            "type": "pipe",
            "command":  "/etc/sensu/plugins/squadcast-handler.rb YOUR-INTEGRATION-KEY-HERE-FROM-STEP-2"                      
        }
    }
}
```

If you want, you can also make it the default handler as follows `/etc/sensu/conf.d/default_handler.json`

```json
{
    "handlers": {
        "default": {
            "type": "set",
            "handlers": [
                "squadcast"
            ]
        }
    }
}
```

Now you can assign this handler to any of your checks, for example: `/etc/sensu/conf.d/YOUR-CHECK.json`

```json
{
    "checks": {
        "YOUR-CHECK-NAME": {
            "command": "YOUR-CHECK-COMMAND",
            "subscribers": [
                "YOUR-SUBSCRIBERS"
            ],
            "interval": YOUR-INTERVAL,
            "handlers": ["default", "squadcast"]
        }
    }
}
```

Restart Sensu for the changes to take effect.

That's it!! Your Sensu integration is now good to go.

Once an event is resolved from Sensu, it will automatically be resolved in Squadcast.

*Have any questions?* [*Ask the community*](https://community.squadcast.com/view/home)*.*


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://support.squadcast.com/integrations/alert-source-integrations-native/sensu.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
