diff --git a/CMakeLists.txt b/CMakeLists.txt index d3636c2dc5..cf530c24e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -189,10 +189,15 @@ else() endif() if (installBMQPLUGINS) - set(BMQ_TARGET_MWC_NEEDED YES) - set(BMQ_TARGET_BMQ_NEEDED YES) - set(BMQ_TARGET_MQB_NEEDED YES) - set(BMQ_TARGET_PLUGINS_NEEDED YES) + set(BMQ_TARGET_BMQBRKR_NEEDED YES) + set(BMQ_TARGET_BMQBRKRCFG_NEEDED YES) + set(BMQ_TARGET_BMQTOOL_NEEDED YES) + set(BMQ_TARGET_MWC_NEEDED YES) + set(BMQ_TARGET_BMQ_NEEDED YES) + set(BMQ_TARGET_MQB_NEEDED YES) + set(BMQ_TARGET_E_BMQBRKR_NEEDED YES) + set(BMQ_TARGET_TUTORIAL_NEEDED YES) + set(BMQ_TARGET_PLUGINS_NEEDED YES) endif() endif() diff --git a/docker/plugins/prometheus/prometheus.yml b/docker/plugins/prometheus/prometheus.yml index b195cd6072..b5f63be8db 100644 --- a/docker/plugins/prometheus/prometheus.yml +++ b/docker/plugins/prometheus/prometheus.yml @@ -1,6 +1,6 @@ global: - scrape_interval: 5s - evaluation_interval: 5s + scrape_interval: 10s + evaluation_interval: 10s scrape_configs: - job_name: 'prometheus' @@ -8,14 +8,14 @@ scrape_configs: - targets: ['localhost:9090'] - job_name: 'gateway' - scrape_interval: 1s + scrape_interval: 10s static_configs: - targets: ['host.docker.internal:9091'] labels: group: 'pushgateway' - job_name: 'bmq' - scrape_interval: 1s + scrape_interval: 10s static_configs: - targets: ['host.docker.internal:8080'] labels: diff --git a/src/plugins/plugins_prometheusstatconsumer.cpp b/src/plugins/plugins_prometheusstatconsumer.cpp index f95e4d6899..45e573b4e6 100644 --- a/src/plugins/plugins_prometheusstatconsumer.cpp +++ b/src/plugins/plugins_prometheusstatconsumer.cpp @@ -113,21 +113,30 @@ class Tagger { prometheus::Labels& getLabels() { return labels; } }; -} // close unnamed namespace - bsl::unique_ptr makeExporter(const bsl::string& mode, const bsl::string& host, const bsl::size_t port, std::shared_ptr& registry); +} // close unnamed namespace + // ---------------------------- // class PrometheusStatConsumer // ---------------------------- +void PrometheusStatConsumer::stopImpl() +{ + if (!d_isStarted || !d_prometheusStatExporter_p) { + return; // RETURN + } + d_prometheusStatExporter_p->stop(); + d_isStarted = false; +} + PrometheusStatConsumer::~PrometheusStatConsumer() { - stop(); + stopImpl(); } PrometheusStatConsumer::PrometheusStatConsumer( @@ -162,17 +171,6 @@ int PrometheusStatConsumer::start( return -1; // RETURN } - if (!d_prometheusStatExporter_p) { - d_prometheusStatExporter_p = makeExporter(d_consumerConfig_p->mode(), - d_consumerConfig_p->host(), - d_consumerConfig_p->port(), - d_prometheusRegistry_p); - } - if (!d_prometheusStatExporter_p) { - return -2; // RETURN - } - d_prometheusStatExporter_p->start(); - const mqbcfg::AppConfig& brkrCfg = mqbcfg::BrokerConfig::get(); d_publishInterval = d_consumerConfig_p->publishInterval(); d_snapshotInterval = brkrCfg.stats().snapshotInterval(); @@ -185,18 +183,25 @@ int PrometheusStatConsumer::start( d_snapshotId = static_cast(d_publishInterval.seconds() / d_snapshotInterval.seconds()); - d_isStarted = true; + + if (!d_prometheusStatExporter_p) { + d_prometheusStatExporter_p = makeExporter(d_consumerConfig_p->mode(), + d_consumerConfig_p->host(), + d_consumerConfig_p->port(), + d_prometheusRegistry_p); + } + if (!d_prometheusStatExporter_p) { + return -2; // RETURN + } + d_prometheusStatExporter_p->start(); + + d_isStarted = true; return 0; } void PrometheusStatConsumer::stop() { - if (!d_isStarted) { - return; // RETURN - } - - d_prometheusStatExporter_p->stop(); - d_isStarted = false; + stopImpl(); } void PrometheusStatConsumer::onSnapshot() @@ -884,6 +889,8 @@ class PrometheusPushStatExporter : public PrometheusStatExporter { void stop() override { stopImpl(); } }; +namespace { + bsl::unique_ptr makeExporter(const bsl::string& mode, const bsl::string& host, @@ -908,6 +915,8 @@ makeExporter(const bsl::string& mode, return result; } +} // close unnamed namespace + } // close package namespace } // close enterprise namespace diff --git a/src/plugins/plugins_prometheusstatconsumer.h b/src/plugins/plugins_prometheusstatconsumer.h index a3e7987ed6..301af1fd08 100644 --- a/src/plugins/plugins_prometheusstatconsumer.h +++ b/src/plugins/plugins_prometheusstatconsumer.h @@ -217,6 +217,9 @@ class PrometheusStatConsumer : public mqbplug::StatConsumer { const prometheus::Labels& labels, const bsls::Types::Int64 value); + /// Stop plugin + void stopImpl(); + public: // NOT IMPLEMENTED