# Build your own beat

**URL:** <https://discuss.elastic.co/t/build-your-own-beat/61186>\
**Category:** Beats\
**Created:** [September 21, 2016, 10:12pm UTC](https://discuss.elastic.co/t/build-your-own-beat/61186 "2016-09-21T22:12:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![overip](https://avatars.discourse-cdn.com/v4/letter/o/cdc98d/32.png) [@overip](https://discuss.elastic.co/u/overip)\
**Post date:** [September 21, 2016, 10:12pm UTC](https://discuss.elastic.co/t/build-your-own-beat/61186/1 "2016-09-21T22:12:10Z")

</div>

Hello everybody,  
I am following the tutorial on how to build your own beat from [https://www.elastic.co/blog/build-your-own-beat](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!

---

<div class="post-metadata">

**Author:** ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)\
**Post date:** [September 21, 2016, 11:49pm UTC](https://discuss.elastic.co/t/build-your-own-beat/61186/2 "2016-09-21T23:49:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![overip](https://avatars.discourse-cdn.com/v4/letter/o/cdc98d/32.png) [@overip](https://discuss.elastic.co/u/overip)\
**Post date:** [September 22, 2016, 5:13pm UTC](https://discuss.elastic.co/t/build-your-own-beat/61186/3 "2016-09-22T17:13:50Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)\
**Post date:** [September 22, 2016, 6:19pm UTC](https://discuss.elastic.co/t/build-your-own-beat/61186/4 "2016-09-22T18:19:22Z")

</div>

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).

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

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 12, 2016, 10:12pm UTC](https://discuss.elastic.co/t/build-your-own-beat/61186/5 "2016-10-12T22:12:26Z")

</div>

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