(五)ELK Logstash output
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # 输出插件将数据发送到一个特定的目的地, 除了elasticsearch还有好多可输出的地方, 例如file, csv, mongodb, redis, syslog等 output { if [ type ] == "apache_access" { elasticsearch { hosts => [ "localhost:9200" ] # 记录的index索引名称格式 index => "apache-access-log-%{+YYYY.MM}" } } else if [ type ] == "apache_error" { elasticsearch { hosts => [ "localhost:9200" ] index => "apache-error-log" } } } |
1 2 3 4 5 6 7 8 9 10 11 | 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 } |
1 2 3 4 5 6 7 8 9 10 11 12 13 | action=>”index” #es要执行的动作 index, delete, create, update index:将logstash.时间索引到一个文档 delete:根据 id 删除一个document(这个动作需要一个 id ) create:建立一个索引document,如果 id 存在 动作失败. update:根据 id 更新一个document,有一种特殊情况可以upsert--如果document不是已经存在的情况更新document 。参见upsert选项。 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" manage_template=> true 一个默认的es mapping 模板将启用(除非设置为 false 用自己的template) template=>”” 有效的filepath 设置自己的template文件路径,不设置就用已有的 template_name=>”logstash” 在es内部模板的名字 |
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 对象命名为何需要避免'-er'和'-or'后缀
· SQL Server如何跟踪自动统计信息更新?
· AI与.NET技术实操系列:使用Catalyst进行自然语言处理
· 分享一个我遇到过的“量子力学”级别的BUG。
· Linux系列:如何调试 malloc 的底层源码
· JDK 24 发布,新特性解读!
· C# 中比较实用的关键字,基础高频面试题!
· .NET 10 Preview 2 增强了 Blazor 和.NET MAUI
· Ollama系列05:Ollama API 使用指南
· 为什么AI教师难以实现