# How to allow elastisearch for proper indexing of logs from logstash/filebeat

**URL:** <https://discuss.elastic.co/t/how-to-allow-elastisearch-for-proper-indexing-of-logs-from-logstash-filebeat/77002>\
**Category:** Elasticsearch\
**Created:** [March 1, 2017, 2:48pm UTC](https://discuss.elastic.co/t/how-to-allow-elastisearch-for-proper-indexing-of-logs-from-logstash-filebeat/77002 "2017-03-01T14:48:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ziemowit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ziemowit/32/96546_2.png) [@Ziemowit](https://discuss.elastic.co/u/Ziemowit)\
**Post date:** [March 1, 2017, 2:48pm UTC](https://discuss.elastic.co/t/how-to-allow-elastisearch-for-proper-indexing-of-logs-from-logstash-filebeat/77002/1 "2017-03-01T14:48:33Z")

</div>

Hi!

My intention is to store logs in elastisearch to be able search the logs via severity, thread, request id, etc.  
My logs have already form of JSON:

```
{
  'severity': 'INFO',
  'requestId': '24fd34',
  'message': 'Saving a person',
  ....
}

```

Now my question is how to do this correctly using a) logstash and b) filebeat.

**a) Logstash**

I understand that to inform elasticsearch that in future I would like to search my log via above attributes I need to use "codec =\> json" in elasticsearch plugin. If I am wrong in this point please correct me.

**b) Filebeat**

The question is if for filebeat sth similar is possible? Can I just read from json logs, directly save them to elastisearch and search via severity/requestId/etc afterwards?

Because with following setup:

```
output.elasticsearch:
      # Array of hosts to connect to.
      hosts: ["url:9243"]

      # Optional protocol and basic auth credentials.
      protocol: "https"
      username: "elastic"
      password: "password"
      index: "filebeat"

```

the log line is treated as a whole piece. And I am able to search it only via timestamp.

---

<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:** [March 29, 2017, 2:49pm UTC](https://discuss.elastic.co/t/how-to-allow-elastisearch-for-proper-indexing-of-logs-from-logstash-filebeat/77002/2 "2017-03-29T14:49:12Z")

</div>

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