fix: add content-type for metrics response (#4340)

chore: add content-type for metrics response.

Also, update the local stack to use prometheus 3.0
Finally, hex-escape arguments when logging an error for a command.

Fixes #4277

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
Roman Gershman 2024-12-18 21:12:00 +02:00 committed by GitHub
parent 3f68028c08
commit 904d21d666
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 3 additions and 2 deletions

View file

@ -715,7 +715,7 @@ string FailedCommandToString(std::string_view command, facade::CmdArgList args,
absl::StrAppend(&result, " ", command);
for (auto arg : args) {
absl::StrAppend(&result, " ", facade::ToSV(arg));
absl::StrAppend(&result, " ", absl::CHexEscape(arg));
}
absl::StrAppend(&result, " failed with reason: ", reason);

View file

@ -1541,6 +1541,7 @@ void ServerFamily::ConfigureMetrics(util::HttpListenerBase* http_base) {
auto cb = [this](const util::http::QueryArgs& args, util::HttpContext* send) {
StringResponse resp = util::http::MakeStringResponse(boost::beast::http::status::ok);
util::http::SetMime(util::http::kTextMime, &resp);
uint64_t uptime = time(NULL) - start_time_;
PrintPrometheusMetrics(uptime, this->GetMetrics(&namespaces->GetDefaultNamespace()),
this->dfly_cmd_.get(), &resp);

View file

@ -14,7 +14,7 @@ services:
command: chown -R 11211:11211 /memcached
prometheus:
image: prom/prometheus:v2.45.5
image: prom/prometheus:v3.0.0
restart: always
volumes:
- ./prometheus:/etc/prometheus/