be/src/service/http/action/metrics_action.cpp
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #include "service/http/action/metrics_action.h" |
19 | | |
20 | | #include <string> |
21 | | |
22 | | #include "common/metrics/metrics.h" |
23 | | #include "service/http/http_channel.h" |
24 | | #include "service/http/http_headers.h" |
25 | | #include "service/http/http_request.h" |
26 | | |
27 | | namespace doris { |
28 | | |
29 | 3 | void MetricsAction::handle(HttpRequest* req) { |
30 | 3 | const std::string& type = req->param("type"); |
31 | 3 | const std::string& with_tablet = req->param("with_tablet"); |
32 | 3 | std::string str; |
33 | 3 | if (type == "core") { |
34 | 0 | str = _metric_registry->to_core_string(); |
35 | 3 | } else if (type == "json") { |
36 | 0 | str = _metric_registry->to_json(with_tablet == "true"); |
37 | 3 | } else { |
38 | 3 | str = _metric_registry->to_prometheus(with_tablet == "true"); |
39 | 3 | } |
40 | | |
41 | 3 | req->add_output_header(HttpHeaders::CONTENT_TYPE, "text/plain; version=0.0.4"); |
42 | 3 | HttpChannel::send_reply(req, str); |
43 | 3 | } |
44 | | |
45 | | } // namespace doris |