Browse code

[metrics] BM-13335 Fix: Dynamic size for postfix-queue-size alerting

qvigand authored on 10/07/2018 14:22:00
Showing 2 changed files
... ...
@@ -10,6 +10,7 @@ import org.vertx.java.core.json.JsonObject;
10 10
 
11 11
 import net.bluemind.core.rest.BmContext;
12 12
 import net.bluemind.metrics.core.tick.ITickTemplateProvider;
13
+import net.bluemind.system.api.ISystemConfiguration;
13 14
 
14 15
 public class PostfixQueueSize implements ITickTemplateProvider {
15 16
 
... ...
@@ -27,7 +28,13 @@ public class PostfixQueueSize implements ITickTemplateProvider {
27 27
 
28 28
 	@Override
29 29
 	public List<TemplateDefinition> createDefinitions(BmContext ctx, String endPointUrl) {
30
+		ISystemConfiguration sysConfApi = ctx.provider().instance(ISystemConfiguration.class);
31
+		Integer maxSize = sysConfApi.getValues().integerValue("message_size_limit");
32
+		maxSize = maxSize == null ? 100000000 : maxSize * 10;
30 33
 		TemplateDefinition def = new TemplateDefinition("postfix-queue-size");
34
+		JsonObject maxVar = new JsonObject().putString("type", "int").putNumber("value", maxSize);
35
+		logger.info("Alerting when emails Size > {}", maxSize);
36
+		def.variables.putObject("maxVar", maxVar);
31 37
 		def.variables.putObject("alertsEndPoint",
32 38
 				new JsonObject().putString("type", "string").putString("value", endPointUrl));
33 39
 		logger.info("Definition is {}", def.variables.encodePrettily());
... ...
@@ -1,5 +1,7 @@
1 1
 var alertsEndPoint string
2 2
 
3
+var maxVar int
4
+
3 5
 var db = 'telegraf'
4 6
 
5 7
 var rp = 'autogen'
... ...
@@ -32,7 +34,7 @@ var outputMeasurement = 'alerts'
32 32
 
33 33
 var triggerType = 'threshold'
34 34
 
35
-var crit = 10000
35
+var crit = maxVar
36 36
 
37 37
 var data = stream
38 38
     |from()