influxdata / influxdata/telegraf

Telegraf logs Errors to Eventlog if started as Service on Windows

Open
#16,064 2 comments 0 reactions 1 assignee Claimed by @skartikey View on GitHub
bug
Dominant language
Go
Stars
17.8k
Forks
5.8k
Avg merge
1d 20h
Merged PRs (30d)
161

Description

### Relevant telegraf.conf

```toml
logtarget = "file"
logfile = "/Program Files/Telegraf/telegraf.log"
logfile_rotation_interval = "24h"
logfile_rotation_max_size = "5MB"
logfile_rotation_max_archives = 5
...
statefile = "/Program Files/Telegraf/statefile.json"

and a statefile.json containing only zero bytes
```

### Logs from Telegraf

```text
If started from terminal, telegraf.log contains

2024-10-22T14:41:31Z E! [telegraf] Error running agent: unmarshalling states failed: invalid character '\x00' looking for beginning of value

If started through services.msc, doesn't contain the error message, as it goes to the Eventlog.
```

### System info

Telegraf 1.32.1

### Expected behavior

Not logging anything to the Eventlog, as we didn't specify `"eventlog"` anywhere

### Actual behavior

Logs to Eventlog if started as a service

### Additional info

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.