Skip to content

Commit

Permalink
add configuration for prometheus export
Browse files Browse the repository at this point in the history
  • Loading branch information
kinnou02 committed Mar 28, 2018
1 parent adfbe18 commit bbe92ee
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build_navitia.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ mkdir -p "$run_dir"
sed -i 's,git\@github.com:\([^/]*\)/\(.*\).git,https://github.com/\1/\2,' .gitmodules

#we need to get the submodules
git submodule update --init
git submodule update --init --recursive

#========
#Building
Expand Down
10 changes: 10 additions & 0 deletions source/kraken/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ po::options_description get_options_description(const boost::optional<std::strin
("GENERAL.log_level", po::value<std::string>(), "log level of kraken")
("GENERAL.log_format", po::value<std::string>()->default_value("[%D{%y-%m-%d %H:%M:%S,%q}] [%p] [%x] - %m %b:%L %n"), "log format")

("GENERAL.metrics_binding", po::value<std::string>(), "IP:PORT to serving metrics in http")

("BROKER.host", po::value<std::string>()->default_value("localhost"), "host of rabbitmq")
("BROKER.port", po::value<int>()->default_value(5672), "port of rabbitmq")
("BROKER.username", po::value<std::string>()->default_value("guest"), "username for rabbitmq")
Expand Down Expand Up @@ -235,4 +237,12 @@ boost::optional<std::string> Configuration::log_format() const{
}
return result;
}

boost::optional<std::string> Configuration::metrics_binding() const{
boost::optional<std::string> result;
if (this->vm.count("GENERAL.metrics_binding") > 0) {
result = this->vm["GENERAL.metrics_binding"].as<std::string>();
}
return result;
}
}}//namespace
1 change: 1 addition & 0 deletions source/kraken/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ namespace navitia { namespace kraken{
int slow_request_duration() const;
boost::optional<std::string> log_level() const;
boost::optional<std::string> log_format() const;
boost::optional<std::string> metrics_binding() const;

std::vector<std::string> rt_topics() const;
};
Expand Down
3 changes: 2 additions & 1 deletion source/kraken/kraken_zmq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ int main(int argn, char** argv){
return 1;
}

navitia::Metrics metrics(conf.metrics_binding());

threads.create_thread(navitia::MaintenanceWorker(data_manager, conf));

navitia::Metrics metrics(boost::make_optional(std::string("127.0.0.1:8080")));

int nb_threads = conf.nb_threads();
// Launch pool of worker threads
Expand Down
4 changes: 3 additions & 1 deletion source/kraken/metrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ www.navitia.io
#include "type/type.pb.h"
#include <boost/optional.hpp>

#include <boost/utility.hpp>

//forward declare
namespace prometheus{
class Registry;
Expand All @@ -45,7 +47,7 @@ namespace prometheus{
}

namespace navitia {
class Metrics{
class Metrics: boost::noncopyable {
protected:
std::unique_ptr<prometheus::Exposer> exposer;
std::shared_ptr<prometheus::Registry> registry;
Expand Down

0 comments on commit bbe92ee

Please sign in to comment.