mirror of
https://github.com/falcosecurity/falco.git
synced 2025-08-12 11:32:39 +00:00
refactor(falco_metrics): put content type in documented constant
This will keep things clearer and also allow for easir update in the future. Signed-off-by: Samuel Gaist <samuel.gaist@idiap.ch>
This commit is contained in:
parent
9cc44c0eb7
commit
a0c109fcff
@ -27,6 +27,15 @@ limitations under the License.
|
|||||||
and falco libs into a string to be return by the metrics endpoint.
|
and falco libs into a string to be return by the metrics endpoint.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief content_type to be returned by the webserver's metrics endpoint.
|
||||||
|
|
||||||
|
Currently it is the default Prometheus exposition format
|
||||||
|
|
||||||
|
https://prometheus.io/docs/instrumenting/exposition_formats/#text-based-format
|
||||||
|
*/
|
||||||
|
const std::string falco_metrics::content_type = "text/plain; version=0.0.4";
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Constructor that takes a \c state object to build its internal state
|
\brief Constructor that takes a \c state object to build its internal state
|
||||||
*/
|
*/
|
||||||
|
@ -27,6 +27,8 @@ namespace falco::app {
|
|||||||
class falco_metrics
|
class falco_metrics
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static const std::string content_type;
|
||||||
|
|
||||||
falco_metrics(falco::app::state& state);
|
falco_metrics(falco::app::state& state);
|
||||||
bool is_enabled() const { return m_metrics_enabled; };
|
bool is_enabled() const { return m_metrics_enabled; };
|
||||||
std::string to_text() const;
|
std::string to_text() const;
|
||||||
|
@ -69,7 +69,7 @@ void falco_webserver::start(
|
|||||||
{
|
{
|
||||||
m_server->Get("/metrics",
|
m_server->Get("/metrics",
|
||||||
[metrics](const httplib::Request &, httplib::Response &res) {
|
[metrics](const httplib::Request &, httplib::Response &res) {
|
||||||
res.set_content(metrics.to_text(), "text/plain; version=0.0.4");
|
res.set_content(metrics.to_text(), falco_metrics::content_type);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// run server in a separate thread
|
// run server in a separate thread
|
||||||
|
Loading…
Reference in New Issue
Block a user