InfluxDB map text to value

I have Telegraf http_response inputs (single example: )
[[inputs.http_response]]
address = “http://mynewsite
response_string_match = “some text”

I have an InfluxDB instance where that is being stored

I have a Grafana instance where I’d like a dashboard containing a bunch of Singlestat panels for up/down red/green status for websites.

My problem:
The InfluxDB query generated returns no data when the site is down - I guess because http_response_code, response_string_match, response_time are only populated when result_type=‘success’

SELECT "response_string_match" FROM "http_response" WHERE ("server" = 'http://mynewsite') AND time >= now() - 5m GROUP BY time(2s) fill(0)

Fill doesn’t work in this case, seemingly by design. (This is exactly the case I’d expect it to be useful.)

I guess I need logic in my InfluxDB query to state that

  • when result_type=‘success’ return 1
  • otherwise return 0

which will work with Singlestat in Grafana. But there’s no CASE WHEN type syntax in InfluxDB as far as I can tell.

How are other people implementing up/down indicators for websites when using Telegraf’s http_response input?

1 Like

I came here to track down this exact case as well. I am checking several sites using the inputs.http_response. I posted a new conversation because the little post-it yelled at me:

This is fixed in some later version of telegraf (works on my 1.10). It no longer errors when the connection fails, but the check should look at the result_type for “success” rather than the status_code as there will not be a status code on a connection failure.