# Create indexes from previous nginx access logs

**URL:** <https://discuss.elastic.co/t/create-indexes-from-previous-nginx-access-logs/316818>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [October 17, 2022, 6:05pm UTC](https://discuss.elastic.co/t/create-indexes-from-previous-nginx-access-logs/316818 "2022-10-17T18:05:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kosmylo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kosmylo/32/99660_2.png) [@kosmylo](https://discuss.elastic.co/u/kosmylo)\
**Post date:** [October 17, 2022, 6:05pm UTC](https://discuss.elastic.co/t/create-indexes-from-previous-nginx-access-logs/316818/1 "2022-10-17T18:05:48Z")

</div>

I use filebeat to send nginx access logs to logstash to parse them and then to elasticsearch. The folder includes access logs my previous days, but when I deploy the ELK stack, only the newly arrived nginx access logs are saved into elasticsearch. Is it possible to save also the old ones?

---

<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:** [October 17, 2022, 11:56pm UTC](https://discuss.elastic.co/t/create-indexes-from-previous-nginx-access-logs/316818/2 "2022-10-17T23:56:20Z")

</div>

Are you using the nginx module here?

---

<div class="post-metadata">

**Author:** ![kosmylo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kosmylo/32/99660_2.png) [@kosmylo](https://discuss.elastic.co/u/kosmylo)\
**Post date:** [October 18, 2022, 4:52am UTC](https://discuss.elastic.co/t/create-indexes-from-previous-nginx-access-logs/316818/3 "2022-10-18T04:52:28Z")

</div>

Here is my `filebeat.yml`:

```auto
filebeat.inputs:
- type: log
  enabled: true
  paths:
    - /var/log/nginx/access.log
    - /var/log/spring/geo/*.log

output.logstash:
  enabled: true
  hosts: ["logstash:5035"]

```

My `nginx.conf` from `logstash` pipelines:

```auto
input {
    beats {
        port => 5035
    }
}

filter {
    grok {
        match => ["message" , "%{COMBINEDAPACHELOG}+%{GREEDYDATA:http_x_forwarded_for}"]
    }
    grok {
        match => ["http_x_forwarded_for" , "%{IP:real_client_ip}"]
    }
    mutate {
        convert => ["response", "integer"]
        convert => ["bytes", "integer"]
        convert => ["responsetime", "float"]
    }
    geoip {
        source => "clientip"
        target => "geoip"
        add_tag => ["nginx-geoip"]
    }
    date {
        match => ["timestamp" , "dd/MMM/YYYY:HH:mm:ss Z"]
    }
    useragent {
        source => "message"
    }
}

output {
    elasticsearch {
        hosts => "elasticsearch:9200"
        index => "weblogs-%{+YYYY.MM.dd}"
        document_type => "nginx_logs"
        user => "elastic"
        password => "changeme"
    }
    stdout { codec => rubydebug }
}

```

I am not using the nginx module. Should I use it?

---

<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:** [October 18, 2022, 5:21am UTC](https://discuss.elastic.co/t/create-indexes-from-previous-nginx-access-logs/316818/4 "2022-10-18T05:21:59Z")

</div>

> [@kosmylo](#):
>
> I am not using the nginx module. Should I use it?

It'd be easier, yeah. But it looks like you have another non-nginx source in use that makes it a bit harder.

In your `log` input you can set things like [`ignore_older`](https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-input-log.html#filebeat-input-log-ignore-older) to get it to capture those older ones.

---

<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:** [November 15, 2022, 5:22am UTC](https://discuss.elastic.co/t/create-indexes-from-previous-nginx-access-logs/316818/5 "2022-11-15T05:22:48Z")

</div>

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