# Index not created using log stash

**URL:** https://discuss.elastic.co/t/index-not-created-using-log-stash/246443
**Category:** Logstash
**Tags:** docker, logstash
**Created:** [August 26, 2020, 11:30am UTC](https://discuss.elastic.co/t/index-not-created-using-log-stash/246443 "2020-08-26T11:30:44Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Adarsh\_S](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adarsh_s/32/46709_2.png) [@Adarsh\_S](https://discuss.elastic.co/u/Adarsh_S)
#### Post date: [August 26, 2020, 11:30am UTC](https://discuss.elastic.co/t/index-not-created-using-log-stash/246443/1 "2020-08-26T11:30:44Z")

</div>

I am using elasticsearch with logstash [Version : 7.9.0] to visualize a data set with kibana.

I am doing this task on Windows10.

**Logstash config file** -

```auto
input {
  jdbc {
    jdbc_driver_library => "$PATH\mysql-connector-java-5.1.46.jar"
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    jdbc_connection_string => "jdbc:mysql://localhost:3306/world?autoReconnect=true&useSSL=false"
    jdbc_user => root
    jdbc_password => herculus
    parameters => { "names" => "Kabul" }
    statement => "SELECT count(*) FROM world.city where name = :names;"
    schedule => " * * * * * *"
  }
}
output {
  elasticsearch {
    document_id => "%{id}"
    document_type => city
    index => cities
    hosts => ["http://localhost:9200"]
  }
  stdout{
  codec => rubydebug
  }
}

```

Response to curl command,

```auto
logstash-7.9.0\bin>curl -X GET "localhost:9200/cities/_search"
{"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index [cities]","resource.type":"index_or_alias","resource.id":"cities","index_uuid":"_na_","index":"cities"}],"type":"index_not_found_exception","reason":"no such index [cities]","resource.type":"index_or_alias","resource.id":"cities","index_uuid":"_na_","index":"cities"},"status":404}

```

Also, for Get request to URL : **[http://localhost:9200/\_cat/indices?v&pretty](http://localhost:9200/_cat/indices?v&pretty)**

O/P -

`health status index uuid pri rep docs.count docs.deleted store.size pri.store.size`

When I updated the logstash.conf to ,

```auto
input {
  jdbc {
    jdbc_driver_library => "$PATH\mysql-connector-java-5.1.46.jar"
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    jdbc_connection_string => "jdbc:mysql://localhost:3306/world?autoReconnect=true&useSSL=false"
    jdbc_user => root
    jdbc_password => herculus
    parameters => { "names" => "Kabul" }
    statement => "SELECT * FROM world.city where name = :names;"
    schedule => " * * * * * *"
  }
}
output {
if "world.city" in [tags] {
  elasticsearch {
    # document_id => "%{id}"
    # document_type => city
    index => "cities"
    hosts => ["http://localhost:9200"]
  }
  }
  stdout{
  codec => rubydebug
  }

}

```

I am getting response

```auto
[2020-08-26T10:28:01,229][INFO][logstash.inputs.jdbc][main][3b01a5ef336ad85c3946fe6866ca42078069f817e05ec92d17e8ab77baa85416] (0.002075s) SELECT * FROM world.city where name = 'Kabul';
{
     "population" => 100000,
       "@version" => "1",
     "@timestamp" => 2020-08-26T04:58:01.231Z,
           "name" => "Kabul",
    "countrycode" => "IDN",
       "district" => "Yasjdasjk",
             "id" => 4081
}
{
     "population" => 10000,
       "@version" => "1",
     "@timestamp" => 2020-08-26T04:58:01.231Z,
           "name" => "Kabul",
    "countrycode" => "IDN",
       "district" => "Uhjhgjh",
             "id" => 4082
}

```

---

<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 26, 2020, 11:48pm UTC](https://discuss.elastic.co/t/index-not-created-using-log-stash/246443/2 "2020-08-26T23:48:02Z")

</div>

You need to have quotes around the `index` value. You should not be using `type` though.

---

<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: [August 27, 2020, 12:31am UTC](https://discuss.elastic.co/t/index-not-created-using-log-stash/246443/3 "2020-08-27T00:31:36Z")

</div>

> [@Adarsh\_S](#):
>
> `if "world.city" in [tags] {`

Why do you expect it to have that value in the [tags] array?

---

<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 24, 2020, 12:31am UTC](https://discuss.elastic.co/t/index-not-created-using-log-stash/246443/4 "2020-09-24T00:31:43Z")

</div>

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