How to Set Up Notifications Using Spyctl
Configure notifications using Spyctl to receive alerts for significant security or operations events.
Published: November 7, 2023
Prerequisites
Overview
Spyderbat's notification system has 3 main components:
Notification Targets: Named destinations to where notifications can be sent.
Notification Configurations: Documents directing Spyderbat on when and where to send notifications. They link to one or more Notification Targets
Notification Configuration Templates: Pre-built templates containing most of the information required to create a Notification Config. These templates simplify the configuration process.
For the the full documentation of the Spyderbat Notifications System refer to this section.
How to Set Up A Notification Target
The first thing to do when setting up notification with Spyderbat is to identify who or what you want to notify be it an email, Slack channel, webhook, or AWS SNS topic. This guide will cover the first 2 options.
All of the commands to manage Notification Targets using Spyctl can be found here.
How to Set Up an Email Target
Create
Use the create
command to create a Notification Target YAML document with emails
in the --type
option:
for example:
This will create a yaml document called target.yaml with a default template for an Email Notification Target
Edit
Email Notification Targets contain a list of 1 or more emails to send notifications to. You can edit this document using the edit
command. When using the edit
command Spyctl will open your default text editor and automatically validate your document on save.
for example:
Add your desired email destination(s) to the Notification Target document.
for example:
Once you have added the emails and saved the document you are now ready to apply the Notification Target.
Apply
Use the apply
command to save the Notification Target for later use.
for example:
How to Set Up a Slack Target
Create
Use the create
command to create a Notification Target YAML document with emails
in the --type
option:
for example:
This will create a yaml document called target.yaml with a default template for a Slack Notification Target
Edit
Slack Notification Targets point to a Slack Hook URL. You can edit this document using the edit
command to add your own URL. When using the edit
command Spyctl will open your default text editor and automatically validate your document on save.
for example:
Add your desired Slack Hook URL destination to the Notification Target document.
Once you have added the URL and saved the document you are now ready to apply the Notification Target.
Apply
Use the apply
command to save the Notification Target for later use.
for example:
How to Test a Notification Target
To test that the notification target is configured correctly, use the following command:
Once this command is run, you should receive a test notification at your specified target in a short amount of time.
How to Set Up Agent Health Notifications
Before going through this section, make sure you have already created at least 1 Notification Target.
All of the commands to manage Notification Configurations using Spyctl can be found here.
Setting up Agent Health notifications is quick and easy using Notification Configuration Templates. To see which notifications can be set up quickly, use the get
command to view Agent Health Notification Config Templates.
This will show you a table of available templates.
For this guide we will show you how to setup a notification when one of your Spyderbat Nano Agent's goes offline. You can follow the same steps for any other the other templates you wish to use.
Create the Notification Config
Using the create
command you can quickly create a Notification Configuration yaml document.
for example:
This will create a Notification Configuration from the "Agent Offline" template and look like this:
Apply the Notification Configuration
At this point no further changes are required. You can use the apply
command to save this Config.
for example:
At this point a notification will be sent to the Target specified in the Config whenever Spyderbat is no longer receiving data from on of your Agents.
(optional) Add a Second Target
Notifications may be sent to multiple Notification Targets at once. To add a second Target, first ensure you have already configured a second Target, then edit a local file or existing Notification Config with the edit
command.
for example:
Then update the target
field of the Notification Config. This field accepts either a single string or a list of strings.
When you save, a notification will be sent to both Targets when the condition is triggered.
Note: If editing a local file, remember to use the apply
command for changes to take effect.
(optional) Limit the Scope to a Cluster
You can limit the scope of a Notification Config, such as by cluster. To limit the scope of a Notification Config to a specific cluster edit a local file or existing Notification Config with the edit
command.
for example:
Then update the condition
field of the Notification Config. This field is a string that tells Spyderbat under what conditions to emit a notification. If it is an empty string that defaults to a condition match, otherwise it will evaluate fields within the evaluated JSON object. If the condition is an empty string ""
just add in the cluster condition:
If there is an existing condition string, you can add a clause to the condition using the AND
keyword.
You can add additional clusters using the OR
keyword and ()
You can also use pattern matching to scope to multiple clusters. For example, if you have multiple clusters that start with "dev" you can modify the condition like this:
When you save, your changes will take effect.
Note: If editing a local file, remember to use the apply
command for changes to take effect.
(optional) Limit the Scope to Non-ephemeral Agents
Some Spyderbat Agents are ephemeral by the nature of the underlying machine they are installed on, such as nodes in a Kubernetes cluster. It is common for nodes to be created or deleted on demand and therefore it may be inconvenient to receive a notification every time one goes offline.
To limit the scope of an Agent Health notification to non-ephemeral (permanent) Nano Agents edit a local file or existing Notification Config with the edit
command.
for example:
Then update the condition
field of the Notification Config. This field is a string that tells Spyderbat under what conditions to emit a notification. If it is an empty string that defaults to a condition match, otherwise it will evaluate fields within the evaluated JSON object. If the condition is an empty string ""
just add in the cluster condition:
If there is an existing condition string, you can add a clause to the condition using the AND
keyword.
When you save, your changes will take effect.
Note: If editing a local file, remember to use the apply
command for changes to take effect.
How to Set Up Security Notifications
Before going through this section, make sure you have already created at least 1 Notification Target.
All of the commands to manage Notification Configurations using Spyctl can be found here.
Setting up Security notifications is quick and easy using Notification Configuration Templates. To see which notifications can be set up quickly, use the get
command to view Security-related Notification Config Templates.
This will show you a table of available templates.
For this guide we will show you how to setup a notification for when someone performs an interactive SSH login to one of your machines. You can follow the same steps for any other the other templates you wish to use.
Create the Notification Config
Using the create
command you can quickly create a Notification Configuration yaml document.
for example:
This will create a Notification Configuration from the "Agent Offline" template and look like this:
Apply the Notification Configuration
At this point no further changes are required. You can use the apply
command to save this Config.
for example:
At this point a notification will be sent to the Target specified in the Config whenever Spyderbat detects an interactive SSH session on one of your machines.
Detailed Documentation
For in-depth documentation on how Notification Configs work go here.
Last updated