logstach安装

logstach安装

1.Logstash下载安装

Logstash官网:https://www.elastic.co/cn/downloads/logstash
Logstash版本号要和Elasticsearch对应

在这里插入图片描述

解压

tar -zxvf logstash-7.6.2.tar.gz -C /opt/module/

进入logstash下的bin目录,创建logstash.conf文件添加配置

input {
	file {
		#指定所要的数据文件路径
		path =>	"/opt/module/logstash-7.6.2/bin/movies.csv"
		start_position => "beginning"
		sincedb_path => "/dev/null"
	}
}
filter{
	csv{
		separator => ","
		columns => ["id","content","genre"]
	}
	mutate{
		split => {"genre" => "|"}
		remove_field => ["path","host","@timestamp","message"]
	}
	mutate{
		split => ["content","("]
		add_field => {"title" => "%{[content][0]}"}
		add_field => {"year" => "%{[content][1]}"}
	}
	mutate{
		convert => {
			"year" => "integer"
		}
		strip => ["title"]
		remove_field => ["path","host","@timestamp","message","content"]
	}
}
#输出到9200端口
output{
	elasticsearch{
		hosts => "http://localhost:9200"
		index => "movies"
		document_id => "%{id}"
	}
	stdout{} 
}
执行命令
sudo ./logstash -f logstash.conf
报错
[ERROR][logstash.agent           ] Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main,

经过检查,发现是配置文件logstash.conf里面的http://localhost:9200少了一个/

配置文件一定要检查是否一样不然就容易报错

你可能感兴趣的:(logstach安装)