I create a new beat based on https://www.elastic.co/guide/en/beats/devguide/current/beater-interface.html. And then I modified beat.yml as follow, but when it is executed for 10 minutes, /tmp/testbeats/testbeats
will no longer add data. And after a few minutes, it had increased again. So period is not 1s. What is the reason?It's a bug? What should I do?
respect
func (bt *Countbeat) Run(b *beat.Beat) error {
logp.Info("countbeat is running! Hit CTRL-C to stop it.")
bt.client = b.Publisher.Connect()
ticker := time.NewTicker(bt.config.Period)
counter := 1
for {
select {
case <-bt.done:
return nil
case <-ticker.C:
}
event := common.MapStr{
"@timestamp": common.Time(time.Now()),
"type": b.Name,
"counter": counter,
}
bt.client.PublishEvent(event)
logp.Info("Event sent")
counter++
}
}
YML:
testbeats:
period: 1s # important
output.file:
enabled: true
# Path to the directory where to save the generated files. The option is
# mandatory.
path: "/tmp/testbeats"
# Name of the generated files. The default is `testbeats` and it generates
# files: `testbeats`, `testbeats.1`, `testbeats.2`, etc.
filename: testbeats
# Maximum size in kilobytes of each file. When this size is reached, and on
# every testbeats restart, the files are rotated. The default value is 10240
# kB.
rotate_every_kb: 10000
# Maximum number of files under path. When this number of files is reached,
# the oldest file is deleted and the rest are shifted from last to first. The
# default is 7 files.
number_of_files: 7