prometheus / prometheus/common

Wrong json umarshal bug for model value

Open
#398 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
295
Forks
367
Avg merge
2d 10h
Merged PRs (30d)
18

Description

https://github.com/prometheus/common/blob/49b36038aead362ce78f09337dc5872000bd048a/model/value.go#L51

I found a strange bug, the response data unmarshalled by prom client-go is wrong by chance.

I use the queryRange API provided by prometheus client go as followings

image

and i print the time series data returned by the queryRange api, it has unexpected data value. it is very large and unexpected.

image

the value logged function is below, i use json marshal directly to marshal the returned data by api, i am sure that this is the data returned by prometheus client-go api queryRange function:

image

and then i use curl curl -G --data-urlencode 'query=irate(container_cpu_usage_seconds_total{container!="POD",namespace="ns-prjchlvc-1544041-production",pod=~"^monitor-server-siliconvalley-150001.*$",container="second-monitor-server"}[3m])' --data-urlencode 'start=1658205420.000' --data-urlencode 'end=1658865360.000' --data-urlencode 'step=60' http://127.0.0.1:9090/api/v1/query_range to query the prometheus directly, it returned normal data as expected. you can see the following data timestamp and value, it is what we want. but the above image is use the client-go api, with the same param, it has unexpected value at the same timestamp.

image

So i think the json unmarshal has some bug the prometheus client go impelmented

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at model/value.go around line 51 and inspect how query-range response values are unmarshalled. Reproduce the report with the provided query, timestamps, and step, then compare the client result with the direct curl response. Done means the unmarshalled timestamp and value data match the Prometheus response.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.