1、logstash导出文件
参考:https://www.cntofu.com/book/52/output/file.md
备份:
input {
elasticsearch {
hosts => ["http://192.168.37.174:9200"]
index => "yspybd_0002" // 多个索引用,隔开
user => "es_user"
password => "es_passwd_balabalabala"
docinfo => true
}
}
filter {
mutate {
remove_field => ["@timestamp", "@version"]
}
}
output {
file {
path => "/data/%{[@metadata][_index]}.json.gz"
gzip => true // gzip压缩减少空间使用
}
}
恢复[ from json files ]:
input {
file {
path => "/data/logstash-7.6.2/bin/exec-history-2023-12.json"
sincedb_path => "/dev/null"
start_position => beginning // 必须加这个,不然,文件中的数据录入不了,logstash默认是tail最新的数据录入
type => "json" // 可以固定加一个字段到新的索引里面,不过一般没有意义,如果做判断,或许可以加不同的
}
}
filter {
json {
source => "message" // source是input的内容,必须做一个转换,不然,旧索引的一行数据就会变成新索引的message字段
}
mutate {
remove_field => ["@timestamp", "@version", "host"] // 用于删除源数据中某[几]个字段
}
}
output {
elasticsearch {
hosts => ["http://192.168.30.130:9200"]
index => "exec-history-2023-12"
user => "elastic"
password => "uguess"
}
}
liutianfeng.com
转载请注明:liutianfeng.com » ES备份&恢复