1. 程式人生 > 實用技巧 >output模組外掛的詳細介紹

output模組外掛的詳細介紹

elaticserach外掛

  1. 常用引數說明:
    1. hosts:設elasticsearch的ip和埠
      1. 支援的格式:埠和http加不加都可以
      2. 如下格式都可以:
        1. hosts=>"192.168.57.100"
        2. hosts=>"192.168.57.100:9200"
        3. hosts=>"http://192.168.57.100"
        4. hosts=>["http://192.168.57.100:9200"]
        5. hosts=>["http://192.168.57.100:9200","http://192.168.57.110:9200"]
      3. 注意點:為了避免向主節點推送批量操作的請求,url只需要配置data node 和 client node
    2. index:事件最終要寫入的目標索引
    3. document_type:文件名稱,資料寫入該文件下面(在7.X以上版本不建議使用,8.X版本已經移除)
    4. document_id :設定資料在ES儲存時候的id,如果不設定ES會自動生成id(如果input為MySQL,則可以引用MySQL中的欄位作為id)
  2. 其他引數說明:
    1. 官方文件:https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html
    2. 參考文件:https://blog.csdn.net/qq330983778/article/details/106343363/
  3. 例項:
    output {
        elasticsearch {
            #es的ip和埠
            hosts => ["http://192.168.227.100:9200"]
            #ES索引名稱(自己定義的)
            index => "mdl_001_202001"
            #文件型別
            document_type => "MdL_001"
            #設定資料的id為資料庫中的欄位
            document_id => "%{trans_jnls_no}"
        }
    }