# Log.file.path with grok condition issue with multiple log files

**URL:** <https://discuss.elastic.co/t/log-file-path-with-grok-condition-issue-with-multiple-log-files/339600>\
**Category:** Elasticsearch\
**Created:** [July 29, 2023, 4:51pm UTC](https://discuss.elastic.co/t/log-file-path-with-grok-condition-issue-with-multiple-log-files/339600 "2023-07-29T16:51:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sanjeev1895](https://avatars.discourse-cdn.com/v4/letter/s/e9a140/32.png) [@sanjeev1895](https://discuss.elastic.co/u/sanjeev1895)\
**Post date:** [July 29, 2023, 4:51pm UTC](https://discuss.elastic.co/t/log-file-path-with-grok-condition-issue-with-multiple-log-files/339600/1 "2023-07-29T16:51:48Z")

</div>

Hi Team,

Am I trying to create the index using log.file.path field in the grok if condition. Actually am I including the multiple file path. so while doing this the index was not creating. but if I include only one, then it's works well.  
I attached below my scenarios, can anyone let me know what I missed here..

Multiple logfile include: ( This method not working )

```auto
filter {
    if [log][file][path] == "/var/log/apache2/sfsite-access_log","/var/log/apache2/sfapi-access_log" {
      grok {
        match => { "message" => "\[%{HTTPDATE:time_stamp}\] %{HOSTNAME:domain_name} \"%{WORD:method} /%{NOTSPACE:request_page} HTTP/%{NUMBER:http_version}\" %{NUMBER:response_code} (?:%{NUMBER:response_bytes}|-) %{QS:agent} %{NOTSPACE:page_url} %{QS:agent_type}" }

 }

```

Single logfile include: ( This method is working )

```auto
filter {
    if [log][file][path] == "/var/log/apache2/sfsite-access_log" {
      grok {
        match => { "message" => "\[%{HTTPDATE:time_stamp}\] %{HOSTNAME:domain_name} \"%{WORD:method} /%{NOTSPACE:request_page} HTTP/%{NUMBER:http_version}\" %{NUMBER:response_code} (?:%{NUMBER:response_bytes}|-) %{QS:agent} %{NOTSPACE:page_url} %{QS:agent_type}" }

 }

```

**NOTE: only changes I made is number of log files include**

Kindly advice anyone.

Thanks

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [July 29, 2023, 5:05pm UTC](https://discuss.elastic.co/t/log-file-path-with-grok-condition-issue-with-multiple-log-files/339600/2 "2023-07-29T17:05:31Z")

</div>

> [@sanjeev1895](#):
>
> `if [log][file][path] == "/var/log/apache2/sfsite-access_log","/var/log/apache2/sfapi-access_log"`

This is not the correct way to test multiple values, check the [documentation](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#conditionals) and try to use `in`.

```auto
if [log][file][path] in ["/var/log/apache2/sfsite-access_log","/var/log/apache2/sfapi-access_log"]

```

---

<div class="post-metadata">

**Author:** ![sanjeev1895](https://avatars.discourse-cdn.com/v4/letter/s/e9a140/32.png) [@sanjeev1895](https://discuss.elastic.co/u/sanjeev1895)\
**Post date:** [August 12, 2023, 6:45am UTC](https://discuss.elastic.co/t/log-file-path-with-grok-condition-issue-with-multiple-log-files/339600/3 "2023-08-12T06:45:48Z")

</div>

@leandrojmp  
Thank you. I will modify my configuration.

---

<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 9, 2023, 6:46am UTC](https://discuss.elastic.co/t/log-file-path-with-grok-condition-issue-with-multiple-log-files/339600/4 "2023-09-09T06:46:15Z")

</div>

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