logstash-output elasticsearch插件使用
来源:互联网 发布:贵阳广电网络公司地址 编辑:程序博客网 时间:2024/04/29 05:00
logstash-output elasticsearch插件使用
output elasticsearch 插件使用是需要template模板,不指定时会用到默认的模板。
一:首先解释下elasticsearch的一些设置参数:
Retry policy 重操作方针
这个插件利用es bulk API来优化es的输入。这些请求可能经历部分或全部失败。
action=>”index” #es要执行的动作 index, delete, create, update
l index:将logstash.时间索引到一个文档
l delete:根据id删除一个document(这个动作需要一个id)
l create:建立一个索引document,如果id存在 动作失败.
l update:根据id更新一个document,有一种特殊情况可以upsert--如果document不是已经存在的情况更新document 。参见upsert选项。
l A sprintf style string to change the action based on the content of the event. The value %{[foo]} would use the foo field for the action
document_id=>” ” 为索引提供document id ,对重写elasticsearch中相同id词目很有用
document_type=>” ”事件要被写入的document type,一般要将相似事件写入同一type,可用%{}引用事件type,默认type=log
index=>”logstash-%{+YYYY,MM.dd}” 事件要被写进的索引,可是动态的用%{foo}语句
hosts=>[“127.0.0.0”] ["127.0.0.1:9200","127.0.0.2:9200"] ["https://127.0.0.1:9200"]["https://127.0.0.1:9200/mypath"]
manage_template=>true 一个默认的es mapping 模板将启用(除非设置为false 用自己的template)
template=>”” 有效的filepath 设置自己的template文件路径,不设置就用已有的
template_name=>”logstash” 在es内部模板的名字
二:单个模板template时
output{ elasticsearch{ hosts=>["172.132.12.3:9200"] action=>"index" index=>"indextemplate-logstash" #document_type=>"%{@type}" document_id=>"ignore" template=>"/opt/logstash-conf/es-template.json" template_name=>"es-template.json" template_overwrite=>true } stdout{ codec=>rubydebug }}
这里指定了自己的本地template: es-template.json. 内容比较简单
{ "template" : "indextemplate-*", "settings" : { "index.refresh_interval" : "5s", "number_of_replicas":"1", "number_of_shards":"3" }, "mappings" : { "_default_" : { "_all" : {"enabled" :false, "omit_norms" : true}, "dynamic_templates" : [ { "message_field" : { "match" : "message", "match_mapping_type" : "string", "mapping" : { "type" : "string", "index" : "analyzed", "omit_norms" : true, "fielddata" : { "format" : "disabled" } } } }, { "string_fields" : { "match" : "*", "match_mapping_type" : "string", "mapping" : { "type" : "string", "index" : "analyzed", "omit_norms" : true, "fielddata" : { "format" : "disabled" }, "fields" : { "raw" : {"type": "string", "index" : "not_analyzed", "ignore_above" : 20} } } } } ] } }}
三:多个模板template时
从logstash写数据到elasticsearch时,指定单个数据模板没有问题,在配置多个数据模板时候就一定要加一个配置项: template_name ,且名字必须全部为小写。
output { if [type] == "log_01" { elasticsearch { cluster => 'elasticsearch' hosts=>[“x.x.x.x:9300”] index => 'log_01-%{+YYYY-MM-dd}' workers => 1 #document_type=>"%{@type}" document_id=>"ignore" template => "/opt/logstash-conf/es-template.json" template_name => "template_01.json" template_overwrite => true } } if [type] == "log_02" { elasticsearch { cluster => 'elasticsearch' hosts => [“x.x.x.x:9300”] index => 'log_02-%{+YYYY-MM-dd}' #document_type=>"%{@type}" document_id=>"ignore" workers => 1 template => "/data/logstash/conf/template_02.json" template_name => "template_01.json" template_overwrite => true } }}
- logstash-output elasticsearch插件使用
- logstash elasticsearch output插件的bulk提交
- logstash Output plugins >> elasticsearch
- 从logstash -> output -> elasticsearch动态模板说起
- logstash input output filter 插件总结
- Logstash input output filter插件总结
- Logstash学习记录--logstash input output filter 插件总结
- 搭建ELK(ElasticSearch+Logstash+Kibana)日志分析系统(三) logstash input output 配置
- elasticsearch插件四—— logstash插件安装详解
- logstash-filter-elasticsearch 具体使用实例
- Elasticsearch、Logstash、Kibana、Filebeat的使用总结
- 使用 logstash + kafka + elasticsearch 实现日志监控
- logstash-input-exec插件使用
- logstash的kafka插件使用
- Logstash的kafka插件使用
- Logstash-Output-Webhdfs
- Logstash的logstash-input-jdbc插件mysql数据同步ElasticSearch及词库
- ElasticSearch学习笔记(三)logstash安装和logstash-input-jdbc插件
- 用户登录后,往session中插入的“userDetail”即用户信息,专业属于叫什么?
- MySQL事务隔离级别详解
- 用*输出菱形图案
- Openfire开发配置,Openfire源代码配置,OpenFire二次开发配置(eclipse)
- Android中对时间的各类操作
- logstash-output elasticsearch插件使用
- C#命名空间“Microsoft”中不存在类型或命名空间名称“Office ”---问题解决
- T-SQL 第十四章上机连接数据库
- 技术人员的自我救赎
- python 批量爬取博客数据(仅供学习)
- C语言中的基本类型
- opencv常用函数入参
- C++互斥锁 临界区 信号量 事件的区别总结
- 如何使用Vuex+Vue.js构建单页应用