It's a bug?


(Panda) #1

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

(Andrew Kroh) #2

I don't see any obvious problems with the code snippet you have shared. How are you monitoring /tmp/testbeats/testbeats? Perhaps the file was rotated while you were monitoring it.

Try adding some logging to your code to see if it is still running and publishing events. Then run you beat with debug enabled (add -d "*" to you CLI flags when starting).


(Panda) #3

Hi, I did not make any changes to the code that was created, and I was constantly checking the size of the testbeats file on the command line,use 'ls -al' command. But the result was not what I wanted, and the file size would not change after 10 minutes of operation. After a while, period=1s loss of original meaning. I do not know why?


(system) #4

This topic was automatically closed after 21 days. New replies are no longer allowed.