Replace \r\n with \n for prometheus
This commit is contained in:
@@ -38,7 +38,11 @@ while (true) {
|
|||||||
|
|
||||||
var body = new StringBuilder();
|
var body = new StringBuilder();
|
||||||
AppendMetrics(body, computer);
|
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.StatusCode = 200;
|
||||||
context.Response.ContentType = "text/plain; version=0.0.4";
|
context.Response.ContentType = "text/plain; version=0.0.4";
|
||||||
context.Response.ContentEncoding = Encoding.UTF8;
|
context.Response.ContentEncoding = Encoding.UTF8;
|
||||||
|
Reference in New Issue
Block a user