Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Seyren ([/ˈsaɪ.rʌn/](http://en.wikipedia.org/wiki/Wikipedia:IPA_for_English#K
[SLF4J](http://www.slf4j.org),
[Slack](https://www.slack.com),
[SNMP](http://en.wikipedia.org/wiki/Simple_Network_Management_Protocol),
[Twilio](https://www.twilio.com/)

[Twilio](https://www.twilio.com/),
[SNS](https://aws.amazon.com/sns/)

#[<img src="http://i.imgur.com/13nR3YA.png" height="200" width="280" />](http://i.imgur.com/ahu3aM6.png)

Expand Down Expand Up @@ -142,6 +142,11 @@ The target for a Slack subscription will be the channel name (including the `#`,
##### [Victorops](https://www.victorops.com/)
* `VICTOROPS_REST_ENDPOINT` - The REST Endpoint given by Victorops. See [REST Integration]( http://victorops.force.com/knowledgebase/articles/Integration/Alert-Ingestion-API-Documentation/) Default ``

##### [SNS](https://aws.amazon.com/sns/)
* `SNS_REGION` - The region of the SNS ARN. Default `eu-west-1`. Must match the [region from the list](http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/regions/Regions.html#valueOf-java.lang.String-).
* AWS SNS Client uses [default AWS credentials provider chain.](http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/auth/DefaultAWSCredentialsProviderChain.html)
* Target is an ARN of the SNS Topic.

##### [Proxy](http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/client/HttpClientBuilder.html#useSystemProperties())
The Proxy settings are changed by using JAVA_OPTS. It important that you exclude your graphite server or you will proxy these requests also.
* `JAVA_OPTS Example` JAVA_OPTS="-server -Dhttps.proxyHost=`PROXYSERVER` -Dhttps.proxyPort=`PROXYPORT` -Dhttp.proxyHost=`PROXYSERVER` -Dhttp.proxyPort=`PROXYPORT` -Dhttp.nonProxyHosts=`GRAPHITESERVER|*YOURDOMAIN.COM|INTERNALHIPCHAT`"
Expand Down
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

<properties>
<mongo.version>3.2.6</mongo.version>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<ch.qos.logback.version>1.1.2</ch.qos.logback.version>
Expand All @@ -59,7 +59,7 @@
<com.fasterxml.jackson.jaxrs.version>2.5.0</com.fasterxml.jackson.jaxrs.version>
<com.github.rest-driver.version>1.1.42</com.github.rest-driver.version>
<com.google.guava.version>18.0</com.google.guava.version>
<com.opsgenie.integration.sdk.version>2.0.7</com.opsgenie.integration.sdk.version>
<com.opsgenie.integration.sdk.version>2.4.2</com.opsgenie.integration.sdk.version>
<com.squareup.pagerduty.version>1.0.1</com.squareup.pagerduty.version>
<commons.io.version>2.4</commons.io.version>
<commons-lang.version>2.6</commons-lang.version>
Expand All @@ -68,7 +68,7 @@
<javax.mail.version>1.4.7</javax.mail.version>
<joda-time.version>2.6</joda-time.version>
<junit.version>4.12</junit.version>
<org.apache.httpcomponents.version>4.3.6</org.apache.httpcomponents.version>
<org.apache.httpcomponents.version>4.5.2</org.apache.httpcomponents.version>
<org.apache.velocity.version>1.7</org.apache.velocity.version>
<org.eclipse.jetty.version>9.2.2.v20140723</org.eclipse.jetty.version>
<org.hamcrest.version>1.3</org.hamcrest.version>
Expand All @@ -77,10 +77,10 @@
<org.mongodb.version>3.2.2</org.mongodb.version>
<org.python.version>2.5.3</org.python.version>
<org.slf4j.version>1.7.9</org.slf4j.version>
<org.snmp4j.version>2.3.3</org.snmp4j.version>
<org.snmp4j.version>2.5.2</org.snmp4j.version>
<org.springframework.version>4.1.4.RELEASE</org.springframework.version>
</properties>

<prerequisites>
<maven>3.0</maven>
</prerequisites>
Expand Down Expand Up @@ -189,7 +189,7 @@
</goals>
</execution>
</executions>
</plugin>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions seyren-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
</parent>

<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-sns</artifactId>
<version>1.11.46</version>
</dependency>
<dependency>
<groupId>com.squareup.pagerduty</groupId>
<artifactId>pagerduty-incidents</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,20 @@
package com.seyren.core.domain;

public enum SubscriptionType {

EMAIL, PAGERDUTY, HIPCHAT, HUBOT, FLOWDOCK, HTTP, IRCCAT, PUSHOVER, LOGGER, SNMP, SLACK, TWILIO, VICTOROPS,
OPSGENIE, BIGPANDA
EMAIL,
PAGERDUTY,
HIPCHAT,
HUBOT,
FLOWDOCK,
HTTP,
IRCCAT,
PUSHOVER,
LOGGER,
SNMP,
SLACK,
TWILIO,
VICTOROPS,
OPSGENIE,
BIGPANDA,
SNS
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/**
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.seyren.core.service.notification;

import java.util.List;

import javax.inject.Inject;
import javax.inject.Named;

import org.springframework.mail.javamail.JavaMailSender;

import com.seyren.core.domain.Alert;
import com.seyren.core.domain.Check;
import com.seyren.core.domain.Subscription;
import com.seyren.core.domain.SubscriptionType;
import com.seyren.core.exception.NotificationFailedException;
import com.seyren.core.util.config.SeyrenConfig;

import com.amazonaws.services.sns.AmazonSNSClient;
import com.amazonaws.auth.ClasspathPropertiesFileCredentialsProvider;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.sns.model.PublishRequest;
import com.amazonaws.services.sns.model.PublishResult;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Named
public class SnsNotificationService implements NotificationService {
private static final Logger LOGGER = LoggerFactory.getLogger(SnsNotificationService.class);

private AmazonSNSClient snsClient;
private SeyrenConfig seyrenConfig;

@Inject
public SnsNotificationService(SeyrenConfig seyrenConfig) {
this.seyrenConfig = seyrenConfig;

String snsRegion = this.seyrenConfig.getSnsRegion();

this.snsClient = new AmazonSNSClient();
this.snsClient.setRegion(Region.getRegion(Regions.fromName(snsRegion)));
}

@Override
public void sendNotification(Check check, Subscription subscription, List<Alert> alerts) {
String checkUrl = this.seyrenConfig.getBaseUrl() + "/#/checks/" + check.getId();
String topicArn = subscription.getTarget();

String msg = String.format("Seyren notification '%s' changed state to '%s' %s",
check.getName(),
check.getState().name(),
checkUrl);

LOGGER.info("Sending Notification to SNS Topic: " + topicArn + " with message " + msg);

PublishRequest publishRequest = new PublishRequest(topicArn, msg);
PublishResult publishResult = snsClient.publish(publishRequest);

LOGGER.info("Send Notification - " + publishResult.getMessageId());
}

@Override
public boolean canHandle(SubscriptionType subscriptionType) {
return subscriptionType == SubscriptionType.SNS;
}
}
Loading