美文网首页
ELK常见命令

ELK常见命令

作者: junpassion | 来源:发表于2018-09-03 17:08 被阅读63次

ELK中常见的命令整理如下:

ES
说明:REST API调用方式为 <REST Verb> /<Index>/<Type>/<ID>

  • 查看ES中的index信息: GET /_cat/indices?v

  • 查看集群的健康状态: GET /_cat/health?v

  • 查看集群的节点信息: GET /_cat/nodes?v

  • 创建index:

PUT /customer?pretty
{
  "acknowledged": true,
  "shards_acknowledged": true,
  "index": "customer"
}
PUT /customer/_doc/1?pretty
{
  "name": "xi dada"
}
  • 删除index:
DELETE /customer?pretty
DELETE /customer/_doc/1?pretty
  • 更新index:
POST /customer/_doc/1/_update?pretty
{
  "doc": {"name":"wang FengFeng", "age":28}
}
POST /customer/_doc/1/_update?pretty
{
  "script": "ctx._source.age += 3"
}
  • 查询index信息:
    GET /customer/_doc/2?pretty
    GET /kafka-snail/_search?pretty&q=* 某个index中所有的记录
  • 复杂查询index信息+条件:
GET /bank/_search?q=*&sort=account_number:asc&pretty
GET /bank/_search
{
  "query": { "match_all": {} },
  "sort": [
    { "account_number": "asc" }
  ]
}
// 指定查询结果的大小和起始位置
GET /bank/_search
{
  "query": {"match_all": {}},
  "_source": ["account_number","balance"], 
  "sort": [
    { "account_number": "asc" },
    {"balance": "desc"}
  ],
  "from":10,
  "size": 5
}
// 指定多个查询条件,包含与、或、非
GET /bank/_search
{
  "query": { 
    "bool": { 
      "must":[
        {"match":{"address":"mill"}},
        {"match":{"gender":"M"}}
      ],
      "must_not":[
        {"match":{"state":"IL"}}
        ],
      "should": [
        {"match": {"city": "Lopezo"}},
        {"match": {"city": "Urie"}}
      ]
    }
  }
}
//使用where条件,限定字段的范围
GET /bank/_search
{
  "query": {
    "bool": {
      "must": { "match": {"gender":"M"} },
      "filter": {
        "range": {
          "balance": {
            "gte": 20000,
            "lte": 23000
          }
        }
      }
    }
  }
}
// 批量操作
POST /customer/_doc/_bulk?pretty
  {"index":{"_id":"1"}}
  {"name":"John legend"}
  {"index":{"_id":"2"}}
  {"name":"wang jun"}

POST /customer/_doc/_bulk?pretty
{"update":{"_id":"1"}}
{"doc":{"name":"John legend become mengmeng"}}
{"delete":{"_id":"2"}}
  • 按indices查看缓存 GET /_stats/request_cache?human
  • 按节点查看缓存 GET /_nodes/stats/indices/request_cache?human
  • 清理多个index的缓存 POST /index1,inex2/_cache/clear?request=true

Logstash:

  • 查看logstash使用的插件信息和版本
    ./bin/logstash-plugin list --verbose
  • 卸载logstash使用的某个xx插件
    ./bin/logstash-plugin remove xx
  • logstash安装指定版本的插件
    ./bin/logstash-plugin install --version 8.0.6 xx 例如:./bin/logstash-plugin install --version 8.0.6 logstash-input-kafka
  • 简单控制台输入输出
    ./bin/logstash -e 'input { stdin {}} output { stdout { } }'
  • 配置好Logstash.conf,检查其配置项
    ./bin/logstash -f logstash.conf --config.test_and_exit
  • 配置好Logstash.conf,检查其配置项
    ./bin/logstash -f logstash.conf --config.test_and_exit
  • 启动logstash,当配置文件修改时,可自动加载
    ./bin/logstash -f logstash.conf --config.reload.automatic
  • logstash读取kafka数据存入到ES中的配置kafka-logstash.conf
input {
     kafka {
        bootstrap_servers => "10.194.xxx.yyy:9092,10.xxx.yyy.18:9092,10.xxx.yyy.180:9092"
        auto_offset_reset => "earliest"
        group_id => "logstash23"
    id => "8.0.6"
        client_id => "logstash-5"
        check_crcs => "false"
    topics => ["mda.online"]
        }
}
filter {
    grok {
        match => { "message" => "%{COMBINEDAPACHELOG}"}
    }
    geoip {
        source => "clientip"
    }
}
output {
      stdout { }   //会打印出信息
      elasticsearch {
                hosts => "esIp:9200"
                index => "kafka-snail"
        template_overwrite => true
        } 
}

参考文献

相关文章

  • ELK常见命令

    ELK中常见的命令整理如下: ES说明:REST API调用方式为 / // ...

  • elasticsearch常用命令

    常用命令(ELK版本7.6.2)

  • 7,总结单机版ELK安装以及简单应用

    接到上峰命令,产品要上ELK,遂就有了这篇文章 ELK介绍 网上copy的:ELK是三个开源软件的缩写,分别表示:...

  • 1,ELK介绍

    接到上峰命令,产品要上ELK,遂就有了这篇文章 ELK介绍 网上copy的:ELK是三个开源软件的缩写,分别表示:...

  • DBA课程-day20-ELK第二天

    ELK第一天知识回顾 ELK第二天内容 大家的索引命令方案 大家开会讨论筛选之后合理的索引命名 为什么filebe...

  • Firewall 常用端口

    安装Firewall命令: Firewall开启常见端口命令: Firewall关闭常见端口命令: 批量添加区间端...

  • 初识命令行之ls cat mv touch

    目录:一. 如何查找命令行的常见用法二. 几个命令行的常见用法三. 如何查找命令行释义 一.如何查找命令行的常见用...

  • ipython 魔术命令

    魔术命令:以%为前缀的命令,是ipython的特殊命令,方便完成常见的任务。,常见的魔术命令有:%run,%pas...

  • 一些常见的命令行

    一些常见的命令行 - 常见的自带命令 explainshell.com的用法 对于常见的命令行我们很容易能记住他们...

  • Docker下ELK设置

    1获取、启动elk 1.1获取elk镜像 $ docker pull sebp/elk 1.2启动elk镜像 启动...

网友评论

      本文标题:ELK常见命令

      本文链接:https://www.haomeiwen.com/subject/gqliwftx.html