From cbdb8d0ad072b4040d1b3999e475cefa96f2e349 Mon Sep 17 00:00:00 2001 From: Christiaan van Tienhoven Date: Mon, 5 Dec 2016 12:18:38 +0100 Subject: [PATCH] Fixes #2 (stream ID wasn't included in search link) --- pom.xml | 2 +- .../graylog/plugins/aggregates/AggregatesMetaData.java | 2 +- .../plugins/aggregates/rule/alert/RuleAlertSender.java | 8 +++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index d0666d5..cb7f96b 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.graylog.plugins.aggregates graylog-plugin-aggregates - 0.0.12 + 0.0.13 jar ${project.artifactId} diff --git a/src/main/java/org/graylog/plugins/aggregates/AggregatesMetaData.java b/src/main/java/org/graylog/plugins/aggregates/AggregatesMetaData.java index 60b0c55..d743520 100644 --- a/src/main/java/org/graylog/plugins/aggregates/AggregatesMetaData.java +++ b/src/main/java/org/graylog/plugins/aggregates/AggregatesMetaData.java @@ -34,7 +34,7 @@ public URI getURL() { @Override public Version getVersion() { - return new Version(0, 0, 12); + return new Version(0, 0, 13); } @Override diff --git a/src/main/java/org/graylog/plugins/aggregates/rule/alert/RuleAlertSender.java b/src/main/java/org/graylog/plugins/aggregates/rule/alert/RuleAlertSender.java index 32a4d70..e2569f3 100644 --- a/src/main/java/org/graylog/plugins/aggregates/rule/alert/RuleAlertSender.java +++ b/src/main/java/org/graylog/plugins/aggregates/rule/alert/RuleAlertSender.java @@ -135,7 +135,13 @@ protected String buildSummary(Rule rule, Map matchedTerms, TimeRan sb.append("").append(entry.getValue()).append(""); try { - String search_uri="/search?rangetype=absolute&fields=message%2Csource%2C"+rule.getField()+"&from="+timeRange.getFrom()+"&to="+timeRange.getTo()+"&q="+URLEncoder.encode(rule.getQuery()+" AND " + rule.getField()+":\""+entry.getKey()+"\"", "UTF-8"); + String streamId = rule.getStreamId(); + String search_uri = ""; + + if (streamId != null && streamId != ""){ + search_uri+="/streams/"+streamId; + } + search_uri+="/search?rangetype=absolute&fields=message%2Csource%2C"+rule.getField()+"&from="+timeRange.getFrom()+"&to="+timeRange.getTo()+"&q="+URLEncoder.encode(rule.getQuery()+" AND " + rule.getField()+":\""+entry.getKey()+"\"", "UTF-8"); sb.append("").append("Search").append(""); } catch (UnsupportedEncodingException e) { sb.append("").append("Unable to URL encode search URI").append("");