# How can I indexing logs separate by their loggedtime(datetime)

**URL:** <https://discuss.elastic.co/t/how-can-i-indexing-logs-separate-by-their-loggedtime-datetime/250868>\
**Category:** Logstash\
**Tags:** homebrew\
**Created:** [October 3, 2020, 12:34pm UTC](https://discuss.elastic.co/t/how-can-i-indexing-logs-separate-by-their-loggedtime-datetime/250868 "2020-10-03T12:34:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bhavin\_Varsur](https://avatars.discourse-cdn.com/v4/letter/b/ecccb3/32.png) [@Bhavin\_Varsur](https://discuss.elastic.co/u/Bhavin_Varsur)\
**Post date:** [October 3, 2020, 12:34pm UTC](https://discuss.elastic.co/t/how-can-i-indexing-logs-separate-by-their-loggedtime-datetime/250868/1 "2020-10-03T12:34:30Z")

</div>

I have 3 log files which is like this  
logstash-2020.10.01  
logstash-2020.10.02  
logstash-2020.10.03  
when I run logstash (run logstash.conf pipeline) it indexing all logs in one index.  
but i want to index them by the their day so it will easy to see particular day logs and not mixing up all in one index  
so how can i do that?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [October 3, 2020, 1:22pm UTC](https://discuss.elastic.co/t/how-can-i-indexing-logs-separate-by-their-loggedtime-datetime/250868/2 "2020-10-03T13:22:58Z")

</div>

If you [turn off](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-ilm_enabled) ILM then the default index name logstash-%{+yyyy.MM.dd} is based on the value of the @timestamp field.

If you really want the index name based on the filename then use whatever field contains the filename (possibly [path] or [log][file][path]) to set the index option on the logstash output.

---

<div class="post-metadata">

**Author:** ![Bhavin\_Varsur](https://avatars.discourse-cdn.com/v4/letter/b/ecccb3/32.png) [@Bhavin\_Varsur](https://discuss.elastic.co/u/Bhavin_Varsur)\
**Post date:** [October 3, 2020, 5:39pm UTC](https://discuss.elastic.co/t/how-can-i-indexing-logs-separate-by-their-loggedtime-datetime/250868/3 "2020-10-03T17:39:31Z")

</div>

I defined index name but it won't indexing

here is logstash.conf pipeline

input {  
beats {  
port =\> 5044   
}  
}  
filter{  
if "gbase" in [fields][log\_type]  
{  
if [level] in ["Error", "Fatal"]  
{  
grok { match=\> ["message","%{DATESTAMP:timestamp} %{LOGLEVEL:level} %  
{USERNAME:logger} %{USER:user} %{URI:url} %{USER:method} %{IPV4:clientIp} %{GREEDYDATA:message}"] }  
}  
else{  
grok { match=\> ["message","%{DATESTAMP:timestamp} %{LOGLEVEL:level} %{USERNAME:logger} %{USER:user} %{GREEDYDATA:message}"] }  
}  
}  
if "finance" in [fields][log\_type]  
{  
if [level] in ["Error", "Fatal"]  
{  
grok { match=\> ["message","%{DATESTAMP:timestamp} [%{WORD:processId}] %{LOGLEVEL:level} %{USERNAME:logger} %{USER:user} %{URI:requestUrl} %{USER:method} %{IPV4:clientIp} %{GREEDYDATA:message}"]}  
}  
else{  
grok { match=\> ["message","%{DATESTAMP:timestamp} [%{WORD:processId}] %{LOGLEVEL:level} %{USERNAME:logger} %{USER:user} %{IPV4:clientIp} %{GREEDYDATA:message}" ]}  
}  
}  
date {  
match =\> ["timestamp", "yyyy-MM-dd HH:mm:ss,SSS"]  
#match =\> ["timestamp" , "dd/MMM/yyyy:HH:mm:ss Z"]  
target=\> "@timestamp"  
}  
}  
output {  
if "finance" in [fields][log\_type]  
{  
elasticsearch  
{  
hosts =\> ["[http://localhost:9200](http://localhost:9200)"]  
#index =\> "%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}"  
index =\> "finance-%{+YYYY.MM.dd}"  
user =\> "_**"  
password =\> "**_"   
}  
}  
if "gbase" in [fields][log\_type]  
{  
elasticsearch  
{  
hosts =\> ["[http://localhost:9200](http://localhost:9200)"]  
#index =\> "%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}"  
index =\> "gbase-%{+YYYY.MM.dd}"  
user =\> "_**"  
password =\> "**_"   
}  
}  
stdout { codec =\> rubydebug }  
}

here is filebeat.yml

filebeat.inputs:

- type: log  
enabled: true  
paths:
  - D:\Git\gbase.API\Logs\*.log  
fields:  
{log\_type: gbase}

- type: log  
enabled: true  
paths:
  - D:\Git\finance.api\FinanceAPI\logs\*.log  
fields:  
{log\_type: finance}

multiline.pattern: '^[[:space:]]'  
multiline.negate: false  
multiline.match: after

but i can't see index in kibana which is defined in output section

---

<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 31, 2020, 5:39pm UTC](https://discuss.elastic.co/t/how-can-i-indexing-logs-separate-by-their-loggedtime-datetime/250868/4 "2020-10-31T17:39:41Z")

</div>

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