A generic HTTP container that sends events to underlying services.
Currently, two services are supported: Slack and OpsGenie.
Others forthcoming.
Look at any of the service classes under services/hydra/notifications/services.
For instance:
hydra.notifications.services.Slack
Services are Akka actors tagged with the HydraNotificationService
trait, which allows them to be loaded dynamically at
start up time.
The lower case short name of the service class becomes the service name. For instance,
hydra.notifications.services.Slack
will be available as "slack"
Create the class in the client module and make sure it extends from http.hydra.notifications.HydraNotification
Examples: SlackNotification and OpsGenieNotification in hydra.notifications.client
Modify http.hydra.notifications.http.NotificationsFormat.scala
and add your service name to the pattern match statements
curl -X POST localhost:8080/notify -d '{"channel":"hydra-ops","message":"an error occured","service":"slack"}' -H "Content-Type:application/json"
curl -X POST localhost:8080/notify -d '{"source":"source","description":"description","tags":["tag1","tag2"],"service":"opsgenie","alias":"alias","note":"note","team":"team","entity":"entity","message":"message","user":"user"}' -H "Content-Type:application/json"
sbt universal:packageBin
The generated zip file will contain both the assembled jar and the run script.
Supply authentication tokens for Slack and OpsGenie by using one of these methods:
- Modify
reference.conf
to add authentication tokens for Slack and OpsGenie. - Supply environment variables
OPSGENIE_TOKEN
andSLACK_TOKEN
- Add the tokens to
/etc/hydra/hydra-notifications.conf
Unzip the executable generated by sbt and run ./bin/hydra-notifications.
By default, the container binds to port 8080. To change that, supply this configuration property:
container.http.port=$PORT_NUMBER
hydra-notifications makes use of environment variables to configure the application. Environment variables make it easy to configure an application for different environments, i.e., stage and prod. Take a look at the env.example for a list of the parameters you can specify with environment variables. If you're running locally, copy the env.example
to .env
. Sbt will pick up the values in .env
and load them into the environment using sbt-dotenv
.