# Logstash import file from url

**URL:** <https://discuss.elastic.co/t/logstash-import-file-from-url/281067>\
**Category:** Logstash\
**Created:** [August 11, 2021, 12:54pm UTC](https://discuss.elastic.co/t/logstash-import-file-from-url/281067 "2021-08-11T12:54:56Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChinigamiHunter](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chinigamihunter/32/92850_2.png) [@ChinigamiHunter](https://discuss.elastic.co/u/ChinigamiHunter)\
**Post date:** [August 11, 2021, 12:54pm UTC](https://discuss.elastic.co/t/logstash-import-file-from-url/281067/1 "2021-08-11T12:54:56Z")

</div>

I am new to Elasticsearch and Logstash, i just need to parse json data from url. Json link is : [https://www.circl.lu/doc/misp/feed-osint/0165e5d7-51e6-4c2e-a382-1dd1e706f7bb.json](https://www.circl.lu/doc/misp/feed-osint/0165e5d7-51e6-4c2e-a382-1dd1e706f7bb.json)

this is my logstash conf file:

```auto
input {

    http {
        url => "https://www.circl.lu/doc/misp/feed-osint/0165e5d7-51e6-4c2e-a382-1dd1e706f7bb.json" 
        codec => json
    }

}

filter {

}

output {
    elasticsearch {
        hosts => "http://localhost:9200"
        index => "indexlogstash"
    }
    stdout { codec => rubydebug }
    
}

```

error i get :

 ![logstash](https://us1.discourse-cdn.com/elastic/original/3X/4/1/4187937f8d5dba7e85f06efa14c266cb1a2beadd.png)

---

<div class="post-metadata">

**Author:** ![Cad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cad/32/86661_2.png) [@Cad](https://discuss.elastic.co/u/Cad)\
**Post date:** [August 11, 2021, 1:07pm UTC](https://discuss.elastic.co/t/logstash-import-file-from-url/281067/2 "2021-08-11T13:07:23Z")

</div>

Hi,

> [@ChinigamiHunter](#):
>
> ```auto
> http {
> url => "https://www.circl.lu/doc/misp/feed-osint/0165e5d7-51e6-4c2e-a382-1dd1e706f7bb.json" 
> codec => json
> }
> 
> ```

url is an option that does not exist for http input plugin.

---

<div class="post-metadata">

**Author:** ![ChinigamiHunter](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chinigamihunter/32/92850_2.png) [@ChinigamiHunter](https://discuss.elastic.co/u/ChinigamiHunter)\
**Post date:** [August 11, 2021, 1:28pm UTC](https://discuss.elastic.co/t/logstash-import-file-from-url/281067/3 "2021-08-11T13:28:35Z")

</div>

Hi,  
what is the best way to parse jso file via url using logstash.

---

<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:** [August 11, 2021, 2:40pm UTC](https://discuss.elastic.co/t/logstash-import-file-from-url/281067/4 "2021-08-11T14:40:36Z")

</div>

You can try the [http\_poller](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-http_poller.html) input plugin.

---

<div class="post-metadata">

**Author:** ![ChinigamiHunter](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chinigamihunter/32/92850_2.png) [@ChinigamiHunter](https://discuss.elastic.co/u/ChinigamiHunter)\
**Post date:** [August 11, 2021, 3:06pm UTC](https://discuss.elastic.co/t/logstash-import-file-from-url/281067/5 "2021-08-11T15:06:29Z")

</div>

hi @leandrojmp Thank for your reply,  
http\_poller use a schedule.  
in my case i want to send it just once.

---

<div class="post-metadata">

**Author:** ![Cad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cad/32/86661_2.png) [@Cad](https://discuss.elastic.co/u/Cad)\
**Post date:** [August 12, 2021, 6:26am UTC](https://discuss.elastic.co/t/logstash-import-file-from-url/281067/6 "2021-08-12T06:26:03Z")

</div>

Hi,

Is it not possible for you to run a curl command, print the result in a file and read this file with logstash ?

---

<div class="post-metadata">

**Author:** ![ChinigamiHunter](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chinigamihunter/32/92850_2.png) [@ChinigamiHunter](https://discuss.elastic.co/u/ChinigamiHunter)\
**Post date:** [August 12, 2021, 5:36pm UTC](https://discuss.elastic.co/t/logstash-import-file-from-url/281067/7 "2021-08-12T17:36:04Z")

</div>

yes i can do that

---

<div class="post-metadata">

**Author:** ![Cad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cad/32/86661_2.png) [@Cad](https://discuss.elastic.co/u/Cad)\
**Post date:** [August 13, 2021, 10:35am UTC](https://discuss.elastic.co/t/logstash-import-file-from-url/281067/8 "2021-08-13T10:35:28Z")

</div>

Hi,

It seems that the [http input plugin](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-http.html#plugins-inputs-http), the [http\_poller input plugin](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-http_poller.html#plugins-inputs-http_poller) and the [exec input plugin](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-exec.html#plugins-inputs-exec) are not compatible with the single reading of a URL.

So if you can do a curl and print the result in a file, try this :

1. Do a curl and print the result in a file
2. Configure your logstash to read the file  
input =\> use the multiline codec plugin to read the entire file in one time [example here](https://discuss.elastic.co/t/parsing-array-of-json-objects-with-logstash-and-injesting-to-elastic/203197/2).  
filter =\> use the json plugin to get all your data.  
output =\> do what you want.

You can even configure logstash before the curl command and configure it to make it read the file when it is edited.

Cad.

---

<div class="post-metadata">

**Author:** ![grumo35](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/grumo35/32/59451_2.png) [@grumo35](https://discuss.elastic.co/u/grumo35)\
**Post date:** [August 13, 2021, 12:10pm UTC](https://discuss.elastic.co/t/logstash-import-file-from-url/281067/9 "2021-08-13T12:10:22Z")

</div>

Hi

i tried something like this but i get a type date to text error dunno why

```auto
input {
  exec {
        command => "curl https://www.circl.lu/doc/misp/feed-osint/0165e5d7-51e6-4c2e-a382-1dd1e706f7bb.json"
        interval => 30
        codec => "json"
        }
}
filter{
        json{
         source=>"message"}
        }       
output {
        elasticsearch{
    hosts => "127.0.0.1:9200"
    index => "zzzzzzzz-%{+YYYY-MM-dd}"
        }
}

```

i get this error mostly need to convert something

```auto
:response=>{"index"=>{"_index"=>"zzzzzzzz-2021-08-13", "_type"=>"_doc", "_id"=>"3rNpP3sBaVcWztqJKPzH", "status"=>400, "error"=>{"type"=>"illegal_argument_exception", "reason"=>"mapper [Event.Object.Attribute.value] cannot be changed from type [date] to [text]"}}}}

```

---

<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 10, 2021, 12:11pm UTC](https://discuss.elastic.co/t/logstash-import-file-from-url/281067/10 "2021-09-10T12:11:05Z")

</div>

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