summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Sun <tony.sun427@gmail.com>2021-03-01 16:38:52 -0800
committerTony Sun <tony.sun427@gmail.com>2021-03-01 16:38:52 -0800
commit5865411c353a9b571c2c103624b2714773677799 (patch)
treeee9ecd12212642089d830f548de03f6138d35142
parent5f43148bafaccad350d2fe5670d71c6d7cde32b6 (diff)
downloadcouchdb-add-couchdb-prometheus.tar.gz
initial commit to add prometheus endpointadd-couchdb-prometheus
-rw-r--r--rebar.config.script1
-rw-r--r--rel/reltool.config2
-rw-r--r--src/chttpd/src/chttpd_node.erl6
-rw-r--r--src/couch/src/couch.app.src3
m---------src/couch_prometheus0
5 files changed, 11 insertions, 1 deletions
diff --git a/rebar.config.script b/rebar.config.script
index 4abdcc9a3..c4cd7a24e 100644
--- a/rebar.config.script
+++ b/rebar.config.script
@@ -146,6 +146,7 @@ SubDirs = [
"src/setup",
"src/smoosh",
"src/ebtree",
+ "src/couch_prometheus",
"rel"
].
diff --git a/rel/reltool.config b/rel/reltool.config
index 16096cefb..9c59aa53b 100644
--- a/rel/reltool.config
+++ b/rel/reltool.config
@@ -72,6 +72,7 @@
smoosh,
snappy,
thrift_protocol,
+ couch_prometheus,
%% extra
recon
]},
@@ -143,6 +144,7 @@
{app, smoosh, [{incl_cond, include}]},
{app, snappy, [{incl_cond, include}]},
{app, thrift_protocol, [{incl_cond, include}]},
+ {app, couch_prometheus, [{incl_cond, include}]},
%% extra
{app, recon, [{incl_cond, include}]}
diff --git a/src/chttpd/src/chttpd_node.erl b/src/chttpd/src/chttpd_node.erl
index 0159672f5..e2f17ce22 100644
--- a/src/chttpd/src/chttpd_node.erl
+++ b/src/chttpd/src/chttpd_node.erl
@@ -117,6 +117,12 @@ handle_node_req(#httpd{method='GET', path_parts=[_, Node, <<"_stats">> | Path]}=
chttpd:send_json(Req, EJSON1);
handle_node_req(#httpd{path_parts=[_, _Node, <<"_stats">>]}=Req) ->
send_method_not_allowed(Req, "GET");
+handle_node_req(#httpd{method='GET', path_parts=[_, Node, <<"_metrics">>]}=Req) ->
+ Metrics = call_node(Node, couch_prometheus_server, scrape, []),
+ Header = [{<<"Content-Type">>, <<"text/plain">>}],
+ chttpd:send_response(Req, 200, Header, Metrics);
+handle_node_req(#httpd{path_parts=[_, _Node, <<"_metrics">>]}=Req) ->
+ send_method_not_allowed(Req, "GET");
% GET /_node/$node/_system
handle_node_req(#httpd{method='GET', path_parts=[_, Node, <<"_system">>]}=Req) ->
Stats = call_node(Node, chttpd_node, get_stats, []),
diff --git a/src/couch/src/couch.app.src b/src/couch/src/couch.app.src
index 6116c79ba..74674bbb5 100644
--- a/src/couch/src/couch.app.src
+++ b/src/couch/src/couch.app.src
@@ -45,7 +45,8 @@
couch_event,
ioq,
couch_stats,
- hyper
+ hyper,
+ couch_prometheus
]},
{env, [
{ httpd_global_handlers, [
diff --git a/src/couch_prometheus b/src/couch_prometheus
new file mode 160000
+Subproject 70717a722df02e4a5f5175fea43d52c014cf52a