diff --git a/userspace/falco/falco_metrics.cpp b/userspace/falco/falco_metrics.cpp index 198153f2..9f9acc57 100644 --- a/userspace/falco/falco_metrics.cpp +++ b/userspace/falco/falco_metrics.cpp @@ -27,6 +27,15 @@ limitations under the License. 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 */ diff --git a/userspace/falco/falco_metrics.h b/userspace/falco/falco_metrics.h index d12aed12..67fa61d5 100644 --- a/userspace/falco/falco_metrics.h +++ b/userspace/falco/falco_metrics.h @@ -27,6 +27,8 @@ namespace falco::app { class falco_metrics { public: + static const std::string content_type; + falco_metrics(falco::app::state& state); bool is_enabled() const { return m_metrics_enabled; }; std::string to_text() const; diff --git a/userspace/falco/webserver.cpp b/userspace/falco/webserver.cpp index c5f47d07..1df67920 100644 --- a/userspace/falco/webserver.cpp +++ b/userspace/falco/webserver.cpp @@ -69,7 +69,7 @@ void falco_webserver::start( { m_server->Get("/metrics", [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