Skip to content

Commit c4bfdbb

Browse files
Merge pull request #13 from GDATASoftwareAG/feature/migrate_to_graylog_3
Dependency upgrades and usage within Graylog 3.3.5
2 parents fa55cc8 + 77eef55 commit c4bfdbb

File tree

10 files changed

+113
-37
lines changed

10 files changed

+113
-37
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
V 1.2.2
2+
-----------
3+
* Upgraded dependencies
4+
* Target changed to Graylog 3.3.5 (as legacy alarm callback)
5+
16
V 1.2.1
27
-----------
38
* Fixed alerts with zero grace time

README.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
# Graylog AlertManager Notification Plugin
77
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/).
88

9-
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).
9+
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/3.3/pages/plugins.html).
10+
11+
**Note:** this plugin is currently only available as "Legacy Alarm Callbacks" item after adding it to Graylog
12+
![Legacy Alarm Callback](images/Legacy_Plugin.png)
13+
14+
The current plugin version 1.2.2 has Graylog 3.3.5 as target. The plugin version 1.2.1 (see releases) targets Graylog 2.5.0 and above.
1015

1116
## Use Case
1217
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.
@@ -42,18 +47,20 @@ List of provided keys you can use inside JMTE Templates:
4247
## How to deploy on Graylog
4348
You can easily build the plugin by executing `./gradlew build -x check --no-daemon`.
4449
Afterwards there should be a `.jar` file inside the `build/libs/` directory.
45-
Follow the instructions mentioned [here](http://docs.graylog.org/en/2.4/pages/plugins.html#installing-and-loading-plugins) to deploy this `.jar` file.
50+
Follow the instructions mentioned [here](http://docs.graylog.org/en/3.3/pages/plugins.html#installing-and-loading-plugins) to deploy this `.jar` file.
51+
52+
## How to develop locally
53+
You can use Docker and Docker-Compose to test changes of this plugin locally by following these steps:
54+
1. Build the JAR
55+
2. Run `docker-compose up` inside the development directory
56+
3. Access your local Graylog instance web-interface at http://localhost:9000/
57+
4. You can configure an alert to be send to `http://alertmanager:9093/api/v1/alerts` and access the AlertManager via http://localhost:9093/
4658

4759
## Screenshots
4860
![Configuration of Callback](images/New_AlertManager_Callback_Window.png)
4961

5062
## Planned Features
51-
You would like to contribute anything? - Take a look at [CONTRIBUTING.md](CONTRIBUTING.md).
52-
53-
## Known Issues
54-
* The test alert will not be shown in AlertManager
55-
* When clicking on `Test` to test your callback configuration it will show a green ok bar when everything is fine but the alert will not be shown in the AlertManager
56-
* You have to create a stream with a alert condition to test the callback alert in AlertManager
63+
* Implementation of EventNotification for usage as non-legacy notification plugin
5764

5865
You would like to contribute anything? - Take a look at [CONTRIBUTING.md](CONTRIBUTING.md).
5966

@@ -62,4 +69,4 @@ See [LICENSE](LICENSE)
6269

6370
## Copyright
6471

65-
Copyright (c) 2019 G DATA CyberDefense AG and other authors.
72+
Copyright (c) 2019-2020 G DATA CyberDefense AG and other authors.

build.gradle

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ serviceLoader {
2626
}
2727

2828
group = 'de.gdata.mobilelab'
29-
version = "1.2.1"
29+
version = "1.2.2"
3030

3131
sourceCompatibility = 1.8
3232
targetCompatibility = 1.8
@@ -46,44 +46,44 @@ repositories {
4646

4747
dependencies {
4848
// https://mvnrepository.com/artifact/org.graylog2/graylog2-server
49-
compile group: 'org.graylog2', name: 'graylog2-server', version: '2.5.0'
49+
implementation group: 'org.graylog2', name: 'graylog2-server', version: '3.3.5'
5050

5151
// https://mvnrepository.com/artifact/org.jboss.dashboard-builder/dashboard-builder-bom
52-
compile group: 'org.jboss.dashboard-builder', name: 'dashboard-builder-bom', version: '6.5.0.Final', ext: 'pom'
52+
implementation group: 'org.jboss.dashboard-builder', name: 'dashboard-builder-bom', version: '6.5.0.Final', ext: 'pom'
5353

5454
// https://mvnrepository.com/artifact/com.google.auto.value/auto-value
55-
compileOnly group: 'com.google.auto.value', name: 'auto-value', version: '1.6.3'
55+
compileOnly group: 'com.google.auto.value', name: 'auto-value', version: '1.7.4'
5656

5757
// https://mvnrepository.com/artifact/org.projectlombok/lombok
58-
compile group: 'org.projectlombok', name: 'lombok', version: '1.18.4'
59-
58+
implementation group: 'org.projectlombok', name: 'lombok', version: '1.18.12'
59+
annotationProcessor('org.projectlombok:lombok:1.18.12')
6060

6161
// TESTS
6262

6363
// https://mvnrepository.com/artifact/org.springframework/spring-web
64-
testCompile group: 'org.springframework', name: 'spring-web', version: '5.1.4.RELEASE'
64+
testImplementation group: 'org.springframework', name: 'spring-web', version: '5.2.8.RELEASE'
6565

6666
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
67-
testCompile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.8'
67+
testImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.11.2'
6868

69-
testCompile group: 'junit', name: 'junit', version: '4.12'
69+
testImplementation group: 'junit', name: 'junit', version: '4.13'
7070

7171
// https://mvnrepository.com/artifact/org.mockito/mockito-core
72-
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.7.13'
72+
testImplementation group: 'org.mockito', name: 'mockito-core', version: '3.5.0'
7373

7474
// https://mvnrepository.com/artifact/org.testcontainers/testcontainers
75-
testCompile group: 'org.testcontainers', name: 'testcontainers', version: '1.10.5'
75+
testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.14.3'
7676

7777
}
7878

7979
jar {
80-
archiveName = "graylog-plugin-alertmanagercallback-" + version + ".jar"
81-
baseName = title
80+
archiveFileName = "graylog-plugin-alertmanagercallback-" + version + ".jar"
81+
archiveBaseName = title
8282
group = "de.gdata.mobilelab.alertmanagercallback"
8383
manifest {
8484
attributes(
8585
'Implementation-Title': title,
86-
'Implementation-Version': version,
86+
'Implementation-Version': archiveVersion,
8787
'Build-Time': new Date().format("yyy-MM-dd HH:mm:ss"),
8888
'Graylog-Plugin-Properties-Path': 'de.gdata.mobilelab.alertmanagercallback.graylog-plugin-alertmanagercallback'
8989
)

development/docker-compose.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
version: '2'
2+
services:
3+
4+
5+
mongodb:
6+
image: mongo:3
7+
volumes:
8+
- mongo_data:/data/db
9+
10+
11+
elasticsearch:
12+
image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.8.10
13+
volumes:
14+
- es_data:/usr/share/elasticsearch/data
15+
environment:
16+
- http.host=0.0.0.0
17+
- transport.host=localhost
18+
- network.host=0.0.0.0
19+
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
20+
ulimits:
21+
memlock:
22+
soft: -1
23+
hard: -1
24+
mem_limit: 1g
25+
26+
27+
graylog:
28+
image: graylog/graylog:3.3.5
29+
volumes:
30+
- graylog_journal:/usr/share/graylog/data/journal
31+
- ../build/libs/graylog-plugin-alertmanagercallback-1.2.2.jar:/usr/share/graylog/plugin/graylog-plugin-alertmanagercallback.jar
32+
environment:
33+
# CHANGE ME (must be at least 16 characters)!
34+
- GRAYLOG_PASSWORD_SECRET=somepasswordpepper
35+
# Password: admin
36+
- GRAYLOG_ROOT_PASSWORD_SHA2=8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918
37+
- GRAYLOG_HTTP_EXTERNAL_URI=http://127.0.0.1:9000/
38+
links:
39+
- mongodb:mongo
40+
- elasticsearch
41+
depends_on:
42+
- mongodb
43+
- elasticsearch
44+
ports:
45+
# Graylog web interface and REST API
46+
- 9000:9000
47+
# Syslog TCP
48+
- 1514:1514
49+
# Syslog UDP
50+
- 1514:1514/udp
51+
# GELF TCP
52+
- 12201:12201
53+
# GELF UDP
54+
- 12201:12201/udp
55+
56+
alertmanager:
57+
image: prom/alertmanager:v0.20.0
58+
ports:
59+
- 9093:9093
60+
61+
volumes:
62+
mongo_data:
63+
driver: local
64+
es_data:
65+
driver: local
66+
graylog_journal:
67+
driver: local
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Wed Feb 06 13:03:44 CET 2019
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip

images/Legacy_Plugin.png

19.6 KB
Loading

src/main/java/de/gdata/mobilelab/alertmanagercallback/AlertManagerPluginMetaData.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public URI getURL() {
3232

3333
@Override
3434
public Version getVersion() {
35-
return Version.from(1, 2, 1);
35+
return Version.from(1, 2, 2);
3636
}
3737

3838
@Override
@@ -42,7 +42,7 @@ public String getDescription() {
4242

4343
@Override
4444
public Version getRequiredVersion() {
45-
return Version.from(2, 5, 0);
45+
return Version.from(3, 3, 5);
4646
}
4747

4848
@Override

src/main/resources/de.gdata.mobilelab.alertmanagercallback.alertmanager-plugin/graylog-plugin.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# The plugin version
2-
version=0.1
2+
version=1.2.2
33

44
# The required Graylog server version
5-
graylog.version=2.5.0
5+
graylog.version=3.3.5
66

77
# When set to true (the default) the plugin gets a separate class loader
88
# when loading the plugin. When set to false, the plugin shares a class loader

src/test/java/de/gdata/mobilelab/alertmanagercallback/AlertManagerAlarmCallbackIT.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@
1616
import java.util.HashMap;
1717
import java.util.Map;
1818

19-
import static org.junit.Assert.assertEquals;
20-
import static org.junit.Assert.assertNotNull;
21-
import static org.junit.Assert.assertTrue;
19+
import static org.junit.Assert.*;
2220
import static org.mockito.Mockito.mock;
2321
import static org.mockito.Mockito.when;
2422

2523
public class AlertManagerAlarmCallbackIT {
2624

2725
@Rule
28-
public GenericContainer alertManagerContainer = new GenericContainer("prom/alertmanager:v0.15.3")
26+
public GenericContainer alertManagerContainer = new GenericContainer("prom/alertmanager:v0.20.0")
2927
.withExposedPorts(9093)
3028
.waitingFor(new HostPortWaitStrategy());
3129

@@ -88,7 +86,7 @@ public void call() throws AlarmCallbackException {
8886
// and: Alert has been triggered in AlertManager
8987
String alertOverview = new RestTemplate().getForObject("http://" + alertManagerContainer.getContainerIpAddress()
9088
+ ":" + alertManagerContainer.getMappedPort(9093)
91-
+ "/api/v1/alerts/groups",
89+
+ "/api/v2/alerts/groups",
9290
String.class);
9391
assertNotNull(alertOverview);
9492
assertTrue(alertOverview.contains("TestAlert1"));
@@ -119,7 +117,7 @@ public void callWithNullValues() throws AlarmCallbackException {
119117
// and: Alert has been triggered in AlertManager
120118
String alertOverview = new RestTemplate().getForObject("http://" + alertManagerContainer.getContainerIpAddress()
121119
+ ":" + alertManagerContainer.getMappedPort(9093)
122-
+ "/api/v1/alerts/groups",
120+
+ "/api/v2/alerts/groups",
123121
String.class);
124122
assertNotNull(alertOverview);
125123
assertTrue(alertOverview.contains("TestAlert1"));

src/test/java/de/gdata/mobilelab/alertmanagercallback/AlertManagerPluginMetaDataTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void getURL() {
3838

3939
@Test
4040
public void getVersion() {
41-
assertEquals(Version.from(1, 2, 1), new AlertManagerPluginMetaData().getVersion());
41+
assertEquals(Version.from(1, 2, 2), new AlertManagerPluginMetaData().getVersion());
4242
}
4343

4444
@Test
@@ -48,7 +48,7 @@ public void getDescription() {
4848

4949
@Test
5050
public void getRequiredVersion() {
51-
assertEquals(Version.from(2, 5, 0), new AlertManagerPluginMetaData().getRequiredVersion());
51+
assertEquals(Version.from(3, 3, 5), new AlertManagerPluginMetaData().getRequiredVersion());
5252
}
5353

5454
@Test

0 commit comments

Comments
 (0)