elk笔记3--常用 API 命令

elk笔记3–常用 API 命令

1 cat API

  1. 查看别名
    http://h01:9200/_cat/aliases?v

    alias          index     filter routing.index routing.search
    website-alias  website3  -      -             -
    website-alias  website2  -      -             -
    .kibana        .kibana_2 -      -             -
    website-alias  website1  -      -             -
    website1-alias website1  -      -             -
    
  2. 查看每个节点shard分配情况
    GET /_cat/allocation/<node_id>
    GET /_cat/allocation
    http://h01:9200/_cat/allocation?v

    shards disk.indices disk.used disk.avail disk.total disk.percent host          ip            node
     41      997.1mb     8.4gb    231.6gb      240gb            3 10.120.75.107 10.120.75.107 node-3
     31      154.4mb    17.9gb      222gb      240gb            7 10.120.75.102 10.120.75.102 node-1
     41          1gb     8.3gb    231.6gb      240gb            3 10.120.75.103 10.120.75.103 node-2
    
  3. 查看集群或者特定索引的文档数量
    GET /_cat/count/
    GET /_cat/count
    http://h01:9200/_cat/count?v

    epoch      timestamp count
    1588599037 13:30:37  1991626
    
  4. 查看字段数据在每个节点上占用的堆内存
    GET /_cat/fielddata/
    GET /_cat/fielddata
    http://h01:9200/_cat/fielddata?v
    http://h01:9200/_cat/fielddata/type,_id?v

    id                     host          ip            node   field size
    zWJjoh1LSJ-P_XPkTdetYw 10.120.75.103 10.120.75.103 node-2 _id   592b
    8qn8oDjBSBqoYULO9djkrw 10.120.75.107 10.120.75.107 node-3 _id   592b
    8qn8oDjBSBqoYULO9djkrw 10.120.75.107 10.120.75.107 node-3 type   1kb
    
  5. 查看集群健康状态
    GET /_cat/health
    http://h01:9200/_cat/health?v

    epoch      timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
    1588599727 13:42:07  es6.8   green           3         3    113  56    0    0        0             0                  -                100.0%
    
  6. 查看集群中索引信息
    GET /_cat/indices/
    GET /_cat/indices
    http://h01:9200/_cat/indices/website1?v

    health status index    uuid                   pri rep docs.count docs.deleted store.size pri.store.size
    green  open   website1 kYg8F45lT3yynrQq560iLA   5   1          6            0     55.5kb         27.7kb
    
  7. 查看master节点信息
    GET /_cat/master
    http://h01:9200/_cat/master?v

    id                     host          ip            node
    8qn8oDjBSBqoYULO9djkrw 10.120.75.107 10.120.75.107 node-3
    
  8. 查看节点属性信息
    GET /_cat/nodeattrs
    http://h01:9200/_cat/nodeattrs?v

    node   host          ip            attr              value
    node-1 10.120.75.102 10.120.75.102 ml.machine_memory 67514142720
    node-1 10.120.75.102 10.120.75.102 ml.max_open_jobs  20
    node-1 10.120.75.102 10.120.75.102 xpack.installed   true
    node-1 10.120.75.102 10.120.75.102 ml.enabled        true
    ...
    
  9. 查看集群节点信息
    GET /_cat/nodes
    http://h01:9200/_cat/nodes?v

    ip            heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
    10.120.75.102           56          35   1    0.20    0.24     0.28 mdi       -      node-1
    10.120.75.103           65          22   0    0.38    0.41     0.43 mdi       -      node-2
    10.120.75.107           61          24   0    0.23    0.27     0.31 mdi       *      node-3
    
  10. 查看追加的任务(集群级别还没执行的任务)
    GET /_cat/pending_tasks
    http://h01:9200/_cat/pending_tasks?v
    此处借用官方数据

    insertOrder timeInQueue priority source
       1685       855ms HIGH     update-mapping [foo][t]
       1686       843ms HIGH     update-mapping [foo][t]
       1693       753ms HIGH     refresh-mapping [foo][[t]]
    
  11. 查看集群各节点安装插件信息
    GET /_cat/plugins
    http://h01:9200/_cat/plugins?v

    name   component       version
    node-1 repository-hdfs 6.8.8
    node-2 repository-hdfs 6.8.8
    node-3 repository-hdfs 6.8.8
    
  12. 查看已经完成或者正在进行的分配恢复信息
    GET /_cat/recovery/
    GET /_cat/recovery
    http://h01:9200/_cat/recovery/website1?v

    index    shard time  type stage source_host   source_node target_host   target_node repository snapshot files files_recovered files_percent files_total bytes bytes_recovered bytes_percent bytes_total translog_ops translog_ops_recovered translog_ops_percent
    website1 0     358ms peer done  10.120.75.103 node-2      10.120.75.107 node-3      n/a        n/a      1     1               100.0%        1           261   261             100.0%        261         0            0                      100.0%
    website1 0     809ms peer done  10.120.75.103 node-2      10.120.75.102 node-1      n/a        n/a      1     1               100.0%        1           261   261             100.0%        261         0            0                      100.0%
    website1 1     408ms peer done  10.120.75.107 node-3      10.120.75.103 node-2      n/a        n/a      4     4               100.0%        4           4788  4788            100.0%        4788        0            0                      100.0%
    website1 1     838ms peer done  10.120.75.107 node-3      10.120.75.102 node-1      n/a        n/a      4     4               100.0%        4           4788  4788            100.0%        
    ......
    
  13. 查看集群快照存储库
    GET /_cat/repositories
    http://h01:9200/_cat/repositories?v

    id                 type
    my_hdfs_repository hdfs
    
  14. 查看当前正在执行的任务
    GET /_cat/tasks
    http://h01:9200/_cat/tasks?v

    action                         task_id                        parent_task_id                type      start_time    timestamp running_time ip            node
    cluster:monitor/tasks/lists    WelixF57Rripol0FfarIwA:379411  -                             transport 1588601800360 14:16:40  314.6micros  10.120.75.102 node-1
    cluster:monitor/tasks/lists[n] zWJjoh1LSJ-P_XPkTdetYw:2433486 WelixF57Rripol0FfarIwA:379411 netty     1588601799976 14:16:39  72.9micros   10.120.75.103 node-2
    cluster:monitor/tasks/lists[n] 8qn8oDjBSBqoYULO9djkrw:2434452 WelixF57Rripol0FfarIwA:379411 netty     1588601799977 14:16:39  55.3micros   10.120.75.107 node-3
    cluster:monitor/tasks/lists[n] WelixF57Rripol0FfarIwA:379412  WelixF57Rripol0FfarIwA:379411 direct    1588601800360 14:16:40  67.5micros   10.120.75.102 node-1
    
  15. 查看集群中每个节点的线程池统计信息
    GET /_cat/thread_pool/<thread_pool>
    GET /_cat/thread_pool
    http://h01:9200/_cat/thread_pool?v

    node_name name                active queue rejected
    node-1    analyze                  0     0        0
    node-1    ccr                      0     0        0
    node-1    fetch_shard_started      0     0        0
    node-1    fetch_shard_store        0     0        0
    node-1    flush                    0     0        0
    node-1    force_merge              0     0        0
    node-1    generic                  0     0        0
    node-1    get                      0     0        0
    node-1    index                    0     0        0
    node-1    listener                 0     0        0
    node-1    management               1     0        0
    node-1    ml_autodetect            0     0        0
    node-1    ml_datafeed              0     0        0
    node-1    ml_utility               0     0        0
    node-1    refresh                  0     0        0
    node-1    rollup_indexing          0     0        0
    node-1    search                   0     0        0
    node-1    search_throttled         0     0        0
    node-1    security-token-key       0     0        0
    node-1    snapshot                 0     0        0
    node-1    warmer                   0     0        0
    node-1    watcher                  0     0        0
    node-1    write                    0     0        0
    node-2    analyze                  0     0        0
    ......
    
  16. 查看分片信息
    GET /_cat/shards/
    GET /_cat/shards
    http://h01:9200/_cat/shards/website1?v

    index    shard prirep state   docs  store ip            node
    website1 2     p      STARTED    3 13.5kb 10.120.75.103 node-2
    website1 2     r      STARTED    3 13.5kb 10.120.75.102 node-1
    website1 3     p      STARTED    1  4.6kb 10.120.75.107 node-3
    website1 3     r      STARTED    1  4.6kb 10.120.75.102 node-1
    website1 1     r      STARTED    1  4.6kb 10.120.75.103 node-2
    website1 1     p      STARTED    1  4.6kb 10.120.75.102 node-1
    website1 4     r      STARTED    1  4.6kb 10.120.75.107 node-3
    website1 4     p      STARTED    1  4.6kb 10.120.75.103 node-2
    website1 0     r      STARTED    0   261b 10.120.75.107 node-3
    website1 0     p      STARTED    0   261b 10.120.75.102 node-1
    
  17. 查看节点分片中Lucene 段信息
    GET /_cat/segments/
    GET /_cat/segments
    http://h01:9200/_cat/segments/website1?v

    index    shard prirep ip            segment generation docs.count docs.deleted  size size.memory committed searchable version compound
    website1 1     r      10.120.75.103 _1               1          1            0 4.3kb        1701 true      true       7.7.2   true
    website1 1     p      10.120.75.102 _1               1          1            0 4.3kb        1701 true      true       7.7.2   true
    website1 2     p      10.120.75.103 _1               1          1            0 4.3kb        1701 true      true       7.7.2   true
    website1 2     p      10.120.75.103 _4               4          1            0 4.3kb        1701 true      true       7.7.2   true
    website1 2     p      10.120.75.103 _5               5          1            0 4.3kb        1701 true      true       7.7.2   true
    website1 2     r      10.120.75.102 _1               1          1            0 4.3kb        1701 true      true       7.7.2   true
    website1 2     r      10.120.75.102 _4               4          1            0 4.3kb        1701 true      true       7.7.2   true
    website1 2     r      10.120.75.102 _5               5          1            0 4.3kb        1701 true      true       7.7.2   true
    website1 3     p      10.120.75.107 _3               3          1            0 4.3kb        1701 true      true       7.7.2   true
    website1 3     r      10.120.75.102 _3               3          1            0 4.3kb        1701 true      true       7.7.2   true
    website1 4     r      10.120.75.107 _1               1          1            0 4.3kb        1701 true      true       7.7.2   true
    website1 4     p      10.120.75.103 _1               1          1            0 4.3kb        1701 true      true       7.7.2   true
    
  18. 查看存储库的快照信息
    GET /_cat/snapshots/
    GET /_cat/snapshots/repo1?v&s=id
    此处借用官方数据

     id     status start_epoch start_time end_epoch  end_time duration indices successful_shards failed_shards total_shards
    snap1  FAILED 1445616705  18:11:45   1445616978 18:16:18     4.6m       1                 4             1            5
    snap2 SUCCESS 1445634298  23:04:58   1445634672 23:11:12     6.2m       2                10             0           10
    
  19. 查看集群中索引模板信息
    GET /_cat/templates/<template_name>
    GET /_cat/templates
    http://h01:9200/_cat/templates?v

    name                          index_patterns             order      version
    logstash-index-template       [.logstash]                0          
    .ml-meta                      [.ml-meta]                 0          6080899
    .ml-config                    [.ml-config]               0          6080899
    .monitoring-beats             [.monitoring-beats-6-*]    0          6070299
    .monitoring-kibana            [.monitoring-kibana-6-*]   0          6070299
    .triggered_watches            [.triggered_watches*]      2147483647 
    security-index-template       [.security-*]              1000       
    .ml-state                     [.ml-state*]               0          6080899
    .kibana_task_manager          [.kibana_task_manager]     0          6080899
    security_audit_log            [.security_audit_log*]     1000       
    .monitoring-es                [.monitoring-es-6-*]       0          6070299
    .watch-history-9              [.watcher-history-9*]      2147483647 
    .ml-anomalies-                [.ml-anomalies-*]          0          6080899
    .ml-notifications             [.ml-notifications]        0          6080899
    .watches                      [.watches*]                2147483647 
    .management-beats             [.management-beats]        0          67000
    .monitoring-logstash          [.monitoring-logstash-6-*] 0          6070299
    kibana_index_template:.kibana [.kibana]                  0          
    .monitoring-alerts            [.monitoring-alerts-6]     0          6070299
    

2 cluster API

  1. 查看集群状态
    GET _cluster/health/
    http://h01:9200/_cluster/health
    {
    “cluster_name”: “es6.8”,
    “status”: “green”,
    “timed_out”: false,
    “number_of_nodes”: 3,
    “number_of_data_nodes”: 3,
    “active_primary_shards”: 56,
    “active_shards”: 118,
    “relocating_shards”: 0,
    “initializing_shards”: 0,
    “unassigned_shards”: 0,
    “delayed_unassigned_shards”: 0,
    “number_of_pending_tasks”: 0,
    “number_of_in_flight_fetch”: 0,
    “task_max_waiting_in_queue_millis”: 0,
    “active_shards_percent_as_number”: 100.0
    }
  2. 查看集群设置
    GET /_cluster/settings
    http://h01:9200/_cluster/settings
    {
    “persistent”: {
    “xpack”: {
    “monitoring”: {
    “collection”: {
    “enabled”: “true”
    }
    }
    }
    },
    “transient”: {
    }
    }
  3. 查看xxx
    待补充

3 其它常用API

  1. 查看特定索引状态
    http://h01:9200/foodsite1/_stats?pretty

  2. 查看看查看节点上的索引状态
    /_nodes/node_ip/stats/indices
    http://h01:9200/_nodes/10.120.75.102/stats/indices

4 说明

测试 elk 版本为6.8.8
rest-apis

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

昕光xg

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值