+ if (strcmp(sctpParams.prometheusMode.c_str(),"pull") == 0) {
+ if (mdclog_level_get() >= MDCLOG_DEBUG) {
+ mdclog_write(MDCLOG_DEBUG, "Start Prometheus Pull mode on %s:%s", sctpParams.myIP.c_str(), sctpParams.prometheusPort.c_str());
+ }
+ sctpParams.prometheusExposer = new Exposer(sctpParams.myIP + ":" + sctpParams.prometheusPort, 1);
+ sctpParams.prometheusExposer->RegisterCollectable(sctpParams.prometheusRegistry);
+ } else if (strcmp(sctpParams.prometheusMode.c_str(),"push") == 0) {
+ if (mdclog_level_get() >= MDCLOG_DEBUG) {
+ mdclog_write(MDCLOG_DEBUG, "Start Prometheus Push mode");
+ }
+ const auto labels = Gateway::GetInstanceLabel(GetHostName());
+ string address {};
+ string port {};
+ char ch = ':';
+ auto found = sctpParams.prometheusPushAddress.find_last_of(ch);
+ // If string doesn't have
+ // character ch present in it
+ if (found != string::npos) {
+ address = sctpParams.prometheusPushAddress.substr(0,found);
+ port = sctpParams.prometheusPushAddress.substr(found + 1);
+ sctpParams.prometheusGateway = new Gateway(address, port, "E2T", labels);
+ sctpParams.prometheusGateway->RegisterCollectable(sctpParams.prometheusRegistry);
+ } else {
+ mdclog_write(MDCLOG_ERR, "failed to build Prometheus gateway no stats will be sent");
+ }
+ }
+}