diff --git a/.gitignore b/.gitignore index 3e7ba63..43cbc10 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -.idea/ -target/ -rpm/target/ +/.idea/ +/target/ +/rpm/target/ diff --git a/README.adoc b/README.adoc index 5ff9baf..586e813 100644 --- a/README.adoc +++ b/README.adoc @@ -6,10 +6,16 @@ Measures latency for RELP records. Provides Dropwizard metrics -Provides Prometheus endpoint +Provides Prometheus endpoint. It listens to port set by `metrics.port` and exposes metrics to path `/metrics` + +Provides Prometheus template for Zabbix == Documentation +=== Zabbix + +Import the template, add `{$PROMETHEUS_HOST}` macro with full url to the metrics endpoint to wanted host and link it to `rlp_11_prometheus` template. + == Limitations == How to compile diff --git a/rpm/rpm.pom.xml b/rpm/rpm.pom.xml index 2c83a22..3bb2584 100644 --- a/rpm/rpm.pom.xml +++ b/rpm/rpm.pom.xml @@ -89,6 +89,25 @@ + + /opt/teragrep/${project.artifactId}/share/doc/zabbix/templates + true + 755 + true + + + /opt/teragrep/${project.artifactId}/share/doc/zabbix/templates + noreplace + false + srv-rlp_11 + srv-rlp_11 + true + + + ${project.basedir}/src/opt/teragrep/rlp_11/share/doc/zabbix/templates/zabbix.template.json + + + /opt/teragrep/${project.artifactId}/etc true diff --git a/rpm/src/opt/teragrep/rlp_11/etc/rlp_11.properties b/rpm/src/opt/teragrep/rlp_11/etc/rlp_11.properties index 52a88ba..99cb3ed 100644 --- a/rpm/src/opt/teragrep/rlp_11/etc/rlp_11.properties +++ b/rpm/src/opt/teragrep/rlp_11/etc/rlp_11.properties @@ -1,5 +1,3 @@ -# Metrics reporting name. Arbitrary string, only used for reporting purposes -metrics.name=target # Metrics window size metrics.window=10000 # Metrics report interval, in seconds diff --git a/rpm/src/opt/teragrep/rlp_11/share/doc/zabbix/templates/zabbix.template.json b/rpm/src/opt/teragrep/rlp_11/share/doc/zabbix/templates/zabbix.template.json new file mode 100644 index 0000000..6832e08 --- /dev/null +++ b/rpm/src/opt/teragrep/rlp_11/share/doc/zabbix/templates/zabbix.template.json @@ -0,0 +1,454 @@ +{ + "zabbix_export": { + "version": "6.0", + "date": "2024-11-12T12:01:55Z", + "groups": [ + { + "uuid": "33ffa51c92774b2d9b04a9341e726734", + "name": "rlp_11" + } + ], + "templates": [ + { + "uuid": "2ed958d0bd564435b8745719bf655f9f", + "template": "rlp_11_prometheus", + "name": "rlp_11_prometheus", + "groups": [ + { + "name": "rlp_11" + } + ], + "items": [ + { + "uuid": "072dbcfd14d64adf81b53b3f3e8f24ee", + "name": "Prometheus Agent rlp_11", + "type": "HTTP_AGENT", + "key": "prometheus_agent_rlp_11", + "delay": "5s", + "value_type": "TEXT", + "url": "{$PROMETHEUS_HOST}" + }, + { + "uuid": "5b34ca0f63c0484ba19e35d28a8e387f", + "name": "rlp_11_com_teragrep_rlp_11_RelpProbe_connects", + "type": "DEPENDENT", + "key": "rlp_11_com_teragrep_rlp_11_RelpProbe_connects", + "delay": "0", + "value_type": "FLOAT", + "description": "Generated from Dropwizard metric import (metric=com.teragrep.rlp_11.RelpProbe.connects, type=com.codahale.metrics.Counter)", + "preprocessing": [ + { + "type": "PROMETHEUS_PATTERN", + "parameters": [ + "com_teragrep_rlp_11_RelpProbe_connects", + "value", + "" + ] + } + ], + "master_item": { + "key": "prometheus_agent_rlp_11" + } + }, + { + "uuid": "679bbda9a1fd4e428a5ae6d5b1baeaec", + "name": "rlp_11_com_teragrep_rlp_11_RelpProbe_records", + "type": "DEPENDENT", + "key": "rlp_11_com_teragrep_rlp_11_RelpProbe_records", + "delay": "0", + "value_type": "FLOAT", + "description": "Generated from Dropwizard metric import (metric=com.teragrep.rlp_11.RelpProbe.records, type=com.codahale.metrics.Counter)", + "preprocessing": [ + { + "type": "PROMETHEUS_PATTERN", + "parameters": [ + "com_teragrep_rlp_11_RelpProbe_records", + "value", + "" + ] + } + ], + "master_item": { + "key": "prometheus_agent_rlp_11" + } + }, + { + "uuid": "94b6c4e0f7b14ad8b33a8cfdc4c67921", + "name": "rlp_11_com_teragrep_rlp_11_RelpProbe_connectLatency[quantile=\"0.5\"]", + "type": "DEPENDENT", + "key": "rlp_11_com_teragrep_rlp_11_RelpProbe_connectLatency[quantile=\"0.5\"]", + "delay": "0", + "value_type": "FLOAT", + "description": "Generated from Dropwizard metric import (metric=com.teragrep.rlp_11.RelpProbe.connectLatency, type=com.codahale.metrics.Timer)", + "preprocessing": [ + { + "type": "PROMETHEUS_PATTERN", + "parameters": [ + "com_teragrep_rlp_11_RelpProbe_connectLatency{quantile=\"0.5\",}", + "value", + "" + ] + } + ], + "master_item": { + "key": "prometheus_agent_rlp_11" + } + }, + { + "uuid": "0a3f8d489abb415884a63f6e98c69df1", + "name": "rlp_11_com_teragrep_rlp_11_RelpProbe_connectLatency[quantile=\"0.75\"]", + "type": "DEPENDENT", + "key": "rlp_11_com_teragrep_rlp_11_RelpProbe_connectLatency[quantile=\"0.75\"]", + "delay": "0", + "value_type": "FLOAT", + "description": "Generated from Dropwizard metric import (metric=com.teragrep.rlp_11.RelpProbe.connectLatency, type=com.codahale.metrics.Timer)", + "preprocessing": [ + { + "type": "PROMETHEUS_PATTERN", + "parameters": [ + "com_teragrep_rlp_11_RelpProbe_connectLatency{quantile=\"0.75\",}", + "value", + "" + ] + } + ], + "master_item": { + "key": "prometheus_agent_rlp_11" + } + }, + { + "uuid": "8d329110c7ef4c98880e06507f2b39bf", + "name": "rlp_11_com_teragrep_rlp_11_RelpProbe_connectLatency[quantile=\"0.95\"]", + "type": "DEPENDENT", + "key": "rlp_11_com_teragrep_rlp_11_RelpProbe_connectLatency[quantile=\"0.95\"]", + "delay": "0", + "value_type": "FLOAT", + "description": "Generated from Dropwizard metric import (metric=com.teragrep.rlp_11.RelpProbe.connectLatency, type=com.codahale.metrics.Timer)", + "preprocessing": [ + { + "type": "PROMETHEUS_PATTERN", + "parameters": [ + "com_teragrep_rlp_11_RelpProbe_connectLatency{quantile=\"0.95\",}", + "value", + "" + ] + } + ], + "master_item": { + "key": "prometheus_agent_rlp_11" + } + }, + { + "uuid": "9ffb8428e7ea4c1fbe44ab3a6ce64149", + "name": "rlp_11_com_teragrep_rlp_11_RelpProbe_connectLatency[quantile=\"0.98\"]", + "type": "DEPENDENT", + "key": "rlp_11_com_teragrep_rlp_11_RelpProbe_connectLatency[quantile=\"0.98\"]", + "delay": "0", + "value_type": "FLOAT", + "description": "Generated from Dropwizard metric import (metric=com.teragrep.rlp_11.RelpProbe.connectLatency, type=com.codahale.metrics.Timer)", + "preprocessing": [ + { + "type": "PROMETHEUS_PATTERN", + "parameters": [ + "com_teragrep_rlp_11_RelpProbe_connectLatency{quantile=\"0.98\",}", + "value", + "" + ] + } + ], + "master_item": { + "key": "prometheus_agent_rlp_11" + } + }, + { + "uuid": "feb7325f9b4548e6aa8bce2fb6bbada6", + "name": "rlp_11_com_teragrep_rlp_11_RelpProbe_connectLatency[quantile=\"0.99\"]", + "type": "DEPENDENT", + "key": "rlp_11_com_teragrep_rlp_11_RelpProbe_connectLatency[quantile=\"0.99\"]", + "delay": "0", + "value_type": "FLOAT", + "description": "Generated from Dropwizard metric import (metric=com.teragrep.rlp_11.RelpProbe.connectLatency, type=com.codahale.metrics.Timer)", + "preprocessing": [ + { + "type": "PROMETHEUS_PATTERN", + "parameters": [ + "com_teragrep_rlp_11_RelpProbe_connectLatency{quantile=\"0.99\",}", + "value", + "" + ] + } + ], + "master_item": { + "key": "prometheus_agent_rlp_11" + } + }, + { + "uuid": "5456ddfb80a148ad8db8623af33b6cb6", + "name": "rlp_11_com_teragrep_rlp_11_RelpProbe_connectLatency[quantile=\"0.999\"]", + "type": "DEPENDENT", + "key": "rlp_11_com_teragrep_rlp_11_RelpProbe_connectLatency[quantile=\"0.999\"]", + "delay": "0", + "value_type": "FLOAT", + "description": "Generated from Dropwizard metric import (metric=com.teragrep.rlp_11.RelpProbe.connectLatency, type=com.codahale.metrics.Timer)", + "preprocessing": [ + { + "type": "PROMETHEUS_PATTERN", + "parameters": [ + "com_teragrep_rlp_11_RelpProbe_connectLatency{quantile=\"0.999\",}", + "value", + "" + ] + } + ], + "master_item": { + "key": "prometheus_agent_rlp_11" + } + }, + { + "uuid": "7c4d2a357fa24e9497bc11ed9f93112d", + "name": "rlp_11_com_teragrep_rlp_11_RelpProbe_connectLatency_count", + "type": "DEPENDENT", + "key": "rlp_11_com_teragrep_rlp_11_RelpProbe_connectLatency_count", + "delay": "0", + "value_type": "FLOAT", + "description": "Description missing", + "preprocessing": [ + { + "type": "PROMETHEUS_PATTERN", + "parameters": [ + "com_teragrep_rlp_11_RelpProbe_connectLatency_count", + "value", + "" + ] + } + ], + "master_item": { + "key": "prometheus_agent_rlp_11" + } + }, + { + "uuid": "a5d73bc000bc4cb9abb9822ca3a8138b", + "name": "rlp_11_com_teragrep_rlp_11_RelpProbe_sendLatency[quantile=\"0.5\"]", + "type": "DEPENDENT", + "key": "rlp_11_com_teragrep_rlp_11_RelpProbe_sendLatency[quantile=\"0.5\"]", + "delay": "0", + "value_type": "FLOAT", + "description": "Generated from Dropwizard metric import (metric=com.teragrep.rlp_11.RelpProbe.sendLatency, type=com.codahale.metrics.Timer)", + "preprocessing": [ + { + "type": "PROMETHEUS_PATTERN", + "parameters": [ + "com_teragrep_rlp_11_RelpProbe_sendLatency{quantile=\"0.5\",}", + "value", + "" + ] + } + ], + "master_item": { + "key": "prometheus_agent_rlp_11" + } + }, + { + "uuid": "50adab1d17194f8bad5ccbad16e227f8", + "name": "rlp_11_com_teragrep_rlp_11_RelpProbe_sendLatency[quantile=\"0.75\"]", + "type": "DEPENDENT", + "key": "rlp_11_com_teragrep_rlp_11_RelpProbe_sendLatency[quantile=\"0.75\"]", + "delay": "0", + "value_type": "FLOAT", + "description": "Generated from Dropwizard metric import (metric=com.teragrep.rlp_11.RelpProbe.sendLatency, type=com.codahale.metrics.Timer)", + "preprocessing": [ + { + "type": "PROMETHEUS_PATTERN", + "parameters": [ + "com_teragrep_rlp_11_RelpProbe_sendLatency{quantile=\"0.75\",}", + "value", + "" + ] + } + ], + "master_item": { + "key": "prometheus_agent_rlp_11" + } + }, + { + "uuid": "7d58da3d675443259be97faccec5c620", + "name": "rlp_11_com_teragrep_rlp_11_RelpProbe_sendLatency[quantile=\"0.95\"]", + "type": "DEPENDENT", + "key": "rlp_11_com_teragrep_rlp_11_RelpProbe_sendLatency[quantile=\"0.95\"]", + "delay": "0", + "value_type": "FLOAT", + "description": "Generated from Dropwizard metric import (metric=com.teragrep.rlp_11.RelpProbe.sendLatency, type=com.codahale.metrics.Timer)", + "preprocessing": [ + { + "type": "PROMETHEUS_PATTERN", + "parameters": [ + "com_teragrep_rlp_11_RelpProbe_sendLatency{quantile=\"0.95\",}", + "value", + "" + ] + } + ], + "master_item": { + "key": "prometheus_agent_rlp_11" + } + }, + { + "uuid": "515c65fae796413eb4c7d6158b02c32d", + "name": "rlp_11_com_teragrep_rlp_11_RelpProbe_sendLatency[quantile=\"0.98\"]", + "type": "DEPENDENT", + "key": "rlp_11_com_teragrep_rlp_11_RelpProbe_sendLatency[quantile=\"0.98\"]", + "delay": "0", + "value_type": "FLOAT", + "description": "Generated from Dropwizard metric import (metric=com.teragrep.rlp_11.RelpProbe.sendLatency, type=com.codahale.metrics.Timer)", + "preprocessing": [ + { + "type": "PROMETHEUS_PATTERN", + "parameters": [ + "com_teragrep_rlp_11_RelpProbe_sendLatency{quantile=\"0.98\",}", + "value", + "" + ] + } + ], + "master_item": { + "key": "prometheus_agent_rlp_11" + } + }, + { + "uuid": "c26b0e60daca4427b31d77ca71033a06", + "name": "rlp_11_com_teragrep_rlp_11_RelpProbe_sendLatency[quantile=\"0.99\"]", + "type": "DEPENDENT", + "key": "rlp_11_com_teragrep_rlp_11_RelpProbe_sendLatency[quantile=\"0.99\"]", + "delay": "0", + "value_type": "FLOAT", + "description": "Generated from Dropwizard metric import (metric=com.teragrep.rlp_11.RelpProbe.sendLatency, type=com.codahale.metrics.Timer)", + "preprocessing": [ + { + "type": "PROMETHEUS_PATTERN", + "parameters": [ + "com_teragrep_rlp_11_RelpProbe_sendLatency{quantile=\"0.99\",}", + "value", + "" + ] + } + ], + "master_item": { + "key": "prometheus_agent_rlp_11" + } + }, + { + "uuid": "f1c21a941de74011b3b01fc30e86087b", + "name": "rlp_11_com_teragrep_rlp_11_RelpProbe_sendLatency[quantile=\"0.999\"]", + "type": "DEPENDENT", + "key": "rlp_11_com_teragrep_rlp_11_RelpProbe_sendLatency[quantile=\"0.999\"]", + "delay": "0", + "value_type": "FLOAT", + "description": "Generated from Dropwizard metric import (metric=com.teragrep.rlp_11.RelpProbe.sendLatency, type=com.codahale.metrics.Timer)", + "preprocessing": [ + { + "type": "PROMETHEUS_PATTERN", + "parameters": [ + "com_teragrep_rlp_11_RelpProbe_sendLatency{quantile=\"0.999\",}", + "value", + "" + ] + } + ], + "master_item": { + "key": "prometheus_agent_rlp_11" + } + }, + { + "uuid": "e9eba88e0fd440e0904f44dace42559c", + "name": "rlp_11_com_teragrep_rlp_11_RelpProbe_sendLatency_count", + "type": "DEPENDENT", + "key": "rlp_11_com_teragrep_rlp_11_RelpProbe_sendLatency_count", + "delay": "0", + "value_type": "FLOAT", + "description": "Description missing", + "preprocessing": [ + { + "type": "PROMETHEUS_PATTERN", + "parameters": [ + "com_teragrep_rlp_11_RelpProbe_sendLatency_count", + "value", + "" + ] + } + ], + "master_item": { + "key": "prometheus_agent_rlp_11" + } + }, + { + "uuid": "faec2fab3b964b7f9519810b4ddd200e", + "name": "rlp_11_com_teragrep_rlp_11_RelpProbe_resends", + "type": "DEPENDENT", + "key": "rlp_11_com_teragrep_rlp_11_RelpProbe_resends", + "delay": "0", + "value_type": "FLOAT", + "description": "Generated from Dropwizard metric import (metric=com.teragrep.rlp_11.RelpProbe.resends, type=com.codahale.metrics.Counter)", + "preprocessing": [ + { + "type": "PROMETHEUS_PATTERN", + "parameters": [ + "com_teragrep_rlp_11_RelpProbe_resends", + "value", + "" + ] + } + ], + "master_item": { + "key": "prometheus_agent_rlp_11" + } + }, + { + "uuid": "4b10d1b2a2b348babf11a2687f708e8a", + "name": "rlp_11_com_teragrep_rlp_11_RelpProbe_disconnects", + "type": "DEPENDENT", + "key": "rlp_11_com_teragrep_rlp_11_RelpProbe_disconnects", + "delay": "0", + "value_type": "FLOAT", + "description": "Generated from Dropwizard metric import (metric=com.teragrep.rlp_11.RelpProbe.disconnects, type=com.codahale.metrics.Counter)", + "preprocessing": [ + { + "type": "PROMETHEUS_PATTERN", + "parameters": [ + "com_teragrep_rlp_11_RelpProbe_disconnects", + "value", + "" + ] + } + ], + "master_item": { + "key": "prometheus_agent_rlp_11" + } + }, + { + "uuid": "9ba558043acb430d94511162f8fdd636", + "name": "rlp_11_com_teragrep_rlp_11_RelpProbe_retriedConnects", + "type": "DEPENDENT", + "key": "rlp_11_com_teragrep_rlp_11_RelpProbe_retriedConnects", + "delay": "0", + "value_type": "FLOAT", + "description": "Generated from Dropwizard metric import (metric=com.teragrep.rlp_11.RelpProbe.retriedConnects, type=com.codahale.metrics.Counter)", + "preprocessing": [ + { + "type": "PROMETHEUS_PATTERN", + "parameters": [ + "com_teragrep_rlp_11_RelpProbe_retriedConnects", + "value", + "" + ] + } + ], + "master_item": { + "key": "prometheus_agent_rlp_11" + } + } + ], + "discovery_rules": [] + } + ] + } +} diff --git a/src/main/java/com/teragrep/rlp_11/Configuration/MetricsConfiguration.java b/src/main/java/com/teragrep/rlp_11/Configuration/MetricsConfiguration.java index f847379..b6627e9 100644 --- a/src/main/java/com/teragrep/rlp_11/Configuration/MetricsConfiguration.java +++ b/src/main/java/com/teragrep/rlp_11/Configuration/MetricsConfiguration.java @@ -59,15 +59,6 @@ public MetricsConfiguration(final Map config) { this.config = config; } - public String name() { - final String name = config.get("metrics.name"); - if (name == null) { - LOGGER.error("Configuration failure: is null"); - throw new ConfigurationException("Invalid value for received"); - } - return name; - } - public int window() { final String windowString = config.get("metrics.window"); if (windowString == null) { @@ -84,7 +75,7 @@ public int window() { } if (window <= 0) { LOGGER.error("Configuration failure: <[{}]> too small, expected to be >0", window); - throw new ConfigurationException("Invalid value for received"); + throw new ConfigurationException("Invalid value for received"); } return window; } diff --git a/src/main/java/com/teragrep/rlp_11/RelpProbe.java b/src/main/java/com/teragrep/rlp_11/RelpProbe.java index 68eb1a5..0226627 100644 --- a/src/main/java/com/teragrep/rlp_11/RelpProbe.java +++ b/src/main/java/com/teragrep/rlp_11/RelpProbe.java @@ -95,13 +95,12 @@ public RelpProbe( targetConfiguration, probeConfiguration, recordFactory, - metricRegistry.counter(name(RelpProbe.class, "<[" + metricsConfiguration.name() + "]>", "records")), - metricRegistry.counter(name(RelpProbe.class, "<[" + metricsConfiguration.name() + "]>", "resends")), - metricRegistry.counter(name(RelpProbe.class, "<[" + metricsConfiguration.name() + "]>", "connects")), - metricRegistry.counter(name(RelpProbe.class, "<[" + metricsConfiguration.name() + "]>", "disconnects")), - metricRegistry - .counter(name(RelpProbe.class, "<[" + metricsConfiguration.name() + "]>", "retriedConnects")), - metricRegistry.timer(name(RelpProbe.class, "<[" + metricsConfiguration.name() + "]>", "sendLatency"), () -> new Timer(new SlidingWindowReservoir(metricsConfiguration.window()))), metricRegistry.timer(name(RelpProbe.class, "<[" + metricsConfiguration.name() + "]>", "connectLatency"), () -> new Timer(new SlidingWindowReservoir(metricsConfiguration.window()))) + metricRegistry.counter(name(RelpProbe.class, "records")), + metricRegistry.counter(name(RelpProbe.class, "resends")), + metricRegistry.counter(name(RelpProbe.class, "connects")), + metricRegistry.counter(name(RelpProbe.class, "disconnects")), + metricRegistry.counter(name(RelpProbe.class, "retriedConnects")), + metricRegistry.timer(name(RelpProbe.class, "sendLatency"), () -> new Timer(new SlidingWindowReservoir(metricsConfiguration.window()))), metricRegistry.timer(name(RelpProbe.class, "connectLatency"), () -> new Timer(new SlidingWindowReservoir(metricsConfiguration.window()))) ); } diff --git a/src/test/java/com/teragrep/rlp_11/Configuration/MetricsConfigurationTest.java b/src/test/java/com/teragrep/rlp_11/Configuration/MetricsConfigurationTest.java index 09d0f7c..64b0eae 100644 --- a/src/test/java/com/teragrep/rlp_11/Configuration/MetricsConfigurationTest.java +++ b/src/test/java/com/teragrep/rlp_11/Configuration/MetricsConfigurationTest.java @@ -53,22 +53,6 @@ public class MetricsConfigurationTest { - // metrics.name - @Test - public void testNonNullName() { - Map map = baseConfig(); - MetricsConfiguration metricsConfiguration = new MetricsConfiguration(map); - Assertions.assertEquals("target-name", metricsConfiguration.name()); - } - - @Test - public void testNullName() { - Map map = baseConfig(); - map.remove("metrics.name"); - MetricsConfiguration metricsConfiguration = new MetricsConfiguration(map); - Assertions.assertThrowsExactly(ConfigurationException.class, metricsConfiguration::name); - } - // metrics.window @Test public void testGoodWindow() { @@ -135,7 +119,6 @@ public void testNonNumericInterval() { private Map baseConfig() { Map map = new HashMap<>(); - map.put("metrics.name", "target-name"); map.put("metrics.window", "1337"); map.put("metrics.interval", "60"); return map; diff --git a/src/test/resources/connect.properties b/src/test/resources/connect.properties index 52a88ba..99cb3ed 100644 --- a/src/test/resources/connect.properties +++ b/src/test/resources/connect.properties @@ -1,5 +1,3 @@ -# Metrics reporting name. Arbitrary string, only used for reporting purposes -metrics.name=target # Metrics window size metrics.window=10000 # Metrics report interval, in seconds