# What is the role of unpack,（/libbeat/common/cfgfile.go）?

**URL:** <https://discuss.elastic.co/t/what-is-the-role-of-unpack-libbeat-common-cfgfile-go/100009>\
**Category:** Beats\
**Created:** [September 11, 2017, 7:19am UTC](https://discuss.elastic.co/t/what-is-the-role-of-unpack-libbeat-common-cfgfile-go/100009 "2017-09-11T07:19:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![caibaoying](https://avatars.discourse-cdn.com/v4/letter/c/dc4da7/32.png) [@caibaoying](https://discuss.elastic.co/u/caibaoying)\
**Post date:** [September 11, 2017, 7:19am UTC](https://discuss.elastic.co/t/what-is-the-role-of-unpack-libbeat-common-cfgfile-go/100009/1 "2017-09-11T07:19:03Z")

</div>

1. I check the source code found after the path is Unpack () function set to '/tmp', but the source seems to have no relevant settings inside;
2. I use "go build main.go" generated executable file, the implementation does not need '/tmp' path, why?

---

<div class="post-metadata">

**Author:** ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)\
**Post date:** [September 11, 2017, 11:59am UTC](https://discuss.elastic.co/t/what-is-the-role-of-unpack-libbeat-common-cfgfile-go/100009/2 "2017-09-11T11:59:21Z")

</div>

> 1. I check the source code found after the path is Unpack () function set to '/tmp', but the source seems to have no relevant settings inside;

Unpack is used for 'unpacking' a configuration object into a go struct. Somewhat similar to `json.Unmarshal`.

I have no idea what you mean by "function set to '/tmp'". The `Unpack` method works on an already read/and parsed file.

> 1. I use "go build main.go" generated executable file, the implementation does not need '/tmp' path, why?

Just use `make` or `go build`, to build the beat.

I don't really understand what your actual problem is. Do you have some logs?

---

<div class="post-metadata">

**Author:** ![caibaoying](https://avatars.discourse-cdn.com/v4/letter/c/dc4da7/32.png) [@caibaoying](https://discuss.elastic.co/u/caibaoying)\
**Post date:** [September 12, 2017, 1:41am UTC](https://discuss.elastic.co/t/what-is-the-role-of-unpack-libbeat-common-cfgfile-go/100009/3 "2017-09-12T01:41:20Z")

</div>

Thanks very much for answering my question.  
I created my own beats according to [https://www.elastic.co/guide/en/beats/devguide/current/beater-interface.html#beater-interface](https://www.elastic.co/guide/en/beats/devguide/current/beater-interface.html#beater-interface)  
but when i run it, there was a error: Exiting: error initializing publisher: Error loading template /tmp/axtx\_beat.template.json: open /tmp/axtx\_beat.template.json: no such file or directory.  
After debugging, I found before Unpack path is NULL, after Unpack the path settings are shown in the attachment  
In fact, I want to modify the path in the attachment and change them to my own path, so what should I do?

[caibaoying3@163.com](mailto:caibaoying3@163.com)

发件人： Steffen Siering  
发送时间： 2017-09-11 20:09  
收件人： caibaoying3  
主题： [Beats] What is the role of unpack,（/libbeat/common/cfgfile.go）?  
steffens Steffen Siering Elastic Team Member  
September 11  
I check the source code found after the path is Unpack () function set to '/tmp', but the source seems to have no relevant settings inside;  
Unpack is used for 'unpacking' a configuration object into a go struct. Somewhat similar to json.Unmarshal.  
I have no idea what you mean by "function set to '/tmp'". The Unpack method works on an already read/and parsed file.  
I use "go build main.go" generated executable file, the implementation does not need '/tmp' path, why?  
Just use make or go build, to build the beat.  
I don't really understand what your actual problem is. Do you have some logs?

Visit Topic or reply to this email to respond.  
To unsubscribe from these emails, click here.

![](https://us1.discourse-cdn.com/elastic/original/3X/5/1/51e2d2a1383df671b5d1d8cb706ad300ee9ba7d3.png)

---

<div class="post-metadata">

**Author:** ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)\
**Post date:** [September 12, 2017, 12:42pm UTC](https://discuss.elastic.co/t/what-is-the-role-of-unpack-libbeat-common-cfgfile-go/100009/4 "2017-09-12T12:42:30Z")

</div>

This makes me wonder in which directory your IDE is building or running the executable. If you just build and run the beat, the default `${path}` is set to the current working directory. Which in your case is `/tmp`. That is, your IDE sets the working directory to `/tmp`, not the beat.

To learn something about 'paths' check out this documentation (it's the same for all beats): [https://www.elastic.co/guide/en/beats/filebeat/current/directory-layout.html](https://www.elastic.co/guide/en/beats/filebeat/current/directory-layout.html)

You can try to pass `-path.home <path to dev directory>` to the application arguments in your IDE. This should set all path variables to the correct path.

---

<div class="post-metadata">

**Author:** ![caibaoying](https://avatars.discourse-cdn.com/v4/letter/c/dc4da7/32.png) [@caibaoying](https://discuss.elastic.co/u/caibaoying)\
**Post date:** [September 13, 2017, 1:14am UTC](https://discuss.elastic.co/t/what-is-the-role-of-unpack-libbeat-common-cfgfile-go/100009/5 "2017-09-13T01:14:59Z")

</div>

Thanks a lot. I will try to modify it.

[caibaoying3@163.com](mailto:caibaoying3@163.com)

发件人： Steffen Siering  
发送时间： 2017-09-12 20:53  
收件人： caibaoying3  
主题： [Beats] What is the role of unpack,（/libbeat/common/cfgfile.go）?  
steffens Steffen Siering Elastic Team Member  
September 12  
This makes me wonder in which directory your IDE is building or running the executable. If you just build and run the beat, the default ${path} is set to the current working directory. Which in your case is /tmp. That is, your IDE sets the working directory to /tmp, not the beat.  
To learn something about 'paths' check out this documentation (it's the same for all beats): [https://www.elastic.co/guide/en/beats/filebeat/current/directory-layout.html](https://www.elastic.co/guide/en/beats/filebeat/current/directory-layout.html)  
You can try to pass -path.home to the application arguments in your IDE. This should set all path variables to the correct path.

Visit Topic or reply to this email to respond.

In Reply To  
caibaoying Panda  
September 12  
Thanks very much for answering my question. I created my own beats according to [https://www.elastic.co/guide/en/beats/devguide/current/beater-interface.html#beater-interface](https://www.elastic.co/guide/en/beats/devguide/current/beater-interface.html#beater-interface) but when i run it, there was a error: Exiting: error initializing publisher: Error loading template /tmp/axtx\_beat.template.…

Visit Topic or reply to this email to respond.  
To unsubscribe from these emails, click here.

---

<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 2, 2017, 7:19am UTC](https://discuss.elastic.co/t/what-is-the-role-of-unpack-libbeat-common-cfgfile-go/100009/6 "2017-10-02T07:19:30Z")

</div>

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