devops-13-elk

elasaticsearch

bookstack elasaticsearch 权威指南
可视化kibana
日志手机golang编写 安装csdn

接口

外部访问配置

修改 vi /etc/elasticsearch/elasticsearch.yml
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: ["host1", "host2"]

日志收集filebeat

filebeat参考csdn
filebeat

wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.7.0-linux-x86_64.tar.gz
配置示例文件:filebeat.reference.yml(包含所有未过时的配置项)
配置文件:filebeat.yml
#./filebeat test config
Config OK
./filebeat -c filebeat.yml  test config

vi filebeat.yml
enabled: true
name: xx.xx.xx.250_filebeat
配置elsaticsearch 服务器地址
output.elasticsearch
   hosts: ["xx.xx.xx.xx:9200","xx.xx.xx.xx:9200"]

./filebeat -e   #启动filebeat
nohup ./filebeat -c filebeat.yml >/dev/null 2>&1 &




获取文档数量

查询所有索引

  • http://xx.xx.xx.250:9200/_cat/indices
curl -XGET 'http://localhost:9200/_count?pretty' -d '
{
    "query": {
        "match_all": {}
    }
}
'

创建用户

http://xx.xx.xx.250:9200/megacorp/employee/5

  • megacorp 索引名
  • employee 类型名
  • 用户id
检索用户
http://xx.xx.xx.xx:9200/megacorp/employee/1
  • 简单搜索 /megacorp/employee/_search
  • 检索标签 /megacorp/employee/_search?q=last_name:Smith

DSL查询

Query Dsl 构建更加复杂强大的查询
使用match语句
年龄大于30 增加过滤器

GET /megacorp/employee/_search
{
    "query" : {
        "filtered" : {
            "filter" : {
                "range" : {
                    "age" : { "gt" : 30 } <1>
                }
            },
            "query" : {
                "match" : {
                    "last_name" : "smith" <2>
                }
            }
        }
    }
}
  • 全文检索
GET /megacorp/employee/_search
{
    "query" : {
        "match" : {
            "about" : "rock climbing"
        }
    }
}

基础

安装

docker pull elasticsearch
启动参考
https://hub.docker.com/_/elasticsearch
官方参考命令
docker network create somenetwork

docker run -d --name elasticsearch --net somenetwork -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:tag

docker run -d --name elasticsearch  -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:latest

docker logs xxx
http://xx.xx.xx.250:9200/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值