# What is the best way to index of documents when aggregating logs?

**URL:** <https://discuss.elastic.co/t/what-is-the-best-way-to-index-of-documents-when-aggregating-logs/97668>\
**Category:** Elasticsearch\
**Created:** [August 19, 2017, 7:47pm UTC](https://discuss.elastic.co/t/what-is-the-best-way-to-index-of-documents-when-aggregating-logs/97668 "2017-08-19T19:47:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zacscoding](https://avatars.discourse-cdn.com/v4/letter/z/7bcc69/32.png) [@zacscoding](https://discuss.elastic.co/u/zacscoding)\
**Post date:** [August 19, 2017, 7:47pm UTC](https://discuss.elastic.co/t/what-is-the-best-way-to-index-of-documents-when-aggregating-logs/97668/1 "2017-08-19T19:47:36Z")

</div>

I want to use on elasticsearch for saving access log datas from WEB APP or Database

Web app logs and Database logs have difference fields respectively.  
for example,  
was-access log :  
"url" : xxx,  
"session-id" : xxx,  
"status-code" : xxx,  
...  
db-access log :  
"query" : xxx  
...

So, i thought 2 ways to save access logs.

- first :  
(access datas from WEB APP)  
index : was-access  
type : logs  
fields..  
(access datas from DB)  
index : db-access  
type : logs  
fields..

- second :  
index : 2017-08-20 (i.e created index everyday)  
type : was-access || db-access  
fields..

what is the best way to save datas?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 19, 2017, 9:13pm UTC](https://discuss.elastic.co/t/what-is-the-best-way-to-index-of-documents-when-aggregating-logs/97668/2 "2017-08-19T21:13:21Z")

</div>

If they are different formats, then different indices is the best option.

---

<div class="post-metadata">

**Author:** ![zacscoding](https://avatars.discourse-cdn.com/v4/letter/z/7bcc69/32.png) [@zacscoding](https://discuss.elastic.co/u/zacscoding)\
**Post date:** [August 21, 2017, 1:16am UTC](https://discuss.elastic.co/t/what-is-the-best-way-to-index-of-documents-when-aggregating-logs/97668/3 "2017-08-21T01:16:06Z")

</div>

thx for reply : )

that is my second focus about my question

The first is that it is best option to save index for every day.

for example  
first option :  
index : 2017-08-21  
type : was  
format..

index : 2017-08-20  
type : was  
format..

second option :  
index : was  
format..

what is the better option ??

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 21, 2017, 2:02am UTC](https://discuss.elastic.co/t/what-is-the-best-way-to-index-of-documents-when-aggregating-logs/97668/4 "2017-08-21T02:02:44Z")

</div>

We recommend time based indices, but daily or not depends on the volumes that you are ingesting.

---

<div class="post-metadata">

**Author:** ![zacscoding](https://avatars.discourse-cdn.com/v4/letter/z/7bcc69/32.png) [@zacscoding](https://discuss.elastic.co/u/zacscoding)\
**Post date:** [August 22, 2017, 1:09am UTC](https://discuss.elastic.co/t/what-is-the-best-way-to-index-of-documents-when-aggregating-logs/97668/5 "2017-08-22T01:09:38Z")

</div>

thx for reply 🙂  
It will be great idea to implement my app 😃

---

<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:** [September 19, 2017, 1:09am UTC](https://discuss.elastic.co/t/what-is-the-best-way-to-index-of-documents-when-aggregating-logs/97668/6 "2017-09-19T01:09:39Z")

</div>

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