1. 程式人生 > 遊戲 >《真女神轉生5》惡魔介紹:中國尊貴龍神黃龍

《真女神轉生5》惡魔介紹:中國尊貴龍神黃龍

參考:
【1】filebeat 配置檔案詳解https://blog.csdn.net/chengxuyuanyonghu/article/details/54378778
【2】ELK-filebeat 採集配置與實現https://blog.csdn.net/fd2025/article/details/80289499

一、Filebeat簡介
Filebeat是本地檔案的日誌資料採集器,可監控日誌目錄或特定日誌檔案(tail file),並將它們轉發給Elasticsearch或Logstatsh進行索引、kafka等。帶有內部模組(auditd,Apache,Nginx,System和MySQL),可通過一個指定命令來簡化通用日誌格式的收集,解析和視覺化。

二、安裝使用(windows和linux安裝包)
1.下載並解壓filebeat
下載地址:https://www.elastic.co/cn/downloads/beats/filebeat

2.編輯配置檔案filebeat.yml
filebeat 配置
採用YAML語言作為其配置語法。它的基本語法規則如下:

大小寫敏感
使用縮排表示層級關係
縮排時不允許使用Tab鍵,只允許使用空格
縮排的空格資料不重要,只要相同層級的元素左側對齊即可

# ============================== Filebeat inputs ===============================
filebeat.config.inputs:
  enable: 
true path: ${path.config}/input.yml reload.enabled: true reload.period: 2s # ============================== Filebeat modules ============================== filebeat.config.modules: path: ${path.config}/modules.d/*.yml reload.enabled: true reload.period: 10s # ======================= Elasticsearch template setting ======================= setup.template.settings: index.number_of_shards:
3 index.number_of_replicas: 1 # 允許自動生成index模板 setup.template.enabled: true # # 生成index模板時欄位配置檔案 setup.template.fields: fields.yml # # 如果存在模組則覆蓋 setup.template.overwrite: true # # 生成index模板的名稱 setup.template.name: "ops_log" # # 生成index模板匹配的index格式 setup.template.pattern: "ops-*" #索引生命週期管理ilm功能預設開啟,開啟的情況下索引名稱只能為filebeat-*, 通過setup.ilm.enabled: false進行關閉; setup.ilm.pattern: "{now/d}" setup.ilm.enabled: false # ================================== General =================================== # ---------------------------- Elasticsearch Output ---------------------------- output.elasticsearch: # Array of hosts to connect to. hosts: ["localhost:9200"] index: "%{[fields.source]}-*" indices: - index: "ops-systemlog-%{+yyyy.MM.dd}" when.equals: fields: source: "ops-systemlog" #- index: "opslog-operationlog-%{+yyyy.MM.dd}" - index: "ops-operationlog-%{+yyyy.MM.dd}" when.equals: fields: #source: "operationlog" source: "ops-operationlog" # ================================= Processors ================================= processors: #... - script: lang: javascript id: my_filter tag: enable source: > function process(event) { //提取時間值 var str= event.Get("message"); var time =str.split(" ").slice(0,2).join(" "); event.Put("start_time",time); } - timestamp: # 格式化時間值 給 時間戳 field: start_time layouts: - '2006-01-02 15:04:05' - '2006-01-02 15:04:05.999' test: - '2019-06-22 16:33:51'

input.yml

#filebeat.input:
- type: log

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

  # Paths that should be crawled and fetched. Glob based paths.
  paths:
    - E:\junxue\ELK_demo03\demo01\system*.txt
  tags: "c7f1771f-0c8f-4c75-9d71-3b8c4b6bd191"
  fields: 
    source: ops-systemlog
   #tags: ["GUID"]
    #- /var/log/*.log
    #- c:\programdata\elasticsearch\logs\*
  #include_l ines: ['^ERROR']
    
- type: log
  enabled: true
  paths: 
    - E:\junxue\ELK_demo03\demo02\operation*.txt
    #- E:\junxue\ELK_demo02\demo02\junxue*.txt
  tags: "c7f1771f-0c8f-4c75-9d71-3b8c4b6bd190"
  fields: 
    #source: operationlog
    source: ops-operationlog

3.啟動

linux

sudo ./filebeat -e -c filebeat.yml

window

.\filebeat.exe -e -c filebeat.yml

三、配置檔案詳細說明

filebeat:
  # List of prospectors to fetch data.
  prospectors:
 
      # 指定要監控的日誌,可以指定具體得檔案或者目錄
      paths:
        - /var/log/*.log  (這是預設的)(自行可以修改)(比如我放在/home/hadoop/app.log裡)
        #- c:\programdata\elasticsearch\logs\*
      # 指定被監控的檔案的編碼型別,使用plain和utf-8都是可以處理中文日誌的
      #encoding: plain
      # 指定檔案的輸入型別log(預設)或者stdin
      input_type: log   
      # 排除指定符合正則表示式的行 DEBUG TRACE INFO
      # exclude_lines: ["^DBG"]
      # 包含輸入中符合正則表示式列表的那些行(預設包含所有行),include_lines執行完畢之後會執行exclude_lines
      # 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$"]
      # 這個得意思就是會在es中多新增一個欄位,格式為 "filelds":{"level":"debug"}
      #fields:
      #  level: debug
      #  review: 1
      # true/false 額外欄位是否存放至根目錄
      #fields_under_root: false   
      # 設定Elasticsearch輸出時的document的type欄位 可以用來給日誌進行分類。Default: log
      #document_type: log
      # Filebeat以多快的頻率去prospector指定的目錄下面檢測檔案更新(比如是否有新增檔案)
      # 如果設定為0s,則Filebeat會盡可能快地感知更新(佔用的CPU會變高)。預設是10s
      #scan_frequency: 10s
 
      # 每個harvester監控檔案時,使用的buffer的大小
      #harvester_buffer_size: 16384
 
      # 日誌檔案中增加一行算一個日誌事件,max_bytes限制在一次日誌事件中最多上傳的位元組數,多出的位元組會被丟棄
      #max_bytes: 10485760
      #如果json 為多⾏格式時,指定⼀個root key,以進⾏標識
      #json.message_key:
       
       #false/true是否覆蓋beat中的欄位
       #json.overwrite_keys:false
       
       #false/true 解析失敗時是否儲存解析失敗資訊
       #json.add_error_key:false