Http_response plugin shows all data along side latest result code in grafana dashboard

  • What Grafana version and what operating system are you using?
    10.2.2 Fedora Workstation 39

  • What are you trying to achieve?
    I am trying to show http response status of some systems using http_response telegraf input plugin.

  • How are you trying to achieve it?
    I added system URL into telegraf.conf file, and test it in Influxdb to only fetch result_code, after that I copied the flux query to grafana panel selecting influxdb as data source. Here is the flux query

from(bucket: "system_stat")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "http_response")
  |> filter(fn: (r) => r["_field"] == "result_code")
  |> filter(fn: (r) => r["host"] == "fedora")
  |> filter(fn: (r) => r["method"] == "GET")
  |> filter(fn: (r) => r["server"] == "https://liyumfi.com/")
  |> aggregateWindow(every: v.windowPeriod, fn: last, createEmpty: false)
  |> yield(name: "last")
  • What happened?
    Instead of showing one result_code at a time it is showing multiple results which are from different time.

  • What did you expect to happen?
    To show one result_code at a time.

  • Can you copy/paste the configuration(s) that you are having problems with?

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

No, there is no error being shown.

  • Did you follow any online instructions? If so, what is the URL?
    No

Your above function did not match that shown in your screenshot (where it showed fn: mean), but nevertheless, I do not think that will resolve your issue.

Can you try this? Maybe fiddle around with the fields box?
image

1 Like

Hello @grant2

Your above function did not match that shown in your screenshot (where it showed fn: mean), but nevertheless, I do not think that will resolve your issue.

Yeah, I was trying to change mean to last and vise-versa just to check if it works, unfortunately it doesn’t.

I have tried changing the reducer function options as you suggested, but in all case it shows two stats at the same time.

@grant2
I couldn’t figure out the problem I also couldn’t even override values. I have posted the problem here

@usman.ahmad

Any ideas here, please.

same problem here.

I have configured a outputs.prometheus_client.
If I scrape the prometheus endpoint during a transition of the http_response endpoint, I get two states at a time:

=> START
# HELP animals_http_response_code Telegraf collected metric
# TYPE animals_http_response_code untyped
animals_http_response_code{host="telegraf-polling-service",method="GET",result="response_status_code_mismatch",result_type="response_status_code_mismatch",server="http://localhost:3000/animals",status_code="201"} 201

=> after next polling (10s)
# HELP animals_http_response_code Telegraf collected metric
# TYPE animals_http_response_code untyped
animals_http_response_code{host="telegraf-polling-service",method="GET",result="response_status_code_mismatch",result_type="response_status_code_mismatch",server="http://localhost:3000/animals",status_code="201"} 201
animals_http_response_code{host="telegraf-polling-service",method="GET",result="success",result_type="success",server="http://localhost:3000/animals",status_code="200"} 200

=> after about 1min
# HELP animals_http_response_code Telegraf collected metric
# TYPE animals_http_response_code untyped
animals_http_response_code{host="telegraf-polling-service",method="GET",result="success",result_type="success",server="http://localhost:3000/animals",status_code="200"} 200