(五)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内部模板的名字

  

 

posted @   丿小贰灬  阅读(395)  评论(0编辑  收藏  举报
编辑推荐:
· 对象命名为何需要避免'-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教师难以实现
点击右上角即可分享
微信分享提示