国产成人精品18p,天天干成人网,无码专区狠狠躁天天躁,美女脱精光隐私扒开免费观看

Linux日志對接Kibana如何進(jìn)行配置與部署

發(fā)布時(shí)間:2021-09-14 18:13 來(lái)源:億速云 閱讀:0 作者:chen 欄目: 服務(wù)器 歡迎投稿:712375056

本篇內容主要講解“Linux日志對接Kibana如何進(jìn)行配置與部署”,感興趣的朋友不妨來(lái)看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強。下面就讓小編來(lái)帶大家學(xué)習“Linux日志對接Kibana如何進(jìn)行配置與部署”吧!


一,準備工作

1,CVM及ElasticSearch

騰訊云帳號下,申請一臺CVM(Linux操作系統)、一個(gè)ElasticSearch集群(后面簡(jiǎn)稱(chēng)ES),使用最簡(jiǎn)配置即可;申請的CVM和ES,必須在同一個(gè)VPC的同一個(gè)子網(wǎng)下。

CVM詳情信息

ElasticSearch詳情信息

2,Filebeat工具

為了將Linux日志提取到ES中,我們需要使用Filebeat工具。Filebeat是一個(gè)日志文件托運工具,在你的上安裝客戶(hù)端后,Filebeat會(huì )監控日志目錄或者指定的日志文件,追蹤讀取這些文件(追蹤文件的變化,不停的讀),并且轉發(fā)這些信息到ElasticSearch或者logstarsh中存放。當你開(kāi)啟Filebeat程序的時(shí)候,它會(huì )啟動(dòng)一個(gè)或多個(gè)探測器(prospectors)去檢測你指定的日志目錄或文件,對于探測器找出的每一個(gè)日志文件,Filebeat啟動(dòng)收割進(jìn)程(harvester),每一個(gè)收割進(jìn)程讀取一個(gè)日志文件的新內容,并發(fā)送這些新的日志數據到處理程序(spooler),處理程序會(huì )集合這些事件,最后Filebeat會(huì )發(fā)送集合的數據到你指定的地點(diǎn)。

官網(wǎng)簡(jiǎn)介:https://www.elastic.co/products/beats/filebeat

二,操作步驟

1,Filebeat下載與安裝

首先,登錄待接管日志的CVM,在CVM上下載Filebeat工具:

[root@VM_3_7_centos ~]# cd /opt/
[root@VM_3_7_centos opt]# ll
total 4
drwxr-xr-x. 2 root root 4096 Sep  7  2017 rh
[root@VM_3_7_centos opt]# wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.2.2-x86_64.rpm
--2018-12-10 20:24:26--  https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.2.2-x86_64.rpm
Resolving artifacts.elastic.co (artifacts.elastic.co)... 107.21.202.15, 107.21.127.184, 54.225.214.74, ...
Connecting to artifacts.elastic.co (artifacts.elastic.co)|107.21.202.15|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 12697788 (12M) [binary/octet-stream]
Saving to: ‘filebeat-6.2.2-x86_64.rpm’

100%[=================================================================================================>] 12,697,788   160KB/s   in 1m 41s 

2018-12-10 20:26:08 (123 KB/s) - ‘filebeat-6.2.2-x86_64.rpm’ saved [12697788/12697788]

然后,進(jìn)行安裝filebeat:

[root@VM_3_7_centos opt]# rpm -vi filebeat-6.2.2-x86_64.rpm
warning: filebeat-6.2.2-x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID d88e42b4: NOKEY
Preparing packages...
filebeat-6.2.2-1.x86_64
[root@VM_3_7_centos opt]#

至此,Filebeat安裝完成。

2,Filebeat配置

進(jìn)入Filebeat配置文件目錄:/etc/filebeat/

[root@VM_3_7_centos opt]# cd /etc/filebeat/
[root@VM_3_7_centos filebeat]# ll
total 108
-rw-r--r-- 1 root root 44384 Feb 17  2018 fields.yml
-rw-r----- 1 root root 52193 Feb 17  2018 filebeat.reference.yml
-rw------- 1 root root  7264 Feb 17  2018 filebeat.yml
drwxr-xr-x 2 root root  4096 Dec 10 20:35 modules.d
[root@VM_3_7_centos filebeat]#

其中,filebeat.yml就是我們需要修改的配置文件。建議修改配置前,先備份此文件。

然后,確認需要對接ElasticSearch的Linux的日志目錄,我們以下圖(/var/log/secure)為例。

/var/log/secure日志文件

使用vim打開(kāi)/etc/filebeat/filebeat.yml文件,修改其中的:

1)Filebeat prospectors類(lèi)目中,enable默認為false,我們要改為true

2)paths,默認為/var/log/*.log,我們要改為待接管的日志路徑:/var/log/secure

3)Outputs類(lèi)目中,有ElasticSearchoutput配置,其中hosts默認為"localhost:9200",需要我們手工修改為上面申請的ES子網(wǎng)地址和端口,即**"10.0.3.8:9200"**。

修改好上述內容后,保存退出。

修改好的配置文件全文如下:

[root@VM_3_7_centos /]# vim /etc/filebeat/filebeat.yml
[root@VM_3_7_centos /]# cat /etc/filebeat/filebeat.yml
###################### Filebeat Configuration Example #########################

# This file is an example configuration file highlighting only the most common
# options. The filebeat.reference.yml file from the same directory contains all the
# supported options with more comments. You can use it as a reference.
#
# You can find the full configuration reference here:
# https://www.elastic.co/guide/en/beats/filebeat/index.html

# For more available modules and options, please see the filebeat.reference.yml sample
# configuration file.

#=========================== Filebeat prospectors =============================

filebeat.prospectors:

# Each - is a prospector. Most options can be set at the prospector level, so
# you can use different prospectors for various configurations.
# Below are the prospector specific configurations.

- type: log

  # Change to true to enable this prospector configuration.
  enabled: true

  # Paths that should be crawled and fetched. Glob based paths.
  paths:
    - /var/log/secure
    #- c:\programdata\elasticsearch\logs\*

  # Exclude lines. A list of regular expressions to match. It drops the lines that are
  # matching any regular expression from the list.
  #exclude_lines: ['^DBG']

  # Include lines. A list of regular expressions to match. It exports the lines that are
  # matching any regular expression from the list.
  #include_lines: ['^ERR', '^WARN']

  # Exclude files. A list of regular expressions to match. Filebeat drops the files that
  # are matching any regular expression from the list. By default, no files are dropped.
  #exclude_files: ['.gz$']

  # Optional additional fields. These fields can be freely picked
  # to add additional information to the crawled log files for filtering
  #fields:
  #  level: debug
  #  review: 1

  ### Multiline options

  # Mutiline can be used for log messages spanning multiple lines. This is common
  # for Java Stack Traces or C-Line Continuation

  # The regexp Pattern that has to be matched. The example pattern matches all lines starting with [
  #multiline.pattern: ^\[

  # Defines if the pattern set under pattern should be negated or not. Default is false.
  #multiline.negate: false

  # Match can be set to "after" or "before". It is used to define if lines should be append to a pattern
  # that was (not) matched before or after or as long as a pattern is not matched based on negate.
  # Note: After is the equivalent to previous and before is the equivalent to to next in Logstash
  #multiline.match: after


#============================= Filebeat modules ===============================

filebeat.config.modules:
  # Glob pattern for configuration loading
  path: ${path.config}/modules.d/*.yml

  # Set to true to enable config reloading
  reload.enabled: false

  # Period on which files under path should be checked for changes
  #reload.period: 10s

#==================== Elasticsearch template setting ==========================

setup.template.settings:
  index.number_of_shards: 3
  #index.codec: best_compression
  #_source.enabled: false

#================================ General =====================================

# The name of the shipper that publishes the network data. It can be used to group
# all the transactions sent by a single shipper in the web interface.
#name:

# The tags of the shipper are included in their own field with each
# transaction published.
#tags: ["service-X", "web-tier"]

# Optional fields that you can specify to add additional information to the
# output.
#fields:
#  env: staging


#============================== Dashboards =====================================
# These settings control loading the sample dashboards to the Kibana index. Loading
# the dashboards is disabled by default and can be enabled either by setting the
# options here, or by using the `-setup` CLI flag or the `setup` command.
#setup.dashboards.enabled: false

# The URL from where to download the dashboards archive. By default this URL
# has a value which is computed based on the Beat name and version. For released
# versions, this URL points to the dashboard archive on the artifacts.elastic.co
# website.
#setup.dashboards.url:

#============================== Kibana =====================================

# Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.
# This requires a Kibana endpoint configuration.
setup.kibana:

  # Kibana Host
  # Scheme and port can be left out and will be set to the default (http and 5601)
  # In case you specify and additional path, the scheme is required: http://localhost:5601/path
  # IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
  #host: "localhost:5601"

#============================= Elastic Cloud ==================================

# These settings simplify using filebeat with the Elastic Cloud (https://cloud.elastic.co/).

# The cloud.id setting overwrites the `output.elasticsearch.hosts` and
# `setup.kibana.host` options.
# You can find the `cloud.id` in the Elastic Cloud web UI.
#cloud.id:

# The cloud.auth setting overwrites the `output.elasticsearch.username` and
# `output.elasticsearch.password` settings. The format is `<user>:<pass>`.
#cloud.auth:

#================================ Outputs =====================================

# Configure what output to use when sending the data collected by the beat.

#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["10.0.3.8:9200"]

  # Optional protocol and basic auth credentials.
  #protocol: "https"
  #username: "elastic"
  #password: "changeme"

#----------------------------- Logstash output --------------------------------
#output.logstash:
  # The Logstash hosts
  #hosts: ["localhost:5044"]

  # Optional SSL. By default is off.
  # List of root certificates for HTTPS server verifications
  #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]

  # Certificate for SSL client authentication
  #ssl.certificate: "/etc/pki/client/cert.pem"

  # Client Certificate Key
  #ssl.key: "/etc/pki/client/cert.key"

#================================ Logging =====================================

# Sets log level. The default log level is info.
# Available log levels are: error, warning, info, debug
#logging.level: debug

# At debug level, you can selectively enable logging only for some components.
# To enable all selectors use ["*"]. Examples of other selectors are "beat",
# "publish", "service".
#logging.selectors: ["*"]

#============================== Xpack Monitoring ===============================
# filebeat can export internal metrics to a central Elasticsearch monitoring
# cluster.  This requires xpack monitoring to be enabled in Elasticsearch.  The
# reporting is disabled by default.

# Set to true to enable the monitoring reporter.
#xpack.monitoring.enabled: false

# Uncomment to send the metrics to Elasticsearch. Most settings from the
# Elasticsearch output are accepted here as well. Any setting that is not set is
# automatically inherited from the Elasticsearch output configuration, so if you
# have the Elasticsearch output configured, you can simply uncomment the
# following line.
#xpack.monitoring.elasticsearch:
[root@VM_3_7_centos /]#

執行下列命令啟動(dòng)filebeat

[root@VM_3_7_centos /]# sudo /etc/init.d/filebeat start
Starting filebeat (via systemctl):                         [  OK  ]
[root@VM_3_7_centos /]#

3,Kibana配置

進(jìn)入ElasticSearch對應的Kibana管理頁(yè),如下圖。

首次訪(fǎng)問(wèn)Kibana默認會(huì )顯示管理頁(yè)

首次登陸,會(huì )默認進(jìn)入Management頁(yè)面,我們需要將Index pattern內容修改為:filebeat-*,然后頁(yè)面會(huì )自動(dòng)填充**Time Filter field name,**不需手動(dòng)設置,直接點(diǎn)擊Create即可。點(diǎn)擊Create后,頁(yè)面需要一定時(shí)間來(lái)加載配置和數據,請稍等。如下圖:

將Index pattern內容修改為:filebeat-*,然后點(diǎn)擊Create

至此,CVM上,/var/log/secure日志文件,已對接到ElasticSearch中,歷史日志可以通過(guò)Kibana進(jìn)行查詢(xún),最新產(chǎn)生的日志也會(huì )實(shí)時(shí)同步到Kibana中。

三,實(shí)戰效果

日志接管已完成配置,如何使用呢?

如下圖:

在Index Patterns中可以看到我們配置過(guò)的filebeat-*

點(diǎn)擊Discover,即可看到secure中的所有日志,頁(yè)面上方的搜索框中輸入關(guān)鍵字,即可完成日志的檢索。如下圖(點(diǎn)擊圖片,可查看高清大圖):

使用Kibana進(jìn)行日志檢索

實(shí)際上,檢索只是Kibana提供的諸多功能之一,還有其他功能如可視化、分詞檢索等,還有待后續研究。

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自本網(wǎng)站內容采集于網(wǎng)絡(luò )互聯(lián)網(wǎng)轉載等其它媒體和分享為主,內容觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如侵犯了原作者的版權,請告知一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容,聯(lián)系我們QQ:712375056,同時(shí)歡迎投稿傳遞力量。

久久亚洲春色中文字幕久久久| 国产婷婷一区二区三区| 欧美高清熟妇啪啪内射不卡自拍| 国产成人AV无码精品| 亚洲制服丝中文字幕| 激情欧美成人久久综合|