Filebeat将csv导入es尝试

一、安装

在docker中安装部署ELK+filebeat

二、主要配置

|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| - type: log ``# Change to true to enable this input configuration. ``enabled: true ``# Paths that should be crawled and fetched. Glob based paths. ``paths: ``- /home/centos/pip_v2.csv #源路径 ``#- c:\programdata\elasticsearch\logs\* ``#exclude_lines: ["^Restaurant Name,"] #第一行为字段头以"Restaurant Name"开头,不要第一行 ``multiline: ``pattern: ^\d{4} ``#pattern: ',\d+,[^\",]+$' ``negate: true ``match: after ``max_lines: 1000 ``timeout: 30s |

三、关于elastic的pipline

https://hacpai.com/article/1512990272091

我简单介绍主流程,详情见上链接

1.开启数据预处理,node.ingest: true

2.向es提交pipline,并命名为my-pipeline-id

PUT _ingest/pipeline/my-pipeline-id

{

"description" : "describe pipeline",

"processors" : [

{

"set" : {

"field": "foo",

"value": "bar"

}

}

]

}

3.以上pipline的作用

若产生新的数据,会新增一个字段为foo:bar

4.curl的pipline即时测试

POST _ingest/pipeline/_simulate

是一个测试接口,提供pipline的规则和测试数据,返回结果数据

四、关于grok

是pipline中的正则匹配模式,以上规则的复杂版

|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| POST _ingest/pipeline/_simulate { ``"pipeline": { ``"description": "grok processor", ``"processors" : [ ``{ ``"grok": { ``"field": "message", ``"patterns": ["%{IP:client} %{WORD:method} %{URIPATHPARAM:request} %{NUMBER:bytes} %{NUMBER:duration}"] ``} ``} ``] ``}, ``"docs": [ ``{ ``"_index": "index", ``"_type": "type", ``"_id": "id", ``"_source": { ``"message": "55.3.244.1 GET /index.html 15824 0.043" ``} ``} ``] } |

五、使用pipline导入csv

|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| utput.elasticsearch: ``# Array of hosts to connect to. ``hosts: ["localhost:9200"] ``#index: "csvindex" ``pipline: "my-pipeline-id" ```# Protocol - eitherhttp(default) orhttps.`` ``#protocol: "https"` |

测试结果pipline配置后,并没生效。

六、结论

1.filebeat 导入csv的资料很少,主要为pipline方式,测试几个失败。

2.J和数据组并没有filebaeat 导入csv的成功案例。J不太建议使用

结论:filebeat导csv并不方便,建议采用logstash。

一般日志收集可使用logstash,每行的信息会存到message中

相关推荐
视界先声3 小时前
2025年GEO自动化闭环构建实践:监测工具选型与多平台反馈机制工程分享
大数据·人工智能·自动化
Elasticsearch3 小时前
Elasticsearch:构建一个 AI 驱动的电子邮件钓鱼检测
elasticsearch
百***24373 小时前
GPT5.1 vs Claude-Opus-4.5 全维度对比及快速接入实战
大数据·人工智能·gpt
alan07214 小时前
【Java + Elasticsearch全量 & 增量同步实战】
java·elasticsearch·jenkins
AI营销前沿4 小时前
私域AI首倡者韩剑,原圈科技领航AI营销
大数据·人工智能
Percent_bigdata4 小时前
数据治理平台选型解析:AI大模型与智能体如何重塑企业数字基座
大数据·人工智能
hg01184 小时前
广西对外农业投资规模稳增 民营企业成主力军
大数据
雪兽软件4 小时前
“大数据”能提供什么帮助?
大数据
事变天下4 小时前
肾尚科技完成新一轮融资,加速慢性肾脏病(CKD)精准化管理闭环渗透
大数据·人工智能
GEO AI搜索优化助手5 小时前
范式革命——从“关键词”到“意图理解”,搜索本质的演进与重构
人工智能·搜索引擎·生成式引擎优化·ai优化·geo搜索优化