From b68a44d04767f5979b5cdb19ceee20b1205fc11d Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Tue, 16 Sep 2025 12:06:23 +0200 Subject: [PATCH] Don't expect `Contet-Type` header to exactly match `application/json` InfluxDB seems to always include some other metadata in the `Content-Type` header separated by semicolons like `application/json; charset=utf-8`, and comparing the whole string with `application/json` will always fail, resulting in almost always useless warnings without any helpful information for the user what actually went wrong. --- lib/perfdata/influxdbcommonwriter.cpp | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/lib/perfdata/influxdbcommonwriter.cpp b/lib/perfdata/influxdbcommonwriter.cpp index 14c5b004f..cbfb74871 100644 --- a/lib/perfdata/influxdbcommonwriter.cpp +++ b/lib/perfdata/influxdbcommonwriter.cpp @@ -493,31 +493,8 @@ void InfluxdbCommonWriter::FlushWQ() auto& response (parser.get()); if (response.result() != http::status::no_content) { - Log(LogWarning, GetReflectionType()->GetName()) - << "Unexpected response code: " << response.result(); - - auto& contentType (response[http::field::content_type]); - if (contentType != "application/json") { - Log(LogWarning, GetReflectionType()->GetName()) - << "Unexpected Content-Type: " << contentType; - return; - } - - Dictionary::Ptr jsonResponse; - auto& body (response.body()); - - try { - jsonResponse = JsonDecode(body); - } catch (...) { - Log(LogWarning, GetReflectionType()->GetName()) - << "Unable to parse JSON response:\n" << body; - return; - } - - String error = jsonResponse->Get("error"); - Log(LogCritical, GetReflectionType()->GetName()) - << "InfluxDB error message:\n" << error; + << "Unexpected response code: " << response.result() << ", InfluxDB error message:\n" << response.body(); } }