Sparkd promethius metrics
This commit is contained in:
1 parent
57bfe5a85e
commit
1558b79c16
7 files changed
+201
-7
No files matched your search
@@ -49,15 +49,17 @@ namespace http {
|
||||
std::string _www;
|
||||
std::string _conf;
|
||||
const api::ServiceContext& _ctx;
|
||||
const metrics::MetricsContainer& _metrics;
|
||||
|
||||
ServerState(const api::ServiceContext& ctx, int port) :
|
||||
ServerState(const api::ServiceContext& ctx, const metrics::MetricsContainer& metrics, int port) :
|
||||
_m(),
|
||||
_dispatcher(utils::Dispatcher::get_named("Webserver")),
|
||||
_session(),
|
||||
_server(),
|
||||
_port(port),
|
||||
_www(),
|
||||
_ctx(ctx)
|
||||
_ctx(ctx),
|
||||
_metrics(metrics)
|
||||
{
|
||||
_www = os::sparkdata_path("www");
|
||||
_conf = os::sparkdata_path("conf");
|
||||
@@ -139,6 +141,13 @@ namespace http {
|
||||
con->set_status(websocketpp::http::status_code::ok);
|
||||
}
|
||||
|
||||
void return_metrics(connection_ptr& con) {
|
||||
std::stringstream ss;
|
||||
_metrics.print(ss);
|
||||
con->set_body(ss.str());
|
||||
con->set_status(websocketpp::http::status_code::ok);
|
||||
}
|
||||
|
||||
void directory_index(connection_ptr& con, const std::string& resource, const boost::filesystem::path& path) {
|
||||
// directory listing
|
||||
std::string body = "<!doctype html>\n";
|
||||
@@ -221,10 +230,13 @@ namespace http {
|
||||
void on_http(connection_hdl hdl) {
|
||||
auto con = _server.get_con_from_hdl(hdl);
|
||||
auto resource = strip_query_str(con->get_resource());
|
||||
LOG(Api,Info, "REQUEST: {}", resource);
|
||||
LOG(Api,Info, "HTTP GET: {}", resource);
|
||||
if (boost::iequals(resource, "/config/.all")) {
|
||||
return_dotall(con);
|
||||
}
|
||||
else if (boost::iequals(resource, "/metrics")) {
|
||||
return_metrics(con);
|
||||
}
|
||||
else if (boost::iequals(resource, "/bts_installer.exe") && boost::filesystem::is_regular_file(_www+"/bts_installer.exe")) {
|
||||
return_bts_installer(con);
|
||||
}
|
||||
@@ -258,8 +270,8 @@ namespace http {
|
||||
|
||||
|
||||
|
||||
SparkWebServer::SparkWebServer(const api::ServiceContext& ctx, int port) :
|
||||
_me(std::make_shared<ServerState>(ctx, port))
|
||||
SparkWebServer::SparkWebServer(const api::ServiceContext& ctx, metrics::MetricsContainer& metrics, int port) :
|
||||
_me(std::make_shared<ServerState>(ctx, metrics, port))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user