telegraf icon indicating copy to clipboard operation
telegraf copied to clipboard

Standard URI for haproxy Stats

Open pasancario opened this issue 10 years ago • 15 comments

Hi,

I want to use haproxy input plugin, but it seems it doesn't work with standard configuration from Haproxy.

They define default URI as: http://cbonte.github.io/haproxy-dconv/configuration-1.5.html#4.2-stats%20enable

This statement enables statistics reporting with default settings defined at build time. Unless stated otherwise, these settings are used :

  • stats uri : /haproxy?stats
  • stats realm : "HAProxy Statistics"

And when plugin tries to parse it, fails:

Error in input [haproxy]: Unable to get valid stat result from 'http://127.0.0.1:80/haproxy?stats': %!s(<nil>)

It seems query values are not being parsed, and default URI from haproxy is not supported.

Configuration:

 [[inputs.haproxy]]
      servers = ["http://127.0.0.1:80/haproxy?stats"]

Output:

Error in input [haproxy]: Unable to get valid stat result from 'http://127.0.0.1:80/haproxy?stats': %!s()

pasancario avatar Apr 13 '16 13:04 pasancario

I've created a fork in my local repository, and ammend it.

It was just a new rule to check it:

https://github.com/pasancario/telegraf/commit/717fe0aa209c325447c6f50c60c4efd6bebbf38f

pasancario avatar Apr 13 '16 14:04 pasancario

@pasancario what if you just specify:

 [[inputs.haproxy]]
      servers = ["http://127.0.0.1:80"]

?

sparrc avatar Apr 20 '16 22:04 sparrc

Hi,

I am trying to use Haproxy as a input plugin and trying to send Output to InfluxDB. Please let me know the fix for the below.

InfluxDB Version - 0.8

Input Plugin

# # Read metrics of haproxy, via socket or csv stats page 
[[inputs.haproxy]]
#   ## An array of address to gather stats about. Specify an ip on hostname
#   ## with optional port. ie localhost, 10.10.3.33:1936, etc.
# #   ## If no servers are specified, then default to 127.0.0.1:1936
servers = ["http://ccrc-hapxy-stg-01:1936"]
#   ## Or you can also use local socket
#   servers = ["socket:/var/lib/haproxy/stats"]

Below is the error stack trace i am getting.
 telegraf-0.13.1-1]$ 2016/06/20 02:55:00 Database creation failed: json: cannot unmarshal number into Go value of type client.Response
2016/06/20 02:55:00 Starting Telegraf (version 0.13.1)
2016/06/20 02:55:00 Loaded outputs: influxdb
2016/06/20 02:55:00 Loaded inputs: diskio mem system haproxy cpu disk kernel processes swap
2016/06/20 02:55:00 Tags enabled: host=ccrc-metrics-stg-01.cisco.com
2016/06/20 02:55:00 Agent Config: Interval:10s, Debug:false, Quiet:false, Hostname:"ccrc-metrics-stg-01.cisco.com", Flush Interval:10s 
2016/06/20 02:55:10 ERROR in input [kernel]: strconv.ParseInt: parsing "5424508880": value out of range
2016/06/20 02:55:10 ERROR in input [haproxy]: Unable to get valid stat result from 'http://ccrc-hapxy-stg-01:1936': %!s(<nil>)
2016/06/20 02:55:20 ERROR in input [kernel]: strconv.ParseInt: parsing "5424514567": value out of range
2016/06/20 02:55:20 ERROR in input [haproxy]: Unable to get valid stat result from 'http://ccrc-hapxy-stg-01:1936': %!s(<nil>)
2016/06/20 02:55:20 Output [influxdb] buffer fullness: 61 / 10000 metrics. Total gathered metrics: 61. Total dropped metrics: 0.
2016/06/20 02:55:20 Database creation failed: json: cannot unmarshal number into Go value of type client.Response
2016/06/20 02:55:20 Error writing to output [influxdb]: Could not write to any InfluxDB server in cluster
2016/06/20 02:55:30 ERROR in input [kernel]: strconv.ParseInt: parsing "5424519176": value out of range
2016/06/20 02:55:30 ERROR in input [haproxy]: Unable to get valid stat result from 'http://ccrc-hapxy-stg-01:1936': %!s(<nil>)
2016/06/20 02:55:30 Output [influxdb] buffer fullness: 94 / 10000 metrics. Total gathered metrics: 94. Total dropped metrics: 0.
2016/06/20 02:55:30 Database creation failed: json: cannot unmarshal number into Go value of type client.Response
2016/06/20 02:55:30 Error writing to output [influxdb]: Could not write to any InfluxDB server in cluster

Thanks, Sigbert

SigbertUCE avatar Jun 20 '16 07:06 SigbertUCE

@sparrc - Can you please let me know the fix for the above issue?

SigbertUCE avatar Jun 20 '16 17:06 SigbertUCE

@SigbertUCE what is the url that your haproxy stats are available at?

sparrc avatar Jun 21 '16 09:06 sparrc

@sparrc - http://ccrc-hapxy-stg-01:1936/?stats

There are 2 issues here.

  1. Database creation is failing first
  2. Unable to get valid stat result from 'http://ccrc-hapxy-stg-01:1936/?stats': %!s()

[ccrccloudop@ccrc-metrics-stg-01 telegraf-0.13.1-1]$ 2016/06/21 15:30:31 Database creation failed: json: cannot unmarshal number into Go value of type client.Response 2016/06/21 15:30:31 Starting Telegraf (version 0.13.1) 2016/06/21 15:30:31 Loaded outputs: influxdb 2016/06/21 15:30:31 Loaded inputs: haproxy cpu disk diskio kernel swap mem processes system 2016/06/21 15:30:31 Tags enabled: host=ccrc-metrics-stg-01.cisco.com 2016/06/21 15:30:31 Agent Config: Interval:10s, Debug:false, Quiet:false, Hostname:"ccrc-metrics-stg-01.cisco.com", Flush Interval:10s 2016/06/21 15:30:40 ERROR in input [kernel]: strconv.ParseInt: parsing "5467407777": value out of range 2016/06/21 15:30:40 ERROR in input [haproxy]: Unable to get valid stat result from 'http://ccrc-hapxy-stg-01:1936/?stats': %!s() 2016/06/21 15:30:50 ERROR in input [kernel]: strconv.ParseInt: parsing "5467413123": value out of range 2016/06/21 15:30:50 ERROR in input [haproxy]: Unable to get valid stat result from 'http://ccrc-hapxy-stg-01:1936/?stats': %!s()

Thanks, Sigbert

SigbertUCE avatar Jun 21 '16 19:06 SigbertUCE

if you're using influxdb 0.8 you'll need to backversion telegraf, probably back to 0.10 at least.

sparrc avatar Jun 21 '16 21:06 sparrc

@sparrc - Tried downloading the below url but gives me 404. https://gowalker.org/github.com/tompao/telegraf

SigbertUCE avatar Jun 22 '16 00:06 SigbertUCE

@sparrc - was trying to use the below(http://get.influxdb.org/telegraf/telegraf-0.10.0_linux_386.tar.gz)

SigbertUCE avatar Jun 22 '16 03:06 SigbertUCE

try http://get.influxdb.org/telegraf/telegraf-0.10.2-1_linux_i386.tar.gz

sparrc avatar Jun 22 '16 06:06 sparrc

@sparrc - Tried downgrading it to 0.10.2 version but no luck.Please let me know the fix for the same.

2016/06/22 03:23:02 Database creation failed: json: cannot unmarshal number into Go value of type client.Response 2016/06/22 03:23:02 Starting Telegraf (version 0.10.2) 2016/06/22 03:23:02 Loaded outputs: influxdb 2016/06/22 03:23:02 Loaded inputs: haproxy 2016/06/22 03:23:02 Tags enabled: host=ccrc-metrics-stg-01.cisco.com 2016/06/22 03:23:02 Agent Config: Interval:10s, Debug:false, Quiet:false, Hostname:"ccrc-metrics-stg-01.cisco.com", Flush Interval:10s 2016/06/22 03:23:10 Error in input [haproxy]: Unable to get valid stat result from 'http://ccrc-hapxy-stg-01:1936/?stats': %!s() 2016/06/22 03:23:10 Gathered metrics, (10s interval), from 1 inputs in 6.864881ms 2016/06/22 03:23:20 Error in input [haproxy]: Unable to get valid stat result from 'http://ccrc-hapxy-stg-01:1936/?stats': %!s() 2016/06/22 03:23:20 Gathered metrics, (10s interval), from 1 inputs in 8.524488ms 2016/06/22 03:23:20 ERROR: 404 page not found

2016/06/22 03:23:20 Error writing to output [influxdb]: Could not write to any InfluxDB server in cluster 2016/06/22 03:23:30 Error in input [haproxy]: Unable to get valid stat result from 'http://ccrc-hapxy-stg-01:1936/?stats': %!s() 2016/06/22 03:23:30 Gathered metrics, (10s interval), from 1 inputs in 15.101773ms 2016/06/22 03:23:30 ERROR: 404 page not found

2016/06/22 03:23:30 Error writing to output [influxdb]: Could not write to any InfluxDB server in cluster 2016/06/22 03:23:40 Error in input [haproxy]: Unable to get valid stat result from 'http://ccrc-hapxy-stg-01:1936/?stats': %!s() 2016/06/22 03:23:40 Gathered metrics, (10s interval), from 1 inputs in 6.362713ms 2016/06/22 03:23:40 ERROR: 404 page not found

2016/06/22 03:23:40 Error writing to output [influxdb]: Could not write to any InfluxDB server in cluster 2016/06/22 03:23:50 Error in input [haproxy]: Unable to get valid stat result from 'http://ccrc-hapxy-stg-01:1936/?stats': %!s() 2016/06/22 03:23:50 Gathered metrics, (10s interval), from 1 inputs in 2.918683ms 2016/06/22 03:23:50 ERROR: 404 page not found

2016/06/22 03:23:50 Error writing to output [influxdb]: Could not write to any InfluxDB server in cluster

SigbertUCE avatar Jun 22 '16 07:06 SigbertUCE

@sparrc - Any pointers on these issues will help me move forward.

SigbertUCE avatar Jun 23 '16 15:06 SigbertUCE

@SigbertUCE I'm sorry but I have no idea how to fix that, it's not a problem I've seen and I don't have any way of reproducing. I was hoping someone in the community could help out.

sparrc avatar Jun 23 '16 15:06 sparrc

I was dealing with the same issue. Think I've got it resolved by adding the uri for the stats to the server config in telegraf.conf.

Section in HA Proxy: listen stats
bind *:1936 log global maxconn 10 mode http stats enable stats uri /stats timeout client 5000 timeout connect 5000 timeout server 5000

Section in telegraf.conf: [[inputs.haproxy]] servers = ["http://192.168.15.254:1936/stats;csv" ]

mverleun avatar Jul 17 '16 11:07 mverleun

@mverleun - tried the same but to no avail.. FYI - i am using influxdb v0.8 & Telegraf v0.13.1

2016/07/18 02:41:20 Error writing to output [influxdb]: Could not write to any InfluxDB server in cluster 2016/07/18 02:41:30 Error in input [haproxy]: Unable to get valid stat result from 'http://****-hapxy-stg-01:1936/stats;csv': %!s() 2016/07/18 02:41:30 Gathered metrics, (10s interval), from 1 inputs in 9.803881ms 2016/07/18 02:41:30 ERROR: 404 page not found

SigbertUCE avatar Jul 18 '16 06:07 SigbertUCE