Http input plugin

logstash作为一个数据输入端。提供http服务,接收客户端的http请求,获取发送的内容。

在config目录下新建文件:

vim config/http-input.yml

input {
  http {
    codec => "json"
    ssl => false
    port => 8989
  }
}

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

output {
  stdout { codec => json }
}

启动:

bin/logstash -f ./config/http-input.yml 

启动后输出:

[root@ss1 logstash-6.5.4]# bin/logstash -f ./config/http-input.yml 
Sending Logstash logs to /root/logstash/logstash-6.5.4/logs which is now configured via log4j2.properties
[2019-04-04T08:52:23,884][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified
[2019-04-04T08:52:23,925][INFO ][logstash.runner          ] Starting Logstash {"logstash.version"=>"6.5.4"}
[2019-04-04T08:52:30,433][INFO ][logstash.pipeline        ] Starting pipeline {:pipeline_id=>"main", "pipeline.workers"=>2, "pipeline.batch.size"=>125, "pipeline.batch.delay"=>50}
[2019-04-04T08:52:31,118][INFO ][logstash.pipeline        ] Pipeline started successfully {:pipeline_id=>"main", :thread=>"#<Thread:0x102cff5e run>"}
[2019-04-04T08:52:31,184][INFO ][logstash.inputs.http     ] Starting http input listener {:address=>"0.0.0.0:8989", :ssl=>"false"}
[2019-04-04T08:52:31,291][INFO ][logstash.agent           ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
[2019-04-04T08:52:31,930][INFO ][logstash.agent           ] Successfully started Logstash API endpoint {:port=>9601}
{"headers":{"request_path":"/","connection":"keep-alive","content_length":"247","request_method":"POST","cache_control":"no-cache","http_version":"HTTP/1.1","postman_token":"7e8dc2ea-f569-42a2-84f4-c53506777c61","content_type":"text/plain","accept_encoding":"gzip, deflate","http_host":"111.111.111.111:8989","http_user_agent":"PostmanRuntime/6.2.5","http_accept":"*/*"},"host":"111.111.111.111","LogType":"maha1","language_type":"heartbeat","LogId":"","ErrorCode":"2","@version":"1","responseLogTime":"2019-04-04 09:40:47.797","srcfile":"c:\\Program.cs","LogMessage":".Net Test","Input":"","Level":"Info","@timestamp":"2019-04-04T08:57:18.780Z"}

另外,logstash有个http poller input,是自己主动去http端点采集数据,如果采集spring boot的jmx服务器监控数据。

 

参考:

https://www.elastic.co/guide/en/logstash/current/plugins-inputs-http.html

 

posted @ 2019-04-04 17:20  Bigben  阅读(636)  评论(0编辑  收藏  举报