If I rename the new file to the existing file, then it would lose the old 
data in the existing file right?
so what we can do! 
On Tuesday, December 12, 2023 at 6:52:46 PM UTC+5:30 Brian Candler wrote:

> Perhaps you didn't write the file atomically. If you start appending to 
> the file, and Prometheus notices you've changed it, it may read it before 
> you've finished writing.
>
> You should:
> 1. Write out a new file, e.g. target.json.new
> 2. fsync it (os.File.Sync)
> 3. rename target.json.new to target.json
>
> On Tuesday 12 December 2023 at 13:11:53 UTC akshay sharma wrote:
>
>> Hi, 
>>
>> I have an application running, which is accepting the post request to add 
>> targets in the path /etc/prometheus/config/target.json. 
>>
>> Currently, I'm posting 2-3 targets using curl to the application which in 
>> turn adds to the Prometheus path, post is happening in a time difference of 
>> 2-3 minutes. 
>>
>> In Prometheus UI, I could see it is adding only one target or can see 
>> only one target in service discovery, but I have added 3 targets. 
>>
>> could see some errors in Prometheus:
>>
>> ts=2023-12-12T10:27:15.936Z caller=file.go:343 level=error 
>> component="discovery manager scrape" discovery=file config=ne-federation 
>> msg="Error reading file" path=/etc/prometheus/config/targets.json 
>> err="unexpected end of JSON input"
>> ts=2023-12-12T10:35:50.707Z caller=file.go:343 level=error 
>> component="discovery manager scrape" discovery=file config=ne-federation 
>> msg="Error reading file" path=/etc/prometheus/config/argets.json 
>> err="unexpected end of JSON input"
>>
>> I checked the JSON file using JSON validator, it's perfectly valid. 
>>
>> can you please help with what could be the issue?
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to prometheus-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/09663ad0-5ce8-49a2-9304-b7bfc21ad0aen%40googlegroups.com.

Reply via email to