# Logstash configuration file to execute a command?

**URL:** <https://discuss.elastic.co/t/logstash-configuration-file-to-execute-a-command/89680>\
**Category:** Logstash\
**Created:** [June 16, 2017, 9:16am UTC](https://discuss.elastic.co/t/logstash-configuration-file-to-execute-a-command/89680 "2017-06-16T09:16:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cilzzz](https://avatars.discourse-cdn.com/v4/letter/c/c67d28/32.png) [@cilzzz](https://discuss.elastic.co/u/cilzzz)\
**Post date:** [June 16, 2017, 9:16am UTC](https://discuss.elastic.co/t/logstash-configuration-file-to-execute-a-command/89680/1 "2017-06-16T09:16:52Z")

</div>

hey everyone,

i need to configure logstash to execute the output of the command "ifconfig" in elastic search then to visualize on kibana here is my logstash.conf file:

input {  
exec {  
command =\> "/sbin/ifconfig"

```
interval => 5 

```

}  
}  
output{  
elasticsearch { hosts =\> ["elasticsearch:9200"] }  
stdout { codec =\> rubydebug }

}  
the error that i received fom the logs is attached below

 ![](https://us1.discourse-cdn.com/elastic/original/3X/9/5/9540390b3c48aa72f1201764110e3bce9152da70.jpg)

can anyone help thanks in advance !

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [June 16, 2017, 9:39am UTC](https://discuss.elastic.co/t/logstash-configuration-file-to-execute-a-command/89680/2 "2017-06-16T09:39:32Z")

</div>

Are you by any chance running Logstash in a Docker container?

Next time, please don't post a screenshot. Use regular copy/paste from your terminal and post it as preformatted text (e.g. using the `</>` toolbar button).

---

<div class="post-metadata">

**Author:** ![cilzzz](https://avatars.discourse-cdn.com/v4/letter/c/c67d28/32.png) [@cilzzz](https://discuss.elastic.co/u/cilzzz)\
**Post date:** [June 16, 2017, 10:17am UTC](https://discuss.elastic.co/t/logstash-configuration-file-to-execute-a-command/89680/3 "2017-06-16T10:17:29Z")

</div>

yes i am

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [June 16, 2017, 11:19am UTC](https://discuss.elastic.co/t/logstash-configuration-file-to-execute-a-command/89680/4 "2017-06-16T11:19:02Z")

</div>

The Docker image you're using doesn't contain an /sbin/ifconfig binary. You might be able to mount it from your host system with the `-v` option to `docker run`, at least if you also make /proc available. A better option would be to build your own image based on the official image (which I think is CentOS-based) and install whatever package is needed for ifconfig.

---

<div class="post-metadata">

**Author:** ![cilzzz](https://avatars.discourse-cdn.com/v4/letter/c/c67d28/32.png) [@cilzzz](https://discuss.elastic.co/u/cilzzz)\
**Post date:** [June 16, 2017, 12:26pm UTC](https://discuss.elastic.co/t/logstash-configuration-file-to-execute-a-command/89680/5 "2017-06-16T12:26:09Z")

</div>

thank you but i am using the command to run the docker :  
`docker run -h logstash --name logstash --link elasticsearch:elasticsearch -it --rm -v "$PWD":/config-dir logstash -f /config-dir/logstash1.conf`

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [June 16, 2017, 12:58pm UTC](https://discuss.elastic.co/t/logstash-configuration-file-to-execute-a-command/89680/6 "2017-06-16T12:58:41Z")

</div>

Yes...? `docker run` supports multiple `-v` options.

---

<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:** [July 14, 2017, 12:58pm UTC](https://discuss.elastic.co/t/logstash-configuration-file-to-execute-a-command/89680/7 "2017-07-14T12:58:54Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
