Skip to content

A generic RESTful API to send notifications to different systems through an HTTP endpoint.

License

Notifications You must be signed in to change notification settings

pluralsight/hydra-notifications

Repository files navigation

Hydra Notifications

Build Status codecov Join the chat at https://gitter.im/pluralsight/hydra

A generic HTTP container that sends events to underlying services.

Supported Services

Currently, two services are supported: Slack and OpsGenie.

Others forthcoming.

Adding a new service

Create the service actor

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 service notification case class

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

Add the case class to the SprayJsonFormat

Modify http.hydra.notifications.http.NotificationsFormat.scala and add your service name to the pattern match statements

Example calls

Slack

 curl -X POST localhost:8080/notify -d '{"channel":"hydra-ops","message":"an error occured","service":"slack"}'  -H "Content-Type:application/json"

Ops Genie

  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"

Building

sbt universal:packageBin

The generated zip file will contain both the assembled jar and the run script.

Running the App

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 and SLACK_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

Configuration

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.

About

A generic RESTful API to send notifications to different systems through an HTTP endpoint.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published