# Template index creation based on time

**URL:** <https://discuss.elastic.co/t/template-index-creation-based-on-time/88044>\
**Category:** Elasticsearch\
**Created:** [June 2, 2017, 9:25am UTC](https://discuss.elastic.co/t/template-index-creation-based-on-time/88044 "2017-06-02T09:25:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![adonahoe](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@adonahoe](https://discuss.elastic.co/u/adonahoe)\
**Post date:** [June 2, 2017, 9:25am UTC](https://discuss.elastic.co/t/template-index-creation-based-on-time/88044/1 "2017-06-02T09:25:27Z")

</div>

Hello All,

I am having some issues with attempting to create a dynamic template for an index. I keep getting a 404 index not found error. Below is my template and logstash config. If someone could possibly take a look and tell me what I am doing wrong that would be great.

```
   PUT _template/blocklist {
  "template": "blocklist-*",
  "mappings": {
    "tor_node": {
      "_all": {
        "enabled": true
      }
    },
    "ip": {
      "_all": {
        "enabled": false
      },
      "properties": {
        "IP": {
          "type": "ip"
        },
        "PullTime": {
          "type": "date",
          "format": "yyyy'-'MM'-'dd' 'HH:mm:ss"
        },
        "Source": {
          "type": "text"
        }
      }
    },
    "url": {
      "_all": {
        "enabled": false
      },
      "properties": {
        "URL": {
          "type": "text"
        },
        "Date": {
          "type": "date",
          "format": "dd'/'MMM'/'yyyy','HH:mm:ss"
        },
        "Source": {
          "type": "text"
        }
      }
    },
    "domain": {
      "_all": {
        "enabled": false
      },
      "properties": {
        "Domain": {
          "type": "text"
        },
        "Date": {
          "type": "date",
          "format": "dd'/'MMM'/'yyyy','HH:mm:ss"
        },
        "Source": {
          "type": "text"
        }
      }
    }
  }
}

input {

        file {
                path => "/home/ubuntu/enviroments/Blocklists/IP/*.csv"
                start_position => "beginning"
                sincedb_path => "/dev/null"
        }
}
filter {
    csv {
       separator => ","
       columns => ["IP","Source","PullTime"]
        add_tag => ["csvOK"]
    }
    if ([PullTime] == "PullTime") {
        drop { }
    }

    geoip {
        source => "IP"
        target => "geoip"
        database => "/etc/logstash/GeoLite2-City.mmdb"
        add_field => ["[geoip][coordinates]", "%{[geoip][longitude]}" ]
        add_field => ["[geoip][coordinates]", "%{[geoip][latitude]}" ]
    }

    date {
        match => ["PullTime", "yyy-MM-dd' 'HH:mm:ss"]
    }
}
output {
    stdout{ codec => rubydebug }
    elasticsearch
    {
        hosts=>"http://XX.XX.XX.XX:9200"
        user=>"elastic"
        password=>"changeme"
        template_name => "blocklist"
        template_overwrite => "true"
        index=>"blocklist-%{+YYYY-MM-dd}"
        document_type=>"ip"
    }
}
```

---

<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:** [June 2, 2017, 9:28am UTC](https://discuss.elastic.co/t/template-index-creation-based-on-time/88044/2 "2017-06-02T09:28:47Z")

</div>

Please format your code using the `</>` button, or markdown style back ticks, it's really hard to read as is 🙂

---

<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:** [June 30, 2017, 9:29am UTC](https://discuss.elastic.co/t/template-index-creation-based-on-time/88044/3 "2017-06-30T09:29:43Z")

</div>

Closed on June 30, 2017, 9:29am UTC

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