# Export template from custom beat based on metricbeat

**URL:** <https://discuss.elastic.co/t/export-template-from-custom-beat-based-on-metricbeat/119250>\
**Category:** Beats\
**Tags:** beats-development\
**Created:** [February 9, 2018, 2:03pm UTC](https://discuss.elastic.co/t/export-template-from-custom-beat-based-on-metricbeat/119250 "2018-02-09T14:03:21Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![dcroonen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dcroonen/32/27450_2.png) [@dcroonen](https://discuss.elastic.co/u/dcroonen)\
**Post date:** [February 13, 2018, 9:36am UTC](https://discuss.elastic.co/t/export-template-from-custom-beat-based-on-metricbeat/119250/6 "2018-02-13T09:36:16Z")

</div>

@steffens May I ask in which file you saw that I'm using the `cmd/instance` directly? I suppose it was `main.go` but when I generate a new beat based on metricbeat with the command `python ${GOPATH}/src/github.com/elastic/beats/script/generate.py --type=metricbeat` I'll get a `main.go` file more or less the same as the one I got?

Based on the 6.0 branch of metricbeat

```
package main

import (
	"os"

	"github.com/elastic/beats/libbeat/cmd/instance"
	"github.com/elastic/beats/metricbeat/beater"

	// Comment out the following line to exclude all official metricbeat modules and metricsets
	_ "github.com/elastic/beats/metricbeat/include"

	// Make sure all your modules and metricsets are linked in this file
	_ "github.com/dcroonen/examplebeat/include"
)

var Name = "examplebeat"

func main() {
	if err := instance.Run(Name, "", beater.New); err != nil {
		os.Exit(1)
	}
}

```

and based on the master branch of metricbeat:

```
package main

import (
	"os"

	"github.com/elastic/beats/libbeat/cmd/instance"
	"github.com/elastic/beats/metricbeat/beater"

	// Comment out the following line to exclude all official metricbeat modules and metricsets
	_ "github.com/elastic/beats/metricbeat/include"

	// Make sure all your modules and metricsets are linked in this file
	_ "github.com/dcroonen/masterbeat/include"
)

var Name = "masterbeat"
var IndexPrefix = "masterbeat"

func main() {
	if err := instance.Run(Name, IndexPrefix, "", beater.DefaultCreator()); err != nil {
		os.Exit(1)
	}
}

```

So at the moment I don't have clue where to look to hook in the sub commands again....

---

_[View the full topic](https://discuss.elastic.co/t/export-template-from-custom-beat-based-on-metricbeat/119250)._
