ELK basic---http://udn.yyuap.com/doc/logstash-best-practice-cn/filter/grok.html
http://blog.csdn.net/lgnlgn/article/details/8053626 elasticsearch学习入门
input {stdin{}}
filter {
grok {
match => {
"message" => ".*(?<json_body>\{.*\}).*"
}
}
json {
source => "json_body"
}
}
************jdbc-in********************
input {
jdbc {
jdbc_driver_library => "/home/app/logstash/vendor/jar/jdbc/mysql-connector-java-5.1.36-bin.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://12.0.1.28:3306/ucampus_dev?characterEncoding=utf8"
jdbc_user => "user"
jdbc_password => "Kn!0748j"
statement => "SELECT * FROM sys_online_history limit 0,1"
jdbc_paging_enabled => "true"
jdbc_page_size => "50000"
schedule => "* * * * *"
}
}
filter {
json {
source => "message"
remove_field => ["message"]
}
}
output {
stdout {
codec => rubydebug
}
}
************jdbc-in********************
检查ES集群状态:
curl 54.223.139.77:9200/_cat/health?v
检查ES节点状态:
curl 54.223.139.77:9200/_cat/nodes?v
查询所有的索引:
curl 54.223.139.77:9200/_cat/indices?v
curl -XPUT 'http://localhost:9200/twitter/'
$ curl -XPUT 'http://localhost:9200/twitter/'
-d '
index :
number_of_shards : 3
number_of_replicas : 2
'
上面第二个curl例子展示了如何创建一个名字叫 twitter 的索引,并且使用 YAML
格式为其指定设置项。在这个例子中,我们为该索引配置了三个切片和两个副本。索引设置项也可以通过 JSON 格式指定:
$ curl -XPUT 'http://localhost:9200/twitter/'
-d '{
"settings" : {
"index" : {
"number_of_shards" : 3,
"number_of_replicas" : 2
}
}
}'
或者简化为
$ curl -XPUT 'http://localhost:9200/twitter/'
-d '{
"settings" : {
"number_of_shards" : 3,
"number_of_replicas" : 2
}
}'
curl -XPOST localhost:9200/test -d '{
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"type1" : {
"_source" : { "enabled" : false },
"properties" : {
"field1" : { "type" : "string", "index" :
"not_analyzed" }
}
}
}
}'
删除索引:
curl -XDELETE localhost:9200/索引名字
查询索引:
curl -XGET localhost:9200/索引名字/类型名字/id
ES 使用bulk 添加数据
动态映射无法添加数据,不要担心!可以使用bulk命令,添加json文件内的数据。
1 定义json数据文件:
{"index":{"_index":"aaa123","_id":1}}
{"name":"xingoo","age":25}
{"index":{"_index":"aaa123","_id":2}}
{"name":"test111","age":31}
{"index":{"_index":"aaa123","_id":3}}
{"name":"test222","age":42}
{"index":{"_index":"aaa123","_id":4}}
{"name":"test333","age":13}
注意的是,json文件名称随意指定,第一行定义了索引和一些常用字段:
_index定义了索引的名称,如果没有指定需要在curl命令中添加索引名称字段
_type定义了索引的类型,如果没有指定需要在curl命令中添加索引类型字段
_id定义了该行数据的id,如果没有指定,会随机生成一串数字。
2 执行命令
进入到json文件所在的目录,执行命令
curl localhost:9200/索引名称/索引类型/_bulk?pretty --data-binary @data.json
注意的是:
如果json文件中定义了_index和_type,那么这里可以不写变成(即便写了也会按照json文件中的生成)
curl localhost:9200/_bulk?pretty --data-binary @data.json
field 换 type
首先创建一个新的索引
curl -XPUT localhost:8305/store_v2 -d '{ "settings" : { "number_of_shards" : 20 }, "mappings" : { "client" : { "properties" : { "ip" : { "type" : "string" }, "cost" : { "type" : "long" },} ====create index mapping curl -XPUT 54.223.139.77:9200/store_v2 --data-binary @data1.json python用起来比较熟,所以我就直接选 pyes了,装了一大堆破依赖库之后,终于可以run起来了 import pyes conn = pyes.es.ES("http://10.xx.xx.xx:8305/") search = pyes.query.MatchAllQuery().search(bulk_read=1000) hits = conn.search(search, 'store_v1', 'client', scan=True, scroll="30m", model=lambda _,hit: hit) for hit in hits: #print hit conn.index(hit['_source'], 'store_v2', 'client', hit['_id'], bulk=True) conn.flush() 花了大概一个多小时,新的索引基本和老索引数据一致了,对于线上完成瞬间的增量,这里没心思关注了,数据准确性要求没那么高,得过且过。 接下来修改alias别名的指向(如果你之前没有用alias来改mapping,纳尼就等着哭吧) curl -XPOST localhost:8305/_aliases -d ' { "actions": [ { "remove": { "alias": "store", "index": "store_v1" }}, { "add": { "alias": "store", "index": "store_v2" }} ] }
等新索引的数据已经追上时
将老的索引删掉
|
1
|
curl -XDELETE localhost:8303/store_v1 |
ELK basic---http://udn.yyuap.com/doc/logstash-best-practice-cn/filter/grok.html的更多相关文章
- ELK学习记录二 :elasticsearch、logstash及kibana的安装与配置
注意事项: 1.ELK版本要求5.X以上,本人使用版本:elasticsearch-6.0.0.kibana-6.0.0-linux-x86_64.logstash-6.0.0.tar 2.Elast ...
- logstash filter grok 用法
在elk+filebeat都安装好,且明白了基本流程后,主要的就是写logstash的filter了,以此来解析特定格式的日志 logstash的filter是用插件实现的,grok是其中一个,用来解 ...
- logstash笔记(二)——grok之match
官方文档: https://www.elastic.co/guide/en/logstash/current/plugins-filters-grok.html 基本语法: %{SYNTAX:SEMA ...
- 使用Logstash filter grok过滤日志文件
Logstash提供了一系列filter过滤plugin来处理收集到的log event,根据log event的特征去切分所需要的字段,方便kibana做visualize和dashboard的da ...
- Logstash详解之——filter模块-grok插件
1. grok插件:能匹配一切数据,但是性能和对资源的损耗也很大. grok内置字段类型参见: https://blog.csdn.net/cui929434/article/details/9439 ...
- 使用logstash的input file filter收集日志文件
使用logstash的input file filter收集日志文件 一.需求 二.实现步骤 1.前置知识 2.编写pipeline文件 3.Input 中 file 插件的部分参数解释: 4.启动l ...
- ELK快速入门(二)通过logstash收集日志
ELK快速入门二-通过logstash收集日志 说明 这里的环境接着上面的ELK快速入门-基本部署文章继续下面的操作. 收集多个日志文件 1)logstash配置文件编写 [root@linux-el ...
- ELK 架构之 Elasticsearch、Kibana、Logstash 和 Filebeat 安装配置汇总(6.2.4 版本)
相关文章: ELK 架构之 Elasticsearch 和 Kibana 安装配置 ELK 架构之 Logstash 和 Filebeat 安装配置 ELK 架构之 Logstash 和 Filebe ...
- 170228、Linux操作系统安装ELK stack日志管理系统--(1)Logstash和Filebeat的安装与使用
安装测试环境:Ubuntu 16.04.2 LTS 前言 (1)ELK是Elasticsearch,Logstash,Kibana 开源软件的集合,对外是作为一个日志管理系统的开源方案.它可以从任何来 ...
随机推荐
- Google 商店:您的应用静态链接到的 OpenSSL 版本有多个安全漏洞。建议您尽快更新 OpenSSL
安全提醒 您的应用静态链接到的 OpenSSL 版本有多个安全漏洞.建议您尽快更新 OpenSSL. 在开头为 1.0.1h.1.0.0m和 0.9.8za的 OpenSSL 版本中这些漏洞已得到修复 ...
- 微服务实战-使用API Gateway
当你决定将应用作为一组微服务时,需要决定应用客户端如何与微服务交互.在单体式程序中,通常只有一组冗余的或者负载均衡的服务提供点.在微服务架构中,每一个微服务暴露一组细粒度的服务提供点.在本篇文章中,我 ...
- 如何生成项目的chm文档
如何生成项目的chm文档 2014-11-30 Generate .chm based documentation of your project using SandCastle tool
- Roslyn介绍
介绍 一般来说,编译器是一个黑箱,源代码从一端进入,然后箱子中发生一些奇妙的变化,最后从另一端出来目标文件或程序集.编译器施展它们的魔法,它们必须对所处理的代码进行深入的理解,不过相关知识不是每个人都 ...
- Java之旅hibernate(8)——基本关系映射
何为关系,何为映射,关系这个词想必大家都不陌生.比方你和老师之间是师生关系,你和父母之间是父子或者父女(母子或者母女关系). 关系是存在某种联系物体之间产生的.什么都是可能的.比方你和工具,你仅仅能使 ...
- spark读取本地文件
/** * Read a text file from HDFS, a local file system (available on all nodes), or any * Hadoop-supp ...
- jackson 不拼null节点的注解
http://blog.sina.com.cn/s/blog_544a7be401011url.html ——————————————————————————————————————————————— ...
- thinkphp中ajaxReturn的用法
1.例子: if ($codeid = $model->addCustomer($this->admin["id"])) { $data["code" ...
- sdut 2158:Hello World!(第一届山东省省赛原题,水题,穷举)
Hello World! Time Limit: 1000MS Memory limit: 65536K 题目描述 We know that Ivan gives Saya three problem ...
- 在ChemDraw中如何使用ChemACX
ChemACX是一款功能强大的化学品比价数据库,可与E-Notebook和ChemDraw整合使用,极大地方便生化科学家们采购化学品.那么很多用户就会开始疑惑该如何在ChemDraw化学绘图软件调用C ...