Build your own beat

Hello everybody,
I am following the tutorial on how to build your own beat from https://www.elastic.co/blog/build-your-own-beat and I can't see where to put my go code. The whole process described in the tutorial is pretty clear except for that.
Thank you so much!

You put your Go code into the Run() function defined in the generated beater/{your-beat-name}.go file. That function can call out to other functions you define if needed.

oh thank you!

I am having problems now making my code work inside the Run function. Basically I created a code which is a HTTP server to upload files which I am saving on the hard disk. Then I am supposed to send these files on Logstash. I can't figure out how to do that step. Can anyone help me? I'd be more than glad to share my beat once it is working.

Thank you!

When you have data that you want to publish, you create an event which is a common.MapStr and call PublishEvent(). That will send the event to the configured outputs (e.g. Logstash).

            event := common.MapStr{
                "@timestamp": common.Time(time.Now()),
                "type":       beatname,
                "mydata":    mydata,
            }
            bt.client.PublishEvent(event)

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