Skip to content

Commit 895483f

Browse files
AlertManagerPlugin first draft
Signed-off-by: Decker, Stefan <[email protected]>
0 parents  commit 895483f

28 files changed

+1297
-0
lines changed

.gitignore

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### JetBrains template
3+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
4+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
5+
6+
# User-specific stuff
7+
.idea/**/workspace.xml
8+
.idea/**/tasks.xml
9+
.idea/**/usage.statistics.xml
10+
.idea/**/dictionaries
11+
.idea/**/shelf
12+
13+
# Sensitive or high-churn files
14+
.idea/**/dataSources/
15+
.idea/**/dataSources.ids
16+
.idea/**/dataSources.local.xml
17+
.idea/**/sqlDataSources.xml
18+
.idea/**/dynamic.xml
19+
.idea/**/uiDesigner.xml
20+
.idea/**/dbnavigator.xml
21+
22+
# Gradle
23+
.idea/**/gradle.xml
24+
.idea/**/libraries
25+
26+
# Gradle and Maven with auto-import
27+
# When using Gradle or Maven with auto-import, you should exclude module files,
28+
# since they will be recreated, and may cause churn. Uncomment if using
29+
# auto-import.
30+
# .idea/modules.xml
31+
# .idea/*.iml
32+
# .idea/modules
33+
34+
# CMake
35+
cmake-build-*/
36+
37+
# Mongo Explorer plugin
38+
.idea/**/mongoSettings.xml
39+
40+
# File-based project format
41+
*.iws
42+
43+
# IntelliJ
44+
out/
45+
46+
# mpeltonen/sbt-idea plugin
47+
.idea_modules/
48+
49+
# JIRA plugin
50+
atlassian-ide-plugin.xml
51+
52+
# Cursive Clojure plugin
53+
.idea/replstate.xml
54+
55+
# Crashlytics plugin (for Android Studio and IntelliJ)
56+
com_crashlytics_export_strings.xml
57+
crashlytics.properties
58+
crashlytics-build.properties
59+
fabric.properties
60+
61+
# Editor-based Rest Client
62+
.idea/httpRequests
63+
### Maven template
64+
target/
65+
pom.xml.tag
66+
pom.xml.releaseBackup
67+
pom.xml.versionsBackup
68+
pom.xml.next
69+
release.properties
70+
dependency-reduced-pom.xml
71+
buildNumber.properties
72+
.mvn/timing.properties
73+
.mvn/wrapper/maven-wrapper.jar
74+
### Gradle template
75+
.gradle
76+
/build/
77+
78+
# Ignore Gradle GUI config
79+
gradle-app.setting
80+
81+
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
82+
!gradle-wrapper.jar
83+
84+
# Cache of project
85+
.gradletasknamecache
86+
87+
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
88+
# gradle/wrapper/gradle-wrapper.properties
89+
### Java template
90+
# Compiled class file
91+
*.class
92+
93+
# Log file
94+
*.log
95+
96+
# BlueJ files
97+
*.ctxt
98+
99+
# Mobile Tools for Java (J2ME)
100+
.mtj.tmp/
101+
102+
# Package Files #
103+
*.jar
104+
*.war
105+
*.nar
106+
*.ear
107+
*.zip
108+
*.tar.gz
109+
*.rar
110+
111+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
112+
hs_err_pid*
113+
114+
.idea/

.travis.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
language: java
2+
jdk:
3+
- oraclejdk8
4+
5+
services:
6+
- docker
7+
8+
install:
9+
- ./gradlew build -x check --no-daemon
10+
11+
12+
jobs:
13+
include:
14+
- stage: test
15+
env: [ NAME=functionallity ]
16+
script: ./gradlew check javadoc --no-daemon

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
V 0.1
2+
-----------
3+
* First draft for plugin
4+
Working callback which sends some information to the AlertManager with HTTP-POST

CONTRIBUTING.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Contributing
2+
Thank you for considering contributing to the AlertManager-Callback plugin for Graylog.
3+
Feel free to contribute via pull-request.
4+
5+
## General rules
6+
If you are contributing code to this project please make sure that it works properly and has at least some unit tests.
7+
Only add things to this project which are actually needed.
8+
9+
## How to report a bug
10+
Please report any bugs via the GitHub issue section.
11+
A bug should contain at least the following information:
12+
* Short description about the bug
13+
* Current behavior
14+
* Expected behavior
15+
* The affected version
16+
17+
## How to suggest a feature or enhancement
18+
Feel free to suggest features or enhancements via the GitHub issue section.
19+
20+
## Code review process
21+
Anyone of the maintainers mentioned in the [MAINTAINERS](MAINTAINERS) file will do the code review.
22+
23+
## Commit messages
24+
Please use proper commit messages so everyone can see what the commit affects.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2019 G DATA Software AG
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Stefan Decker <[email protected]>

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Graylog AlertManager Notification Plugin
2+
This plugin can be used for connecting [Graylog](https://www.graylog.org/) alerts to the [Prometheus](https://prometheus.io/) [AlertManager](https://prometheus.io/docs/alerting/alertmanager/).
3+
4+
The plugin development is based on [Graylog2/graylog-plugin-sample](https://github.com/Graylog2/graylog-plugin-sample) which is mentioned in the [Graylog plugin documentation](http://docs.graylog.org/en/2.4/pages/plugins.html).
5+
6+
## Use Case
7+
You are using a Graylog for checking the logs for errors, a Prometheus for checking the service metrics and you would like to organize your alerts with a AlertManager you need to get your Graylog alerts into the AlertManager.
8+
This plugin provides the possibility to send your Graylog notifications with a AlertManager-Callback to your AlertManager.
9+
10+
## AlertManager Endpoint
11+
The plugin uses the `/api/v1/alerts` endpoint of AlertManager. You can find some documentation about this endpoint [here](https://prometheus.io/docs/alerting/clients/).
12+
13+
## Provided Information
14+
The plugin provides the AlertManager several information out of the box:
15+
* `stream_title` - The title of the stream triggering the alert condition in Graylog
16+
* `triggered_at` - The time of triggering the alert condition in Graylog
17+
* `triggered_rule_description` - The generated rule description of triggered alert condition in Graylog
18+
* `triggered_rule_title` - The title of alert condition rule in Graylog
19+
20+
All of those information will be added as annotation.
21+
22+
The values `startsAt`, `endsAt` and `generatorURL` will be transmitted to the AlertManager as well.
23+
`startsAt` will be set to the point of time when the condition triggered the alert.
24+
`endsAt` will be set to the point of time when the condition triggered the alert plus the set grace time which is configured for the alert.
25+
26+
## How to deploy on Graylog
27+
You can easily build the plugin by executing `./gradlew build`.
28+
Afterwards there should be a `.jar` file inside the `build/libs/` directory.
29+
Follow the instructions mentioned [here](http://docs.graylog.org/en/2.4/pages/plugins.html#installing-and-loading-plugins) to deploy this `.jar` file.
30+
31+
## Screenshots
32+
![Configuration of Callback](images/New_AlertManager_Callback_Window.png)
33+
34+
## Planned Features
35+
* Add possibility to define custom labels in UI when configuring the callback
36+
* Add possibility to define custom annotations in UI when configuring the callback
37+
38+
You would like to contribute anything? - Take a look at [CONTRIBUTING.md](CONTRIBUTING.md).
39+
40+
## Known Issues
41+
* The test-callback does not work as expected, it will cause an error instead of a notification
42+
* Workaround: You have to create a stream with a alert condition to test the callback
43+
44+
You would like to contribute anything? - Take a look at [CONTRIBUTING.md](CONTRIBUTING.md).
45+
46+
## License
47+
See [LICENSE](LICENSE)
48+
49+
## Copyright
50+
51+
Copyright (c) 2019 G DATA Software AG and other authors.

build.gradle

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
buildscript {
2+
repositories {
3+
maven {
4+
url "https://plugins.gradle.org/m2/"
5+
}
6+
}
7+
dependencies {
8+
classpath "gradle.plugin.com.github.harbby:gradle-serviceloader:1.1.5"
9+
}
10+
}
11+
12+
13+
def title = "mOPS_Graylog_AlertManagerNotificationPlugin"
14+
15+
def getVersionName = { ->
16+
def stdout = new ByteArrayOutputStream()
17+
exec {
18+
commandLine 'git', 'describe', '--tags', '--long'
19+
standardOutput = stdout
20+
}
21+
return stdout.toString().trim()
22+
}
23+
24+
apply plugin: "com.github.harbby.gradle.serviceloader"
25+
apply plugin: 'java'
26+
apply plugin: 'idea'
27+
apply plugin: "jacoco"
28+
29+
jacoco {
30+
toolVersion = "0.8.2"
31+
}
32+
33+
serviceLoader {
34+
serviceInterface 'org.graylog2.plugin.Plugin'
35+
}
36+
37+
group = 'de.gdata.mobilelab'
38+
version = getVersionName()
39+
40+
sourceCompatibility = 1.8
41+
targetCompatibility = 1.8
42+
43+
44+
repositories {
45+
mavenCentral()
46+
maven { url 'http://repo.spring.io/plugins-release/'}
47+
}
48+
49+
dependencies {
50+
// https://mvnrepository.com/artifact/org.graylog2/graylog2-plugin
51+
compile group: 'org.graylog2', name: 'graylog2-server', version: '2.5.0'
52+
53+
// https://mvnrepository.com/artifact/org.jboss.dashboard-builder/dashboard-builder-bom
54+
compile group: 'org.jboss.dashboard-builder', name: 'dashboard-builder-bom', version: '6.5.0.Final', ext: 'pom'
55+
56+
// https://mvnrepository.com/artifact/com.google.auto.value/auto-value
57+
compileOnly group: 'com.google.auto.value', name: 'auto-value', version: '1.6.3'
58+
59+
// https://mvnrepository.com/artifact/org.projectlombok/lombok
60+
compile group: 'org.projectlombok', name: 'lombok', version: '1.18.4'
61+
62+
63+
// TESTS
64+
65+
// https://mvnrepository.com/artifact/org.springframework/spring-web
66+
testCompile group: 'org.springframework', name: 'spring-web', version: '5.1.4.RELEASE'
67+
68+
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
69+
testCompile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.8'
70+
71+
testCompile group: 'junit', name: 'junit', version: '4.12'
72+
73+
// https://mvnrepository.com/artifact/org.mockito/mockito-core
74+
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.7.13'
75+
76+
// https://mvnrepository.com/artifact/org.testcontainers/testcontainers
77+
testCompile group: 'org.testcontainers', name: 'testcontainers', version: '1.10.5'
78+
79+
}
80+
81+
jar {
82+
archiveName = "graylog-plugin-alertmanagercallback-" + getVersionName() + ".jar"
83+
baseName = title
84+
version = getVersionName()
85+
group = "de.gdata.mobilelab.alertmanagercallback"
86+
manifest {
87+
attributes(
88+
'Implementation-Title': title,
89+
'Implementation-Version': getVersionName(),
90+
'Build-Time': new Date().format("yyy-MM-dd HH:mm:ss"),
91+
'Graylog-Plugin-Properties-Path': 'de.gdata.mobilelab.alertmanagercallback.graylog-plugin-alertmanagercallback'
92+
)
93+
}
94+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Wed Feb 06 13:03:44 CET 2019
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip

0 commit comments

Comments
 (0)