我想在我的 golangApp 中使用 logstash。/etc/logstash/conf.d/first-pipeline.confinput { tcp { port => 5959 codec => json }}#filter {}output { elasticsearch { hosts => [ "localhost:9200" ] }}和運行 logstash 的命令:/usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/first-pipeline.conf --path.settings=/etc/logstashgolang 中的代碼:import ( "encoding/json" "fmt" "github.com/heatxsink/go-logstash" "time")func main() {l := logstash.New("0.0.0.0", 5959, 5)_, err := l.Connect()if err != nil { fmt.Println(err)}dataMap := map[string]int{"apple": 5, "lettuce": 7}jsonMap, _ := json.Marshal(dataMap)err = l.Writeln(string(jsonMap))if err != nil { fmt.Println(err)}}當我嘗試在應用程序中請求 logstash 時,在終端顯示此錯誤結束:[2018-12-09T09:12:41,954][錯誤][logstash.inputs.tcp] Netty 管道錯誤:java.io.IOException:連接由對等方重置每件事都在我的本地系統(tǒng)中??梢詭椭覇??
- 0 回答
- 0 關注
- 242 瀏覽
添加回答
舉報
0/150
提交
取消