# Logstash insert only first row

**URL:** <https://discuss.elastic.co/t/logstash-insert-only-first-row/160288>\
**Category:** Logstash\
**Created:** [December 11, 2018, 5:29am UTC](https://discuss.elastic.co/t/logstash-insert-only-first-row/160288 "2018-12-11T05:29:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![inandi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/inandi/32/40801_2.png) [@inandi](https://discuss.elastic.co/u/inandi)\
**Post date:** [December 11, 2018, 5:29am UTC](https://discuss.elastic.co/t/logstash-insert-only-first-row/160288/1 "2018-12-11T05:29:05Z")

</div>

I am getting data from Google API and I want to save it to ES using logstash.

**logstash conf** file

```
input {
  file {
    path => "/home/templetes/dt5.txt"
    start_position => "beginning"
    sincedb_path => "/dev/null"
    codec => "json"        
  }
}

filter { 
  json {
    source => "message"
  } 
}

output {
  stdout { codec => rubydebug }
  if [reviewId] != "" {
    elasticsearch {
      hosts => ["http://127.0.0.1:9200"] 
      index => "losscation_7"
      document_id => "%{reviewId}"
      template =>"/home/templetes/datamobi.json"
      template_name=>"datamobi"
      template_overwrite => true
    }
  }
}

```

datamobi.json ( **template** ) file

```
{
  "index_patterns": ["losscation*"],
  "settings": {
    "index": {
      "number_of_shards": "2",
      "number_of_replicas": "1"
    }
  },
  "mappings": {
    "doc":{
      "dynamic": "false"
    }
  },
  "aliases": {}
}

```

in my controller (PHP, Codeigniter), I am writing the file(dt5.txt) with data that I am getting from API. But the problem is it is inserting the first document only. But if I manually change the file(dt5.txt), it is inserting all data. What might be the issue?

---

<div class="post-metadata">

**Author:** ![inandi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/inandi/32/40801_2.png) [@inandi](https://discuss.elastic.co/u/inandi)\
**Post date:** [December 11, 2018, 5:49am UTC](https://discuss.elastic.co/t/logstash-insert-only-first-row/160288/2 "2018-12-11T05:49:42Z")

</div>

Got my solution, i was using txt file. Now i am using JSON file ie dt5.json. Problem solved.

---

<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:** [January 8, 2019, 5:49am UTC](https://discuss.elastic.co/t/logstash-insert-only-first-row/160288/3 "2019-01-08T05:49:44Z")

</div>

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