'appid' is not recognized as an internal or external command

Hi all,

I am following this link (Link) to display live weather data on Kibana.

I used the logstash configuration explained in the pdf.

Here is my logstash configuration:

input {
  exec {
    command => "curl --silent -L ’http://api.openweathermap.org/data/2.5/weather?id=5490223&appid=my_api_key&units=metric’"
    codec => "json"
    interval => 600
  }
}
filter {
  mutate {
    remove_field => ["@version" ,"command" ,"host" ,"cod" ,"id" ,"base" ,"coord" ,"sys" ,"dt"]
  }
  split { field => "weather" }
}
output {
  elasticsearch {
    hosts => ["localhost:9200"]
    index => "weather-%{+YYYY.MM.dd}"
  }
}

When I execute, I get an error like this

PS E:\elk\logstash\bin> .\logstash -f weather_data.conf --config.test_and_exit
Sending Logstash's logs to E:/elk/logstash/logs which is now configured via log4j2.properties
[2018-07-17T15:59:55,097][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified
Configuration OK
[2018-07-17T15:59:57,966][INFO ][logstash.runner          ] Using config.test_and_exit mode. Config Validation Result: OK. Exiting Logstash
PS E:\elk\logstash\bin> .\logstash -f weather_data.conf
Sending Logstash's logs to E:/elk/logstash/logs which is now configured via log4j2.properties
[2018-07-17T16:00:43,198][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified
[2018-07-17T16:00:44,089][INFO ][logstash.runner          ] Starting Logstash {"logstash.version"=>"6.3.1"}
[2018-07-17T16:00:49,292][INFO ][logstash.pipeline        ] Starting pipeline {:pipeline_id=>"main", "pipeline.workers"=>8, "pipeline.batch.size"=>125, "pipeline.batch.delay"=>50}
[2018-07-17T16:00:50,101][INFO ][logstash.outputs.elasticsearch] Elasticsearch pool URLs updated {:changes=>{:removed=>[], :added=>[http://localhost:9200/]}}
[2018-07-17T16:00:50,119][INFO ][logstash.outputs.elasticsearch] Running health check to see if an Elasticsearch connection is working {:healthcheck_url=>http://localhost:9200/, :path=>"/"}
[2018-07-17T16:00:50,488][WARN ][logstash.outputs.elasticsearch] Restored connection to ES instance {:url=>"http://localhost:9200/"}
[2018-07-17T16:00:50,596][INFO ][logstash.outputs.elasticsearch] ES Output version determined {:es_version=>6}
[2018-07-17T16:00:50,603][WARN ][logstash.outputs.elasticsearch] Detected a 6.x and above cluster: the `type` event field won't be used to determine the document _type {:es_version=>6}
[2018-07-17T16:00:50,650][INFO ][logstash.outputs.elasticsearch] New Elasticsearch output {:class=>"LogStash::Outputs::ElasticSearch", :hosts=>["//localhost:9200"]}
[2018-07-17T16:00:50,687][INFO ][logstash.outputs.elasticsearch] Using mapping template from {:path=>nil}
[2018-07-17T16:00:50,819][INFO ][logstash.outputs.elasticsearch] Attempting to install template {:manage_template=>{"template"=>"logstash-*", "version"=>60001, "settings"=>{"index.refresh_interval"=>"5s"}, "mappings"=>{"_default_"=>{"dynamic_templates"=>[{"message_field"=>{"path_match"=>"message", "match_mapping_type"=>"string", "mapping"=>{"type"=>"text", "norms"=>false}}}, {"string_fields"=>{"match"=>"*", "match_mapping_type"=>"string", "mapping"=>{"type"=>"text", "norms"=>false, "fields"=>{"keyword"=>{"type"=>"keyword", "ignore_above"=>256}}}}}], "properties"=>{"@timestamp"=>{"type"=>"date"}, "@version"=>{"type"=>"keyword"}, "geoip"=>{"dynamic"=>true, "properties"=>{"ip"=>{"type"=>"ip"}, "location"=>{"type"=>"geo_point"}, "latitude"=>{"type"=>"half_float"}, "longitude"=>{"type"=>"half_float"}}}}}}}}
[2018-07-17T16:00:50,921][INFO ][logstash.inputs.exec     ] Registering Exec Input {:type=>nil, :command=>"curl --silent -L 'http://api.openweathermap.org/data/2.5/weather?id=5490223&appid=6fe2c29d12b0cced47f3efa361dc1fe8&units=metric'", :interval=>600, :schedule=>nil}
[2018-07-17T16:00:50,989][INFO ][logstash.pipeline        ] Pipeline started successfully {:pipeline_id=>"main", :thread=>"#<Thread:0x59b6b4e7 run>"}
[2018-07-17T16:00:51,154][INFO ][logstash.agent           ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
'appid' is not recognized as an internal or external command,
operable program or batch file.
'units' is not recognized as an internal or external command,
operable program or batch file.
[2018-07-17T16:00:51,890][INFO ][logstash.agent           ] Successfully started Logstash API endpoint {:port=>9600}

What wrong am I doing? Can someone please help me?

Windows quoting does not work like UNIX. It does not respect single quotes. You can test this in a CMD window.

C:\>echo 'foo&bar'
'foo
'bar'' is not recognized as an internal or external command,
operable program or batch file.

Reverse the single and double quotes

command => 'curl --silent -L "http://api.openweathermap.org/data/2.5/weather?id=5490223&appid=my_api_key&units=metric"’

Thanks @Badger! It is working now.

But, when I now navigate to http://localhost:9200/_cat/indices, I don't see any new index that begins with weather-*

What am I supposed to do now?

Add

output { stdout { codec => rubydebug } }

and see what the events look like. Also, check the elasticsearch logs and see if it is logging anything (although if it were returning an error to logstash I would expect logstash to log it).

@Badger Everything seems to be fine

Here is the output of the logstash-plain.log

[2018-07-18T11:18:18,301][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified
[2018-07-18T11:18:18,764][INFO ][logstash.runner          ] Starting Logstash {"logstash.version"=>"6.3.1"}
[2018-07-18T11:18:22,501][INFO ][logstash.pipeline        ] Starting pipeline {:pipeline_id=>"main", "pipeline.workers"=>8, "pipeline.batch.size"=>125, "pipeline.batch.delay"=>50}
[2018-07-18T11:18:22,879][INFO ][logstash.outputs.elasticsearch] Elasticsearch pool URLs updated {:changes=>{:removed=>[], :added=>[http://localhost:9200/]}}
[2018-07-18T11:18:22,886][INFO ][logstash.outputs.elasticsearch] Running health check to see if an Elasticsearch connection is working {:healthcheck_url=>http://localhost:9200/, :path=>"/"}
[2018-07-18T11:18:23,089][WARN ][logstash.outputs.elasticsearch] Restored connection to ES instance {:url=>"http://localhost:9200/"}
[2018-07-18T11:18:23,168][INFO ][logstash.outputs.elasticsearch] ES Output version determined {:es_version=>6}
[2018-07-18T11:18:23,177][WARN ][logstash.outputs.elasticsearch] Detected a 6.x and above cluster: the `type` event field won't be used to determine the document _type {:es_version=>6}
[2018-07-18T11:18:23,213][INFO ][logstash.outputs.elasticsearch] New Elasticsearch output {:class=>"LogStash::Outputs::ElasticSearch", :hosts=>["//localhost:9200"]}
[2018-07-18T11:18:23,252][INFO ][logstash.outputs.elasticsearch] Using mapping template from {:path=>nil}
[2018-07-18T11:18:23,297][INFO ][logstash.outputs.elasticsearch] Attempting to install template {:manage_template=>{"template"=>"logstash-*", "version"=>60001, "settings"=>{"index.refresh_interval"=>"5s"}, "mappings"=>{"_default_"=>{"dynamic_templates"=>[{"message_field"=>{"path_match"=>"message", "match_mapping_type"=>"string", "mapping"=>{"type"=>"text", "norms"=>false}}}, {"string_fields"=>{"match"=>"*", "match_mapping_type"=>"string", "mapping"=>{"type"=>"text", "norms"=>false, "fields"=>{"keyword"=>{"type"=>"keyword", "ignore_above"=>256}}}}}], "properties"=>{"@timestamp"=>{"type"=>"date"}, "@version"=>{"type"=>"keyword"}, "geoip"=>{"dynamic"=>true, "properties"=>{"ip"=>{"type"=>"ip"}, "location"=>{"type"=>"geo_point"}, "latitude"=>{"type"=>"half_float"}, "longitude"=>{"type"=>"half_float"}}}}}}}}
[2018-07-18T11:18:23,369][INFO ][logstash.inputs.exec     ] Registering Exec Input {:type=>nil, :command=>"curl --silent -L \"http://api.openweathermap.org/data/2.5/weather?id=5490223&appid='My_API_Key'&units=metric\"", :interval=>600, :schedule=>nil}
[2018-07-18T11:18:23,409][INFO ][logstash.pipeline        ] Pipeline started successfully {:pipeline_id=>"main", :thread=>"#<Thread:0x7420a8b0 run>"}
[2018-07-18T11:18:23,552][INFO ][logstash.agent           ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
[2018-07-18T11:18:24,086][INFO ][logstash.agent           ] Successfully started Logstash API endpoint {:port=>9600}

And yet, I don't see an index created

health status index                           uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   .kibana                         ZB7x3FQyQlyRvkRIaEGi2g   1   0          2            0     12.3kb         12.3kb
green  open   .monitoring-kibana-6-2018.07.12 8iFI69JhQL-bLWsGZzFQYA   1   0       2370            0    697.8kb        697.8kb
green  open   .monitoring-es-6-2018.07.12     4-XcOMWsRkW7_enzqslTQg   1   0      34226          115     12.7mb         12.7mb
yellow open   logstash-2018.07.13             _oiQOnpMQ4KQcHssK8PmxA   5   1       9999            0        7mb            7mb
green  open   .monitoring-es-6-2018.07.18     h_ylFE80RS6153Sx5A7o6A   1   0      11538            0       11mb           11mb
green  open   .monitoring-es-6-2018.07.15     27pTcx8TTDqchfQgo7WQ-w   1   0        234            0    160.2kb        160.2kb
green  open   .monitoring-kibana-6-2018.07.16 Lmydu8eOS8-p6aKPP7SUqw   1   0       1383            0    465.1kb        465.1kb
green  open   .monitoring-es-6-2018.07.17     HThfGRdATO-C455Xm_-e9Q   1   0      49107          175     18.1mb         18.1mb
green  open   .monitoring-kibana-6-2018.07.17 u1EedigZSWeXOaOwdueEdQ   1   0       2450            0    700.7kb        700.7kb
green  open   .monitoring-kibana-6-2018.07.14 17TgPEalTAOJRe3gb59eZA   1   0         15            0     87.5kb         87.5kb
green  open   .monitoring-es-6-2018.07.16     3iZspMNoQUuty5lYM5ylvg   1   0      39028          135     17.3mb         17.3mb
green  open   .monitoring-es-6-2018.07.13     1FBGvkSzR4yf7WcyrwN3LQ   1   0      51214           50     19.2mb         19.2mb
green  open   .monitoring-kibana-6-2018.07.18 ZnYApUXKQbiH9CVFRqmzdw   1   0        530            0    413.1kb        413.1kb
green  open   .monitoring-kibana-6-2018.07.15 9TZ9csgUQp-LrAbRYT4aGw   1   0          9            0    127.5kb        127.5kb
green  open   .monitoring-kibana-6-2018.07.13 Cpt83ctnQiqLWiydy1nmUw   1   0       2585            0    830.1kb        830.1kb
green  open   .monitoring-es-6-2018.07.14     fuXHKIMNS5u15-XR0dvrTw   1   0        380          162    575.3kb        575.3kb

What wrong am I doing?

Why not use the http_poller input plugin instead of running a separate process?

@magnusbaeck How do I use this plugin? Could you please help me? I need to get this up and running for a demo. Also, I have been following the steps in the pdf I have mentioned above. Is there anything wrong I am doing?

@magnusbaeck @Badger I would really appreciate your help. Could you please help me?

Probably something like this, although I am unable to test it. Note that if it is configured to run every 10 minutes then it will wait for 10 minutes before the first run.

http_poller {
    urls => {
        weather => {
            url => "http://api.openweathermap.org/data/2.5/weather?id=5490223&appid=my_api_key&units=metric’"
            headers => {
              Accept => "application/json"
            }
        }
    }
    schedule => { cron => "* */10 * * * *" }
    codec => json
}

Note also that is considered rude to ping people if they fail to respond within a few minutes.

Thanks! I will take a look at it. Sorry, I did not mean to ping anyone. I did not realize that tagging name was equivalent to pinging. Will ensure that it doesn't happen.

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