From 6a280533257e2295bd3ddf80d87fc9791e027c9b Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Sun, 5 Oct 2025 18:11:12 +0200 Subject: [PATCH] Replace \r\n with \n for prometheus --- Program.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Program.cs b/Program.cs index 7c6012f..3cf0cd6 100644 --- a/Program.cs +++ b/Program.cs @@ -38,7 +38,11 @@ while (true) { var body = new StringBuilder(); AppendMetrics(body, computer); - var bytes = Encoding.UTF8.GetBytes(body.ToString()); + var text = body.ToString(); + // Normalize all line endings to '\n' for Prometheus compatibility + text = text.Replace("\r\n", "\n").Replace("\r", "\n"); + if (!text.EndsWith("\n")) text += "\n"; + var bytes = Encoding.UTF8.GetBytes(text); context.Response.StatusCode = 200; context.Response.ContentType = "text/plain; version=0.0.4"; context.Response.ContentEncoding = Encoding.UTF8;