Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

haproxy receiver gives error "record on line 21: wrong number of fields" in socket mode #32291

Closed
ubcharron opened this issue Apr 10, 2024 · 1 comment · Fixed by #32366
Closed
Assignees
Labels
bug Something isn't working receiver/haproxy

Comments

@ubcharron
Copy link

ubcharron commented Apr 10, 2024

Component(s)

receiver/haproxy

What happened?

Description

When using the haproxy receiver to collect metrics from an haproxy via unix socket, the otel collector spits the following error message:

2024-04-10T01:19:24.122Z        error   scraperhelper/scrapercontroller.go:197  Error scraping metrics  {"kind": "receiver", "name": "haproxy", "data_type": "metrics", "error": "record on line 21: wrong number of fields", "scraper": "haproxy"}

I believe it is because the command sent is show stats, whereas according to the haproxy doc it should be "show stat" (singular).

When I manually use "show stats", haproxy gives an error message:

$ echo 'show stats' | socat /run/haproxy/admin.sock stdio
Unknown command. Please enter one of the following commands only :
  help           : this message
  prompt         : toggle interactive mode with prompt
  quit           : disconnect
...

but "show stat" works:

$ echo 'show stat' | socat /run/haproxy/admin.sock stdio
# pxname,svname,qcur,qmax,scur,smax,slim,stot,bin,bout,dreq,dresp,ereq,econ,eresp,wretr,wredis,status,weight,act,bck,chkfail,chkdown,lastchg,downtime,qlimit,pid,iid,sid,throttle,lbtot,tracked,type,rate,rate_lim,rate_max,check_status,check_code,check_duration,hrsp_1xx,hrsp_2xx,hrsp_3xx,hrsp_4xx,hrsp_5xx,hrsp_other,hanafail,req_rate,req_rate_max,req_tot,cli_abrt,srv_abrt,comp_in,comp_out,comp_byp,comp_rsp,lastsess,last_chk,last_agt,qtime,ctime,rtime,ttime,agent_status,agent_code,agent_duration,check_desc,agent_desc,check_rise,check_fall,check_health,agent_rise,agent_fall,agent_health,addr,cookie,mode,algo,conn_rate,conn_rate_max,conn_tot,intercepted,dcon,dses,wrew,connect,reuse,cache_lookups,cache_hits,srv_icur,src_ilim,qtime_max,ctime_max,rtime_max,ttime_max,

Steps to Reproduce

Setup a basic haproxy

global
  stats socket /run/haproxy/admin.sock mode 660

Configure a basic otel collector with haproxy receiver:

receivers:
  haproxy:
    endpoint: /run/haproxy/admin.sock
    collection_interval: 10s

exporters:
  debug:
    verbosity: detailed

service:
  pipelines:
    metrics:
      receivers: [haproxy]
      exporters: [debug]

Expected Result

Successfully collect stats from haproxy.

Actual Result

I get the following error from otel collector with both haproxy 1.8.8 and 2.0.33:

2024-04-10T01:22:15.149Z        error   scraperhelper/scrapercontroller.go:197  Error scraping metrics  {"kind": "receiver", "name": "haproxy", "data_type": "metrics", "error": "record on line 21: wrong number of fields", "scraper": "haproxy"}

Collector version

0.97.0

Environment information

Environment

Ubuntu 20.04.6 LTS
haproxy 2.0.33-0ubuntu0.1

OpenTelemetry Collector configuration

receivers:
  haproxy:
    endpoint: /run/haproxy/admin.sock
    collection_interval: 10s

exporters:
  debug:
    verbosity: detailed

service:
  pipelines:
    metrics:
      receivers: [haproxy]
      exporters: [debug]

Log output

2024-04-10T01:22:15.149Z        error   scraperhelper/scrapercontroller.go:197  Error scraping metrics  {"kind": "receiver", "name": "haproxy", "data_type": "metrics", "error": "record on line 21: wrong number of fields", "scraper": "haproxy"}
go.opentelemetry.io/collector/receiver/scraperhelper.(*controller).scrapeMetricsAndReport
        go.opentelemetry.io/collector/receiver@v0.97.0/scraperhelper/scrapercontroller.go:197
go.opentelemetry.io/collector/receiver/scraperhelper.(*controller).startScraping.func1
        go.opentelemetry.io/collector/receiver@v0.97.0/scraperhelper/scrapercontroller.go:169
2024-04-10T01:22:15.150Z        info    MetricsExporter {"kind": "exporter", "data_type": "metrics", "name": "debug", "resource metrics": 0, "metrics": 0, "data points": 0}
2024-04-10T01:22:15.150Z        info            {"kind": "exporter", "data_type": "metrics", "name": "debug"}

Additional context

No response

@ubcharron ubcharron added bug Something isn't working needs triage New item requiring triage labels Apr 10, 2024
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@atoulme atoulme removed the needs triage New item requiring triage label Apr 12, 2024
@atoulme atoulme self-assigned this Apr 12, 2024
dmitryax pushed a commit that referenced this issue Apr 20, 2024
**Description:**
Fix an issue where we called `show stats` instead of `show stat`.
This also fixes the situation where no records are present by properly
trimming the data.

**Link to tracking Issue:**
Fixes #32291

**Testing:**
Added a unit test.
rimitchell pushed a commit to rimitchell/opentelemetry-collector-contrib that referenced this issue May 8, 2024
**Description:**
Fix an issue where we called `show stats` instead of `show stat`.
This also fixes the situation where no records are present by properly
trimming the data.

**Link to tracking Issue:**
Fixes open-telemetry#32291

**Testing:**
Added a unit test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working receiver/haproxy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants