Search in sources :

Example 1 with InfluxConfig

use of io.micrometer.influx.InfluxConfig in project spring-boot by spring-projects.

the class InfluxPropertiesTests method defaultValuesAreConsistent.

@Test
void defaultValuesAreConsistent() {
    InfluxProperties properties = new InfluxProperties();
    InfluxConfig config = InfluxConfig.DEFAULT;
    assertStepRegistryDefaultValues(properties, config);
    assertThat(properties.getDb()).isEqualTo(config.db());
    assertThat(properties.getConsistency()).isEqualTo(config.consistency());
    assertThat(properties.getUserName()).isEqualTo(config.userName());
    assertThat(properties.getPassword()).isEqualTo(config.password());
    assertThat(properties.getRetentionPolicy()).isEqualTo(config.retentionPolicy());
    assertThat(properties.getRetentionDuration()).isEqualTo(config.retentionDuration());
    assertThat(properties.getRetentionReplicationFactor()).isEqualTo(config.retentionReplicationFactor());
    assertThat(properties.getRetentionShardDuration()).isEqualTo(config.retentionShardDuration());
    assertThat(properties.getUri()).isEqualTo(config.uri());
    assertThat(properties.isCompressed()).isEqualTo(config.compressed());
    assertThat(properties.isAutoCreateDb()).isEqualTo(config.autoCreateDb());
    assertThat(properties.getOrg()).isEqualTo(config.org());
    assertThat(properties.getToken()).isEqualTo(config.token());
}
Also used : InfluxConfig(io.micrometer.influx.InfluxConfig) Test(org.junit.jupiter.api.Test)

Example 2 with InfluxConfig

use of io.micrometer.influx.InfluxConfig in project vertx-micrometer-metrics by vert-x3.

the class CustomMicrometerMetricsITest method shouldReportWithCompositeRegistry.

@Test
public void shouldReportWithCompositeRegistry(TestContext context) throws Exception {
    // Mock an influxdb server
    Async asyncInflux = context.async();
    InfluxDbTestHelper.simulateInfluxServer(vertxForSimulatedServer, context, 8087, body -> {
        try {
            context.verify(w -> assertThat(body).contains("vertx_eventbus_handlers,address=test-eb,metric_type=gauge value=1"));
        } finally {
            asyncInflux.complete();
        }
    });
    CompositeMeterRegistry myRegistry = new CompositeMeterRegistry();
    myRegistry.add(new JmxMeterRegistry(s -> null, Clock.SYSTEM));
    myRegistry.add(new InfluxMeterRegistry(new InfluxConfig() {

        @Override
        public String get(String s) {
            return null;
        }

        @Override
        public Duration step() {
            return Duration.ofSeconds(1);
        }

        @Override
        public String uri() {
            return "http://localhost:8087";
        }

        @Override
        public boolean autoCreateDb() {
            return false;
        }
    }, Clock.SYSTEM));
    vertx = Vertx.vertx(new VertxOptions().setMetricsOptions(new MicrometerMetricsOptions().setMicrometerRegistry(myRegistry).setRegistryName(REGITRY_NAME).addDisabledMetricsCategory(MetricsDomain.HTTP_SERVER).addDisabledMetricsCategory(MetricsDomain.NAMED_POOLS).addLabels(Label.EB_ADDRESS).setEnabled(true)));
    // Send something on the eventbus and wait til it's received
    Async asyncEB = context.async();
    vertx.eventBus().consumer("test-eb", msg -> asyncEB.complete());
    vertx.eventBus().publish("test-eb", "test message");
    asyncEB.await(2000);
    // Read MBean
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    assertThat(mbs.getDomains()).contains("metrics");
    Number result = (Number) mbs.getAttribute(new ObjectName("metrics", "name", "vertxEventbusHandlers.address.test-eb"), "Value");
    assertThat(result).isEqualTo(1d);
    // Await influx
    asyncInflux.awaitSuccess();
}
Also used : CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) TestContext(io.vertx.ext.unit.TestContext) Async(io.vertx.ext.unit.Async) CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RunWith(org.junit.runner.RunWith) MicrometerMetricsOptions(io.vertx.micrometer.MicrometerMetricsOptions) After(org.junit.After) MBeanServer(javax.management.MBeanServer) Duration(java.time.Duration) ManagementFactory(java.lang.management.ManagementFactory) Clock(io.micrometer.core.instrument.Clock) InfluxConfig(io.micrometer.influx.InfluxConfig) Vertx(io.vertx.core.Vertx) VertxOptions(io.vertx.core.VertxOptions) JmxMeterRegistry(io.micrometer.jmx.JmxMeterRegistry) Test(org.junit.Test) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) MetricsDomain(io.vertx.micrometer.MetricsDomain) VertxPrometheusOptions(io.vertx.micrometer.VertxPrometheusOptions) ObjectName(javax.management.ObjectName) InfluxMeterRegistry(io.micrometer.influx.InfluxMeterRegistry) PrometheusMeterRegistry(io.micrometer.prometheus.PrometheusMeterRegistry) HttpServerOptions(io.vertx.core.http.HttpServerOptions) Label(io.vertx.micrometer.Label) PrometheusConfig(io.micrometer.prometheus.PrometheusConfig) Async(io.vertx.ext.unit.Async) JmxMeterRegistry(io.micrometer.jmx.JmxMeterRegistry) InfluxConfig(io.micrometer.influx.InfluxConfig) InfluxMeterRegistry(io.micrometer.influx.InfluxMeterRegistry) VertxOptions(io.vertx.core.VertxOptions) MicrometerMetricsOptions(io.vertx.micrometer.MicrometerMetricsOptions) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 3 with InfluxConfig

use of io.micrometer.influx.InfluxConfig in project pravega by pravega.

the class RegistryConfigUtilTest method testPrometheusConfig.

@Test
public void testPrometheusConfig() {
    MetricsConfig appConfig = MetricsConfig.builder().with(MetricsConfig.OUTPUT_FREQUENCY, 40).with(MetricsConfig.METRICS_PREFIX, "prometheusPrefix").build();
    InfluxConfig testConfig = RegistryConfigUtil.createInfluxConfig(appConfig);
    assertTrue(40 == testConfig.step().getSeconds());
    assertEquals("prometheusPrefix", testConfig.prefix());
    assertNull(testConfig.get("Undefined Key"));
}
Also used : InfluxConfig(io.micrometer.influx.InfluxConfig) Test(org.junit.Test)

Example 4 with InfluxConfig

use of io.micrometer.influx.InfluxConfig in project pravega by pravega.

the class RegistryConfigUtilTest method testInfluxConfig.

@Test
public void testInfluxConfig() {
    MetricsConfig appConfig = MetricsConfig.builder().with(MetricsConfig.OUTPUT_FREQUENCY, 39).with(MetricsConfig.METRICS_PREFIX, "influxPrefix").with(MetricsConfig.INFLUXDB_URI, "http://localhost:2375").with(MetricsConfig.INFLUXDB_NAME, "databaseName").with(MetricsConfig.INFLUXDB_USERNAME, "admin").with(MetricsConfig.INFLUXDB_PASSWORD, "changeme").with(MetricsConfig.INFLUXDB_RETENTION_POLICY, "2h").build();
    InfluxConfig testConfig = RegistryConfigUtil.createInfluxConfig(appConfig);
    assertTrue(39 == testConfig.step().getSeconds());
    assertEquals("influxPrefix", testConfig.prefix());
    assertEquals("http://localhost:2375", testConfig.uri());
    assertEquals("databaseName", testConfig.db());
    assertEquals("admin", testConfig.userName());
    assertEquals("changeme", testConfig.password());
    assertEquals("2h", testConfig.retentionPolicy());
    assertNull(testConfig.get("Undefined Key"));
}
Also used : InfluxConfig(io.micrometer.influx.InfluxConfig) Test(org.junit.Test)

Aggregations

InfluxConfig (io.micrometer.influx.InfluxConfig)4 Test (org.junit.Test)3 Clock (io.micrometer.core.instrument.Clock)1 CompositeMeterRegistry (io.micrometer.core.instrument.composite.CompositeMeterRegistry)1 InfluxMeterRegistry (io.micrometer.influx.InfluxMeterRegistry)1 JmxMeterRegistry (io.micrometer.jmx.JmxMeterRegistry)1 PrometheusConfig (io.micrometer.prometheus.PrometheusConfig)1 PrometheusMeterRegistry (io.micrometer.prometheus.PrometheusMeterRegistry)1 Vertx (io.vertx.core.Vertx)1 VertxOptions (io.vertx.core.VertxOptions)1 HttpServerOptions (io.vertx.core.http.HttpServerOptions)1 Async (io.vertx.ext.unit.Async)1 TestContext (io.vertx.ext.unit.TestContext)1 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)1 Label (io.vertx.micrometer.Label)1 MetricsDomain (io.vertx.micrometer.MetricsDomain)1 MicrometerMetricsOptions (io.vertx.micrometer.MicrometerMetricsOptions)1 VertxPrometheusOptions (io.vertx.micrometer.VertxPrometheusOptions)1 ManagementFactory (java.lang.management.ManagementFactory)1 Duration (java.time.Duration)1