Notification Target Management using Spyctl

Published: December 7, 2023

To learn more about what Notification Targets are, see:

pageNotification Targets

Prerequisites

If you have never used Spyctl start here to learn how to install it, then follow the Initial Configuration guide.

Managing Notification Targets

Create

To create a new Notification Target you can use the create command:

Note: This will only create a local yaml file for you to edit. It makes no immediate changes to your Spyderbat environment.

spyctl create notification-target -n NAME -T TYPE

For example:

spyctl create notification-target -n OperationsTeam -T emails > target.yaml

This will create a default Notification Target and save it to a file called target.yaml

target.yaml
apiVersion: spyderbat/v1
kind: NotificationTarget
metadata:
  # The uid will be generated for you when your run the create command
  uid: notif_tgt:XXXXXXXXXXXXXXXXXXXXXX
  name: OperationsTeam
spec:
  emails:
  - example@example.com

Edit

When creating new Notification Targets you will need to edit the default document to point to the proper destination. With spyctl you can use the edit command to ensure you don't accidentally introduce syntax errors.

spyctl edit -f FILENAME

If you have already applied the Notification Target you may edit the resource using the following:

spyctl edit [OPTIONS] notification-target NAME_OR_UID

For example:

spyctl edit -f target.yaml

This will bring up a prompt to select a text editor unless you have already done so previously. Then, using your text editor you may fill in your desired destination or destinations.

If you save without making any changes, nothing happens to the resource or file you're editing. If you save and there were syntax errors, Spyctl will save your draft to a temporary location and re-open it with comments detailing the errors. Finally, if your changes have no syntax errors, Spyctl will update the resource or file you're editing.

Note: If you edit a Notification Target in a local file, but the Target has already been applied. You will need to apply the file again for the updates to take effect.

Apply

In order for a Notification Target to be usable by the Spyderbat Notifications System you must first apply it using the apply command.

spyctl apply -f FILENAME

For example:

spyctl apply -f target.yaml

If the operation is successful, your Notification Target will be ready for use.

Delete

To remove a Notification Target from the Spyderbat Notifications System you can use the delete command.

spyctl delete [OPTIONS] notification-target NAME_OR_UID

For example:

spyctl delete notification-target OperationsTeam

You will not be able to delete a Notification Target that is currently being used by a Notification Configuration

View or Download

You can use the get command to view or download your Notification Targets.

spyctl get [OPTIONS] notification-targets [NAME_OR_UID]

For example:

spyctl get notification-targets
$ spyctl get notification-targets
Getting notification-targets
NAME              ID                                  AGE    TYPE      DESTINATIONS
OperationsTeam    notif_tgt:XXXXXXXXXXXXXXXXXXXXXX    7d     emails               1

The default output is a tabular summary of your Notification Targets. To download the Notification Target as yaml or json you can use the -o option

spyctl get notification-targets -o yaml OperationsTeam
$ spyctl get notification-targets -o yaml OperationsTeam
apiVersion: spyderbat/v1
kind: NotificationTarget
metadata:
  uid: notif_tgt:XXXXXXXXXXXXXXXXXXXXXX
  name: OperationsTeam
spec:
  emails:
  - engineer1@example.com
  - engineer2@example.com

Using the > character you can save the document to a file.

spyctl get notification-targets -o yaml OperationsTeam > target.yaml

Last updated

© SPYDERBAT, Inc., All Rights Reserved