Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pluralsight/hydra-notifications
A generic RESTful API to send notifications to different systems through an HTTP endpoint.
https://github.com/pluralsight/hydra-notifications
akka notifications opsgenie scala slack
Last synced: 1 day ago
JSON representation
A generic RESTful API to send notifications to different systems through an HTTP endpoint.
- Host: GitHub
- URL: https://github.com/pluralsight/hydra-notifications
- Owner: pluralsight
- License: apache-2.0
- Created: 2017-09-15T14:55:40.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-04-11T13:46:42.000Z (7 months ago)
- Last Synced: 2024-04-14T04:07:52.267Z (7 months ago)
- Topics: akka, notifications, opsgenie, scala, slack
- Language: Scala
- Size: 230 KB
- Stars: 2
- Watchers: 6
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Hydra Notifications
[![Build Status](https://travis-ci.org/pluralsight/hydra-notifications.svg?branch=master)](https://travis-ci.org/pluralsight/hydra-notifications)
[![codecov](https://codecov.io/gh/pluralsight/hydra-notifications/branch/master/graph/badge.svg)](https://codecov.io/gh/pluralsight/hydra-notifications)
[![Join the chat at https://gitter.im/pluralsight/hydra](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/pluralsight/hydra-notifications?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)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
```bash
curl -X POST localhost:8080/notify -d '{"channel":"hydra-ops","message":"an error occured","service":"slack"}' -H "Content-Type:application/json"
```
## Ops Genie
```bash
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 AppSupply 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`.