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

Telegraf won't start on empty (zero-length) statefile #14935

Closed
burkart opened this issue Mar 4, 2024 · 2 comments · Fixed by #14937
Closed

Telegraf won't start on empty (zero-length) statefile #14935

burkart opened this issue Mar 4, 2024 · 2 comments · Fixed by #14937
Labels
bug unexpected problem or unintended behavior

Comments

@burkart
Copy link

burkart commented Mar 4, 2024

Relevant telegraf.conf

[agent]
  statefile = "/var/lib/telegraf/statefile"

# Dedup uses the statefile
[[processors.dedup]]
  dedup_interval = "60s"

Logs from Telegraf

E! [telegraf] Error running agent: unmarshalling states failed: unexpected end of JSON input

System info

Telegraf 1.29.2, Debian 12.4, Docker 24.0.7

Docker

No response

Steps to reproduce

  1. Enable statefile in telegraf.conf
  2. Make sure statefile is empty (0 bytes)
  3. Start Telegraf

Expected behavior

Telegraf starts and fills statefile on exit.

Actual behavior

Telegraf fails to start.

Additional info

Telegraf comes with a zero-length statefile /var/lib/telegraf/statefile that's generated by scripts/{deb,rpm}/post-install.sh.

Telegraf starts successfully if the file contents are "{}" (without the quotes).

@burkart burkart added the bug unexpected problem or unintended behavior label Mar 4, 2024
powersj added a commit to powersj/telegraf that referenced this issue Mar 5, 2024
@shengbinxu
Copy link

Yes, I also encountered this issue. The version I am using is 1.29.1, and the issue can be resolved by writing the following content in the file.

{}

@srebhan
Copy link
Member

srebhan commented Apr 18, 2024

@shengbinxu this should be fixed in v1.30.0+...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants