我正在关注此链接(Link),以显示Kibana上的实时天气数据。我正在使用logstash将实时数据存储到elasticsearch。
我使用了pdf中解释的logstash配置。
这是我的logstash配置:
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}"
}
}
当我执行时,我得到这样的错误
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}
'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.
我在做什么错?有人可以帮帮我吗?
最佳答案
您从源复制了配置,该配置根据您的编辑器首选项,用'
U+0027 : APOSTROPHE {APL quote}
替换了’
U+2019 : RIGHT SINGLE QUOTATION MARK {single comma quotation mark}
。请阅读Right single apostrophe vs. apostrophe?为何不同。
在你的command => "curl --silent -L ’http://api.openweathermap.org/data/2.5/weather?id=5490223&appid=my_api_key&units=metric’"
中
您需要将’
替换为'
,或者手动编写整个网址,而不是复制它
关于windows - “appid”, 'units'无法识别为内部或外部命令,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51391565/