Http_response input plugin shows multiple result_codes at a time instead of showing only one

Hello friends,
I am trying to use http_response telegraf input plugin to monitor multiple websites and systems. I am using result_code as field and based on that I am creating Grafana dashboard to show the status of the website.

The problem I am facing is, I am getting multiple result_code at a time in influxdb dashboard when I tested the plugin. But, what I am trying to achieve is just to get one result at a time, and it should be that way too I guess. Here is the screenshot:


This is the flux query I am working with

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")

From Influxdb

The http_response plugin is only capable of returning a single status code at a time, take a look at the code itself here. If you truly think this is an issue with Telegraf, then please provide the output from [[outputs.file]] showing two status codes showing up at the same time.

What is more likely occurring is that your flux query or your chart/graph is setup incorrectly and not grouping sufficiently. For example you are aggregating over your window period. Is it possible that multiple return codes occurred during that period?

If you truly think this is an issue with Telegraf, then please provide the output from [[outputs.file]] showing two status codes showing up at the same time

Where do I get that?

What is more likely occurring is that your flux query or your chart/graph is setup incorrectly and not grouping sufficiently. For example you are aggregating over your window period. Is it possible that multiple return codes occurred during that period?

I just used influxdb web to build the query, and I checked last to get the last value.

Hello @jpowers
I have checked [[outputs.file]] and there is no duplicate value shown there,

# /tmp/metrics.out

http_response,host=fedora,method=GET,result=success,server=https://liyumfi.com/,status_code=200 response_time=0.68368988,http_response_code=200i,content_length=95354i,result_type="success",result_code=0i 1702558501000000000

What confuses me is it’s working fine on InfluxDB v2.7.1 and Grafana 10.0.1 on my Fedora 37 another PC. I used the same flux query.

Are you sure you don’t have two telegrafs running?

@jpowers
I have just installed Telegraf using dnf in Fedora, if I try to install Telegraf again it won’t let me after all. Here is telegraf.service daemon file I am using

[Unit]
Description=Telegraf
Documentation=https://github.com/influxdata/telegraf
After=network-online.target
Wants=network-online.target

[Service]
Type=notify
EnvironmentFile=-/etc/default/telegraf
User=telegraf
ExecStart=/usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-director>
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartForceExitStatus=SIGPIPE
KillMode=mixed
TimeoutStopSec=5
LimitMEMLOCK=8M:8M
CapabilityBoundingSet=CAP_NET_RAW
AmbientCapabilities=CAP_NET_RAW

[Install]
WantedBy=multi-user.target

@jpowers @Anaisdg

Please help, I tried my best, removing telegraf and influxdb and reinstalling it but still I am getting multiple results at a time, and in Grafana it looks really bad since it shows two results at a time.