Error "unable to create logs instance: invalid yaml positions file" when Grafana Agent is restarted

Hi Team,

We are observing the below error (looks like positions file is getting corrupted) when Grafana Agent is restarted, maybe after windows machine shuts down abruptly or restarts.

level=error msg=“error creating the agent server entrypoint” err=“unable to apply config for xxx-logs: unable to create logs instance: invalid yaml positions file [grafana-agent-data
\positions-xxx.yaml]: yaml: control characters are not allowed”

We have to delete the positions file and then rerun the agent.

Could you kindly advise how this issue can be remediated?

Control characters are usually invisible characters from Windows non-textonly text editors. There are ways you can print them with cat on linux, and the recommendation usually is to not use a text editor that is prone to inject those characters when editing a configuration file.