Search in sources :

Example 1 with PrometheusManager

use of com.datastax.oss.dsbulk.workflow.commons.metrics.prometheus.PrometheusManager in project dsbulk by datastax.

the class MetricsManagerTest method should_exchange_metrics_with_prometheus.

@Test
void should_exchange_metrics_with_prometheus() throws Exception {
    Path executionDirectory = Files.createTempDirectory("test");
    PrometheusManager prometheus = mock(PrometheusManager.class);
    MetricsManager manager = new MetricsManager(new MetricRegistry(), true, "test", Executors.newSingleThreadScheduledExecutor(), SECONDS, MILLISECONDS, -1, -1, true, false, false, false, prometheus, executionDirectory, LogSettings.Verbosity.verbose, Duration.ofSeconds(5), true, protocolVersion, codecRegistry, RowType.REGULAR);
    manager.init();
    manager.start();
    manager.stop(Duration.ofSeconds(123), true);
    manager.close();
    manager.reportFinalMetrics();
    verify(prometheus).init();
    verify(prometheus).start();
    verify(prometheus).close();
    verify(prometheus).pushMetrics(Duration.ofSeconds(123), true);
}
Also used : Path(java.nio.file.Path) MetricRegistry(com.codahale.metrics.MetricRegistry) PrometheusManager(com.datastax.oss.dsbulk.workflow.commons.metrics.prometheus.PrometheusManager) Test(org.junit.jupiter.api.Test)

Example 2 with PrometheusManager

use of com.datastax.oss.dsbulk.workflow.commons.metrics.prometheus.PrometheusManager in project dsbulk by datastax.

the class MonitoringSettings method configurePrometheus.

private PrometheusManager configurePrometheus(Config config) {
    boolean pullEnabled = config.getBoolean("pull.enabled");
    boolean pushEnabled = config.getBoolean("push.enabled");
    if (!pullEnabled && !pushEnabled) {
        return null;
    }
    PullConfig pullConfig = null;
    if (pullEnabled) {
        pullConfig = new PullConfig(config.getString("pull.hostname"), config.getInt("pull.port"));
    }
    PushConfig pushConfig = null;
    if (pushEnabled) {
        pushConfig = new PushConfig(ConfigUtils.getURL(config, "push.url"), config.getString("push.username"), config.getString("push.password"), config.getBoolean("push.groupBy.instance"), config.getBoolean("push.groupBy.operation"), ConfigUtils.getStringMap(config, "push.groupBy.keys"));
    }
    return new PrometheusManager(registry, executionId, config.getString("job"), ConfigUtils.getStringMap(config, "labels"), pullConfig, pushConfig);
}
Also used : PushConfig(com.datastax.oss.dsbulk.workflow.commons.metrics.prometheus.PrometheusManager.PushConfig) PullConfig(com.datastax.oss.dsbulk.workflow.commons.metrics.prometheus.PrometheusManager.PullConfig) PrometheusManager(com.datastax.oss.dsbulk.workflow.commons.metrics.prometheus.PrometheusManager)

Aggregations

PrometheusManager (com.datastax.oss.dsbulk.workflow.commons.metrics.prometheus.PrometheusManager)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 PullConfig (com.datastax.oss.dsbulk.workflow.commons.metrics.prometheus.PrometheusManager.PullConfig)1 PushConfig (com.datastax.oss.dsbulk.workflow.commons.metrics.prometheus.PrometheusManager.PushConfig)1 Path (java.nio.file.Path)1 Test (org.junit.jupiter.api.Test)1