Skip to content
This repository was archived by the owner on Dec 23, 2017. It is now read-only.

Commit 048e3fb

Browse files
committed
Merge pull request #12 from Graylog2/alarm-stats
Additional statistics for alarm callbacks and alert counts
2 parents 91cf3ce + 312f6fd commit 048e3fb

File tree

3 files changed

+51
-3
lines changed

3 files changed

+51
-3
lines changed

src/main/java/org/graylog/plugins/usagestatistics/collectors/ClusterCollector.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.google.common.collect.ImmutableMap;
2020
import org.cliffc.high_scale_lib.Counter;
2121
import org.graylog.plugins.usagestatistics.UsageStatsMetaData;
22+
import org.graylog.plugins.usagestatistics.dto.AlarmStats;
2223
import org.graylog.plugins.usagestatistics.dto.ClusterDataSet;
2324
import org.graylog.plugins.usagestatistics.dto.ClusterStats;
2425
import org.graylog.plugins.usagestatistics.dto.LdapStats;
@@ -99,7 +100,8 @@ private ClusterStats buildClusterStats() {
99100
clusterStats.contentPackCount(),
100101
counts.total(),
101102
buildStreamThroughput(),
102-
buildLdapStats()
103+
buildLdapStats(),
104+
buildAlarmStats()
103105
);
104106
}
105107

@@ -126,4 +128,9 @@ private LdapStats buildLdapStats() {
126128
ldapStats.roleMappingCount(),
127129
ldapStats.roleCount());
128130
}
131+
132+
private AlarmStats buildAlarmStats() {
133+
final org.graylog2.system.stats.AlarmStats stats = clusterStatsService.alarmStats();
134+
return AlarmStats.create(stats.alertCount(), stats.alarmcallbackCountByType());
135+
}
129136
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Copyright (C) 2015 Graylog, Inc. ([email protected])
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.graylog.plugins.usagestatistics.dto;
17+
18+
import com.fasterxml.jackson.annotation.JsonAutoDetect;
19+
import com.fasterxml.jackson.annotation.JsonProperty;
20+
import com.google.auto.value.AutoValue;
21+
22+
import java.util.Map;
23+
24+
@JsonAutoDetect
25+
@AutoValue
26+
public abstract class AlarmStats {
27+
@JsonProperty
28+
public abstract long alertCount();
29+
30+
@JsonProperty
31+
public abstract Map<String, Long> alarmcallbackCountByType();
32+
33+
public static AlarmStats create(long alertCount, Map<String, Long> alarmcallbackCountByType) {
34+
return new AutoValue_AlarmStats(alertCount, alarmcallbackCountByType);
35+
}
36+
}

src/main/java/org/graylog/plugins/usagestatistics/dto/ClusterStats.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ public static ClusterStats create(ElasticsearchClusterStats elasticsearchCluster
4646
long contentPackCount,
4747
long totalMessages,
4848
Map<String, Long> streamThroughput,
49-
LdapStats ldapStats
49+
LdapStats ldapStats,
50+
AlarmStats alarmStats
5051
) {
5152
return new AutoValue_ClusterStats(
5253
elasticsearchCluster,
@@ -68,7 +69,8 @@ public static ClusterStats create(ElasticsearchClusterStats elasticsearchCluster
6869
contentPackCount,
6970
totalMessages,
7071
streamThroughput,
71-
ldapStats);
72+
ldapStats,
73+
alarmStats);
7274
}
7375

7476
@JsonProperty
@@ -130,4 +132,7 @@ public static ClusterStats create(ElasticsearchClusterStats elasticsearchCluster
130132

131133
@JsonProperty
132134
public abstract LdapStats ldapStats();
135+
136+
@JsonProperty
137+
public abstract AlarmStats alarmStats();
133138
}

0 commit comments

Comments
 (0)