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

Malformed JSON in query API result, 2.52-rc.0 regression #14040

Closed
baryluk opened this issue May 3, 2024 · 5 comments
Closed

Malformed JSON in query API result, 2.52-rc.0 regression #14040

baryluk opened this issue May 3, 2024 · 5 comments

Comments

@baryluk
Copy link

baryluk commented May 3, 2024

What did you do?

$ curl 'http://localhost:19092/api/v1/query?query=process_cpu_seconds_total&time=1714716585.782'; echo

{"status":"success","data":{"resultType":"vector","result":[{"metric":{"__name__":"process_cpu_seconds_total","instance":"localhost:19092","job":"prometheus"},"value":[1714716585.782,"0.29"]}{"metric":{"__name__":"process_cpu_seconds_total","job":"a","instance":"baz:20702"},"value":[1714716585.782,"2125535.148752446"]}]}}

Notice a missing comma between array elements.

What did you expect to see?

$ curl 'http://localhost:19091/api/v1/query?query=process_cpu_seconds_total&time=1714716585.782'; echo

{"status":"success","data":{"resultType":"vector","result":[{"metric":{"__name__":"process_cpu_seconds_total","job":"a","instance":"baz:20702"},"value":[1714716585.782,"23600372.135197595"]},{"metric":{"__name__":"process_cpu_seconds_total","instance":"localhost:19092","job":"prometheus"},"value":[1714716585.782,"1.2"]}]}}

What did you see instead? Under which circumstances?

See above.

It looks like there are missing comas.

Works fine in 2.51.2

System information

Linux amd64

Prometheus version

prometheus, version 2.52.0-rc.0 (branch: HEAD, revision: f170a014f31cc97d2aba47cc769e846c68f8545d)
  build user:       root@969a4b73703c
  build date:       20240430-12:21:35
  go version:       go1.22.2
  platform:         linux/amd64
  tags:             netgo,builtinassets,stringlabels

Prometheus configuration file

scrape_configs:
  - job_name: "prometheus"
    static_configs:
      - targets: ["localhost:19091"]

  - job_name: "a"
    static_configs:
      - targets:
        - "baz:20702"
@amirvejahat
Copy link
Contributor

I just had a quick look at the source code. it seems that comma is missing in the marshal functions, I'd like to work on the fix.

@ArthurSens
Copy link
Member

ArthurSens commented May 3, 2024

I just had a quick look at the source code. it seems that comma is missing in the marshal functions, I'd like to work on the fix.

Please do if you already know the fix, happy to review :)

cc @bboreham, I think it's related to #13997. It is the only PR that was not included in the benchmark

@amirvejahat
Copy link
Contributor

I think it's ready to be reviewed. this is my first time contributing to an open source project, it's a big step for me. please let me know if there's something wrong with the pull request or the code.

#14047

@bboreham
Copy link
Member

bboreham commented May 3, 2024

Agreed, thanks for spotting the problem.

@baryluk
Copy link
Author

baryluk commented May 12, 2024

Fixed by #14047

@baryluk baryluk closed this as completed May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants