elasticsearch,filebeat,kibana部署,添加图表及elastalert报警(代码片段)

放飞 放飞     2022-11-16     624

关键词:

服务端安装

Elasticsearch和Kibana(需要安装openjdk1.8以上)

安装方法:https://www.elastic.co
以Ubuntu为例:

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
sudo apt-get install apt-transport-https
echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list
apt-get update
apt-get install elasticsearch
apt-get install kibana

elasticsearch配置

cat /etc/elasticsearch/elasticsearch.yml

path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 172.16.80.28
http.port: 9200
discovery.zen.ping.unicast.hosts: ["172.16.80.28","172.16.80.155"]

附件有文件elasticsearch.map

Kibana配置

cat /etc/kibana/kibana.yml

server.port: 5601
server.host: "172.16.80.28"
elasticsearch.url: "http://172.16.80.28:9200"

Elastalert(需要Python2.7)

下载 https://github.com/Yelp/elastalert/releases

进入elastalert目录

pip install -r requirements.txt
python setup.py install
elastalert-create-index

前台运行elastalert

python -m elastalert.elastalert --verbose --rule rules/my_rule.yaml

安装参考:
https://elastalert.readthedocs.io/en/latest/running_elastalert.html#downloading-and-configuring
https://blog.csdn.net/df007df/article/details/54773391

elastalert配置

cat /etc/elastalert/rules/my_rule.yaml

es_host: 172.16.80.28
es_port: 9200
name: filebeat rules
type: frequency
index: filebeat*
num_events: 5
timeframe:
  hours: 1
filter:
- query:
    query_string:
      query: "message: *error*"
alert:
- "email"
email:
- "[email protected]"
- "[email protected]"
alert_text: "Ref Log http://172.16.80.28:5601/app/kibana"
smtp_host: smtp.exmail.qq.com
smtp_port: 25
smtp_ssl: false
smtp_auth_file: /etc/elastalert/rules/smtp_auth_file.yaml
from_addr:  [email protected]

cat /etc/elastalert/rules/smtp_auth_file.yaml

user: "[email protected]"
password: "邮箱密码"  

cat /etc/elastalert/config.yaml

rules_folder: /etc/elastalert/rules
run_every:
  minutes: 1
buffer_time:
  minutes: 15
es_host: 172.16.80.28
es_port: 9200
s_url_prefix: elasticsearch
writeback_index: elastalert_status
alert_time_limit:
  days: 2  

elastalert配置注解

rules_folder:用来加载下一阶段rule的设置,默认是example_rules
run_every:用来设置定时向elasticsearch发送请求
buffer_time:用来设置请求里时间字段的范围,默认是45分钟
es_host:elasticsearch的host地址
es_port:elasticsearch 对应的端口号
use_ssl:可选的,选择是否用SSL连接es,true或者false
es_username:es认证的username
es_password:es认证的password
writeback_index:elastalert产生的日志在elasticsearch中的创建的索引
alert_time_limit:失败重试的时间限制

告警参考
https://blog.csdn.net/gamer_gyt/article/details/52917116
https://elastalert.readthedocs.io/en/latest/ruletypes.html

客户端安装

Filebeat安装

以Ubuntu为例:

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
sudo apt-get install apt-transport-https
echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list
apt-get update
apt-get install filebeat

filebeat配置

cat /etc/filebeat/filebeat.yml

filebeat.prospectors:
- type: log
  enabled: true
  paths:
    - /var/log/nginx/*.log
  path: $path.config/modules.d/*.yml
  reload.enabled: false
setup.template.settings:
  index.number_of_shards: 3
setup.kibana:
  host: "172.16.80.28:5601"
output.elasticsearch:
  hosts: ["172.16.80.28:9200"]

EFK备注

日志位置 /var/lib/elasticsearch/nodes/
日志大小 暂时为345Mb
日志轮循 暂时不知道在哪设置

elasticsearch.map内容

技术分享图片
# uint mapping

   "settings" : 
      "index" : 
         "number_of_replicas" : 1,
         "number_of_shards" : 5
      
   ,
   "mappings" : 
      "values" : 
         "properties" : 
            "itemid" : 
               "type" : "long"
            ,
            "clock" : 
               "format" : "epoch_second",
               "type" : "date"
            ,
            "value" : 
               "type" : "long"
            
         
      
   

 
# dbl mapping

   "settings" : 
      "index" : 
         "number_of_replicas" : 1,
         "number_of_shards" : 5
      
   ,
   "mappings" : 
      "values" : 
         "properties" : 
            "itemid" : 
               "type" : "long"
            ,
            "clock" : 
               "format" : "epoch_second",
               "type" : "date"
            ,
            "value" : 
               "type" : "double"
            
         
      
   

 
# str mapping

   "settings" : 
      "index" : 
         "number_of_replicas" : 1,
         "number_of_shards" : 5
      
   ,
   "mappings" : 
      "values" : 
         "properties" : 
            "itemid" : 
               "type" : "long"
            ,
            "clock" : 
               "format" : "epoch_second",
               "type" : "date"
            ,
            "value" : 
               "fields" : 
                  "analyzed" : 
                     "index" : true,
                     "type" : "text",
                     "analyzer" : "standard"
                  
               ,
               "index" : false,
               "type" : "text"
            
         
      
   

 
# text mapping

   "settings" : 
      "index" : 
         "number_of_replicas" : 1,
         "number_of_shards" : 5
      
   ,
   "mappings" : 
      "values" : 
         "properties" : 
            "itemid" : 
               "type" : "long"
            ,
            "clock" : 
               "format" : "epoch_second",
               "type" : "date"
            ,
            "value" : 
               "fields" : 
                  "analyzed" : 
                     "index" : true,
                     "type" : "text",
                     "analyzer" : "standard"
                  
               ,
               "index" : false,
               "type" : "text"
            
         
      
   

 
# log mapping

   "settings" : 
      "index" : 
         "number_of_replicas" : 1,
         "number_of_shards" : 5
      
   ,
   "mappings" : 
      "values" : 
         "properties" : 
            "itemid" : 
               "type" : "long"
            ,
            "clock" : 
               "format" : "epoch_second",
               "type" : "date"
            ,
            "value" : 
               "fields" : 
                  "analyzed" : 
                     "index" : true,
                     "type" : "text",
                     "analyzer" : "standard"
                  
               ,
               "index" : false,
               "type" : "text"
            
         
      
   
View Code

 








filebeat+logstash+elasticsearch+granfa(代码片段)

filebeat+logstash+elasticsearch+granfahttps://www.cnblogs.com/wenchengxiaopenyou/p/9034213.html一。背景前端web服务器为nginx,采用filebeat+logstash+elasticsearch+granfa进行数据采集与展示,对客户端ip进行地域统计,监控服务器响应时间等。二。业务整体架... 查看详情

elk做日志分析(filebeat+logstash+elasticsearch)配置(代码片段)

...Filebeat去读取日志发送到Logstash,再由Logstash处理后发送给Elasticsearch。一、Filebeat项目日志文件:利用Filebeat去读取文件,paths下面配置路径地址,Filebeat会自动去读取/data/share/business_log/TA-*/debug.log文件#===========================Filebeatprosp 查看详情

filebeat+logstash+elasticsearch收集haproxy日志

...,传输到kafka,在用logstash从消息队列中抓取日志存储到elasticsearch中。但是在5.5版本中,使用filebeat收集日志,减少对客户机的性能影响,filebeat收集日志传输到logstash的5044端口,logstash接收日志,然后传输 查看详情

使用elasticsearch和filebeat做日志收集

在存储数据之前,elasticsearch可以使用IngestNode对数据做预处理。https://www.elastic.co/guide/en/beats/filebeat/current/configuring-ingest-node.html1使用ingest功能1.1定义一个pipeline例如grib2-pipeline.jsongrok可以使用预定义Patterns(%Patte 查看详情

日志分析系统elk(elasticsearch+logstash+kibana+filebeat)

...装Filebeat​​​​五、集群模式​​搭建日志分析系统ELK(elasticsearch+logstash+kibana+filebeat)这里先介绍ELK的安装 首先下载ELK在官网下载:​​https://www.elastic.co/cn/downloads/​ 查看详情

windows下elk安装配置-elasticsearch/kibana/filebeat(代码片段)

以8.6.2为例,下载地址elasticsearch:https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.6.2-windows-x86_64.zipkibana:https://artifacts.elastic.co/downloads/kibana/kibana-8.6.2-windows-x86_64.zipfilebeat:https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-8.6.... 查看详情

elk(elasticsearch+filebeat+kibana)轻量级采集分析nginx日志(代码片段)

ELK是什么?轻量级日志统计分析组件,包含elasticsearch、filebeat、kibanaELK环境准备Elasticsearch下载地址https://www.elastic.co/downloads/past-releases/elasticsearch-6-4-2Elasticsearch参考文档https://www.elastic.co/guide/en/elasticsearch/reference/current/index... 查看详情

elk(elasticsearch+filebeat+kibana)轻量级采集分析nginx日志(代码片段)

ELK是什么?轻量级日志统计分析组件,包含elasticsearch、filebeat、kibanaELK环境准备Elasticsearch下载地址https://www.elastic.co/downloads/past-releases/elasticsearch-6-4-2Elasticsearch参考文档https://www.elastic.co/guide/ 查看详情

2021年大数据elk(十九):使用filebeat采集kafka日志到elasticsearch(代码片段)

...家回顾前面的知识重点。目录使用FileBeat采集Kafka日志到Elasticsearch一、需求分析二、配置FileBeats1、input配置2、output配置三、配置文件1、创建配置文件2、复制一下到配置文件中四、运行FileBeat1、运行FileBeat2、将日志数据上传到/var... 查看详情

efk教程-efk快速入门指南

参考技术A通过部署elasticsearch(三节点)+filebeat+kibana快速入门EFK,并搭建起可用的demo环境测试效果▪用途▪实验架构▪EFK软件安装▪elasticsearch配置▪filebeat配置▪kibana配置▪启动服务▪kibana界面配置▪... 查看详情

filebeat配置输出

参考技术A1、配置Elasticsearchoutput当你指定Elasticsearch作为output时,Filebeat通过Elasticsearch提供的HTTPAPI向其发送数据。例如:output.elasticsearch:hosts:["https://localhost:9200"]index:"filebeat-%[beat.version]-%+yyyy.MM.dd"ssl.certificate_authorit... 查看详情

通过filebeat把日志传入到elasticsearch(代码片段)

...文件中预先处理字段数据的用法通过Filebeat把日志传入到ElasticsearchElasticStack被称之为ELK(Elasticsearch,LogstashandKibana)。由于beats的加入,现在很多人把ELK说成为ELKB。这里的B就是代表Beats。Beats在Elasticsearch中扮演很重要的角色。Beats... 查看详情

如何使用filebeat读取json文件并通过logstash发送到elasticsearch

】如何使用filebeat读取json文件并通过logstash发送到elasticsearch【英文标题】:Howtoreadjsonfileusingfilebeatandsendittoelasticsearchvialogstash【发布时间】:2019-10-3117:24:48【问题描述】:这是我的json日志文件。我正在尝试通过我的logstash将文件... 查看详情

错误:在 Chart.yaml 中找到,但在 charts/ 目录中缺失:elasticsearch、kibana、filebeat、logstash

】错误:在Chart.yaml中找到,但在charts/目录中缺失:elasticsearch、kibana、filebeat、logstash【英文标题】:Error:foundinChart.yaml,butmissingincharts/directory:elasticsearch,kibana,filebeat,logstash【发布时间】:2020-12-0219:13:19【问题描述】:我想将弹性... 查看详情

filebeat+kafka+logstash+elasticsearch+kibana日志采集方案(代码片段)

...格式的数据。其实Beats和Logstash的功能差不多,都能够与Elasticsearch产生协同作用,而且logstash比filebeat功能更强大一点,2个都使用是因为:Beats是一个轻量级的采集器,支持从边缘机器向Logstash和Elasticsearch发送数据。考虑到Logstash... 查看详情

filebeat+elasticsearch+logstash+kibana收集系统日志(docker)

参考技术A我们这里用到的是filebeat+elk(elasticsearch+logstash+kibana)来进行系统日志的收集。filebeat安装在各个服务器中,Logstash+ElasticSearch+Kibana安装在一台专门用于基础服务的服务器上。Filebeat是一个轻量级的托运人,用于转发和集中... 查看详情

elasticsearch,filebeat,kibana部署,添加图表及elastalert报警(代码片段)

服务端安装Elasticsearch和Kibana(需要安装openjdk1.8以上)安装方法:https://www.elastic.co以Ubuntu为例:wget-qO-https://artifacts.elastic.co/GPG-KEY-elasticsearch|sudoapt-keyadd-sudoapt-getinstallapt-transport-httpsecho"debh 查看详情

filebeat向elasticsearch传入数据,并使用grok处理

参考技术A最近在捣鼓Filebeat监听springboot的日志然后将其传入到es中。这个时候日志肯定要切分单独字段存储。这个时候用到了es自带的ingestnodepipeline功能,使用grok使用正则将log进行切分参考资料:https://www.elastic.co/guide/en/beats/file... 查看详情