Score:0

How can I get nginx to add a newline to a response from an upstream server?

hk flag

I have a service that exposes a Prometheus statistics endpoint. I'm using Telegraf's input.prometheus to relay these stats. Unfortunately this particular service doesn't terminate the request with a newline character as is required by the text exposition format spec, and as a result, the Telegraf Prometheus input chokes (unexpected end of stream).

As a quick fix I'd like to use nginx to proxy this stats endpoint and append a newline char to the response. I don't need to inspect the response and only add the newline if it doesn't already end with one, as I already know that it won't have one.

My deployment environment is a bit sensitive to added dependencies, so I'd really like a solution that can work with the default community build of nginx without need for any additional modules. However if that's not possible, I'd also be very grateful for a solution that would run on a typical OpenResty install. Solutions that make use of very recent features are fine as well.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.