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

unexpected end of JSON input #4297

Closed
pc10201 opened this issue Jun 21, 2018 · 9 comments

Comments

@pc10201
Copy link

commented Jun 21, 2018

Prometheu version=2.3.1

level=error ts=2018-06-21T08:20:01.914472896Z caller=file.go:321 component="discovery manager scrape" discovery=file msg="Error reading file" path=/etc/prometheus/jobs/node.json err="unexpected end of JSON input"

But /etc/prometheus/jobs/node.json file is a valid json file.I use

python -m json.tool /etc/prometheus/jobs/node.json

to check it

@brian-brazil

This comment has been minimized.

Copy link
Member

commented Jun 21, 2018

Is the file being created atomically via rename?

@pc10201

This comment has been minimized.

Copy link
Author

commented Jun 22, 2018

I know the reason.

I write a program to update /etc/prometheus/jobs/node.json file every minute

And I set refresh_interval to 15s in prometheus.yml

@simonpasquier

This comment has been minimized.

Copy link
Member

commented Jul 6, 2018

@pc10201 can you close the issue in that case?

@simonpasquier

This comment has been minimized.

Copy link
Member

commented Jul 10, 2018

@pc10201 I'm closing the issue as it looks like you got things sorted out. If this isn't the case, I recommend that you ask for help on our user mailing list.

@sorx00

This comment has been minimized.

Copy link

commented Dec 17, 2018

@pc10201 How you fixed this problem? I have discovery service for Rancher, which rewrite job file every 30 seconds. So every time Prom try to read this file, it's putting error into log.

@currycan

This comment has been minimized.

Copy link

commented Jan 14, 2019

I met the same problem,the prometheus version is 2.4.3.

@pc10201

This comment has been minimized.

Copy link
Author

commented Feb 17, 2019

@pc10201 How you fixed this problem? I have discovery service for Rancher, which rewrite job file every 30 seconds. So every time Prom try to read this file, it's putting error into log.

I do not fix it.But I change my program to create a tmp file,if the file is same as before and will not override it.

@snarlysodboxer

This comment has been minimized.

Copy link

commented May 21, 2019

Is the file being created atomically via rename?

Which is best for this situation, writing to a temporary file and then using os.Rename, or overwriting the existing file with ioutil.WriteFile or similar?

@zhangxb1987

This comment has been minimized.

Copy link

commented Jul 26, 2019

@pc10201 how you override ? which api do you use?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.