ELK运维之路(Logstash测试案例1)

这个是在部署elk过程中操作的,这里作为工作留档,比较粗糙只是为了测试下各个模块的使用。具体测试环境在前面已经发布,另外这里需要给Docker-compose中logstash开放7777和8888端口

1.综合案例图

null

2.Logstash配置

ini 复制代码
root@ubuntu2204test99:~/elkf/logstash/pipeline# pwd
/root/elkf/logstash/pipeline
root@ubuntu2204test99:~/elkf/logstash/pipeline# cat logstash.conf
input {
  beats {
    # 自定义一个类型,使Logstash可以进行判断处理
    type => "soure-bates"
    port => 7777
  }
  tcp {
    type => "soure-tcp"
    port => 8888
  }
  redis {
    type => "soure-redis"
    data_type => "list"  
    db => 5 
    host => "192.168.1.47"
    port => "6379"
    password => "123456"
    key => "filebeat-log"
  }
}
output {
  stdout {}
  if [type] == "soure-bates"{
    elasticsearch {
        hosts => ["192.168.1.99:9201","192.168.1.99:9202","192.168.1.99:9203"]
        user => "elastic"
        password => "123456"
        index => "soure-bates-%{+yyyy.MM.dd}"
    }
  } else if [type] == "soure-tcp" {
    elasticsearch {
        hosts => ["192.168.1.99:9201","192.168.1.99:9202","192.168.1.99:9203"]
        user => "elastic"
        password => "123456"
        index => "soure-tcp-%{+yyyy.MM.dd}"
    }
  } else if [type] == "soure-redis"{
      elasticsearch {
        hosts => ["192.168.1.99:9201","192.168.1.99:9202","192.168.1.99:9203"]
        user => "elastic"
        password => "123456"
        index => "soure-redis-%{+yyyy.MM.dd}"
    }
  } else {
      elasticsearch {
        hosts => ["192.168.1.99:9201","192.168.1.99:9202","192.168.1.99:9203"]
        user => "elastic"
        password => "123456"
        index => "soure-other-%{+yyyy.MM.dd}"
    }
  }
}

3.Filebeat配置(TCP)

ruby 复制代码
root@ubuntu2204test99:/usr/local/filebeat-7.17.24# pwd
/usr/local/filebeat-7.17.24
root@ubuntu2204test99:/usr/local/filebeat-7.17.24# cat filebeat-tcp-logstatsh-es.yml

# Filebeat tcp配置,监听tcp9000断后来的信息并写入到logstash
filebeat.inputs:
- type: tcp
  host: "0.0.0.0:9001"

output.logstash:
  hosts: ["192.168.1.99:7777"]


# Filebeat启动命令
root@ubuntu2204test99:/usr/local/filebeat-7.17.24# ./filebeat -e -c filebeat-tcp-logstatsh-es.yml --path.data /tmp/filebeat01/

# 测试命令
root@ubuntu2204test99:~/elkf/logstash/pipeline# echo "this is filebeat 9001" |nc 192.168.1.99 9001
null

4.Filebeat配置(Redis)

ruby 复制代码
root@ubuntu2204test99:/usr/local/filebeat-7.17.24# pwd
/usr/local/filebeat-7.17.24
root@ubuntu2204test99:/usr/local/filebeat-7.17.24# cat filebeat-redis-logstatsh-es.yml
filebeat.inputs:
- type: tcp
  host: "0.0.0.0:9000"

output.redis:
  hosts: ["192.168.1.47:6379"]
  password: "123456"
  key: "filebeat-log"
  db: 5 # 数据库编号
  timeout: 5

# Filebeat启动命令  
root@ubuntu2204test99:/usr/local/filebeat-7.17.24# ./filebeat -e -c filebeat-redis-logstatsh-es.yml --path.data /tmp/filebeat02/

# 测试命令
root@ubuntu2204test99:~/elkf/logstash/pipeline# echo "this is redis 9000" |nc 192.168.1.99 9000
null

5.nc直接向Logstash写入

ruby 复制代码
root@ubuntu2204test99:/usr/local/filebeat-7.17.24# echo 'hello this is nc to logstash 8888' |nc 192.168.1.99 8888
null

6.建立索引模式查看数据

null
null
null
null
null
相关推荐
Elastic 中国社区官方博客2 小时前
开始使用 Elastic Agent Builder 和 Strands Agents SDK
大数据·人工智能·elasticsearch·搜索引擎·ai·全文检索
Elasticsearch3 小时前
Elasticsearch:在分析过程中对数字进行标准化
elasticsearch
武子康4 小时前
大数据-186 Logstash JDBC vs Syslog Input:原理、场景对比与可复用配置(基于 Logstash 7.3.0)
大数据·后端·logstash
微扬嘴角5 小时前
Springcloud篇9-Elasticsearch-3(数据聚合、自动补全、数据同步、集群)
elasticsearch·spring cloud
真上帝的左手5 小时前
13. 搜索引擎-ES-ES集群
elasticsearch·搜索引擎·jenkins
济南java开发,求内推5 小时前
ES升级至:8.15.3
elasticsearch
真上帝的左手5 小时前
13. 搜索引擎-ES-自动补全
elasticsearch·搜索引擎
真上帝的左手5 小时前
13. 搜索引擎-ES-DSL(Domain Specific Language)
elasticsearch·搜索引擎·数学建模
AI逐月19 小时前
Git 彻底清除历史记录
大数据·git·elasticsearch
管理大亨1 天前
ELK + Redis Docker 企业级部署落地方案
大数据·运维·elk·elasticsearch·docker·jenkins