Search code examples
elasticsearchlogstashprtg

Index data in ElasticSearch from a WEB API


Im trying to index / insert data from an API of a service called PRTG into elasticsearch. This API when i go to an specific URL returns a JSON file, like an WEB API, without downloading nothing. I thought it was possible with this command:

curl --user elastic:****** -XPOST http://localhost:9200/prtg_test/_mapping/_doc  -d @'https://prtgserver/api/historicdata.json?id=2477&avg=0&sdate=2018-08-01-00-00-00&edate=2018-08-07-00-00-00&usecaption=1&username=myusser&password=****'

But im getting an error.

Im newbie in Elastic, so any help would be great, thanks.


Solution

  • To input and index your data in elasticsearch, you first need an input in Logstash.

    Logstash consumes and cleans the data, elasticsearch stores, indexes and presents the data (via web page).

    quick and dirty diagram

    Logstash has an input plugin you could use to consume your messages. Here are details. You’d setup the url as an input and send the data to elasticsearch. You should review the grok language to parse and clean your data in an elasticsearch readable format.

    http plugin