久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

Linux下如何安裝Logstash

瀏覽:3日期:2023-09-23 20:55:12
目錄一、安裝Logstash1.解壓tar包2.配置config目錄下的logstash.conf3.啟動(dòng)命令4.查看Logstash是否啟動(dòng)成功 二、配置應(yīng)用項(xiàng)目的logback環(huán)境1.在pom.xml中添加Logstash依賴2.在resouces目錄下添加logback-spring.xml三、在kibana界面查看數(shù)據(jù)1.查看索引管理2.配置索引模式總結(jié)一、安裝Logstash1.解壓tar包c(diǎn)d /data/app/elk/elk-6.8.5tar zxvf logstash-6.8.5.tar.gz2.配置config目錄下的logstash.conf# 數(shù)據(jù)輸入部分input { # 讀取nginx訪問(wèn)日志 file {#path:監(jiān)聽文件的路徑,絕對(duì)路徑path => '/data/app/nginx/logs/access.log' #為Nginx的access.log路徑# 格式:jsoncodec => 'json'#start_position:監(jiān)聽文件的起始位置,beginning:從文件的頭開始讀取start_position => 'beginning'#type:自定義類型type => 'nginx-access-log' } # 讀取nginx異常日志 file {path => '/data/app/nginx/logs/error.log' #為Nginx的error.log路徑# 格式:plain,輸入的是字符串,輸出把全部?jī)?nèi)容放到message字段codec => 'plain'start_position => 'beginning'type => 'nginx-error-log' }#filebeats方式beats {port => 5044type => 'beats_log'}#自定義端口,一個(gè)項(xiàng)目可對(duì)應(yīng)一個(gè)自定義tcp端口接收數(shù)據(jù)tcp {mode => 'server'host => '192.168.X.X' #IP地址port => 21022codec => jsontype => 'application-log' #application一般為項(xiàng)目名稱}}# 數(shù)據(jù)處理部分filter{if[type] == 'application-log'{mutate {rename => {'host' => 'hostname'}}}}# 數(shù)據(jù)輸出部分output { # beat監(jiān)控信息if [type] == 'beats_log'{elasticsearch { hosts => ['192.168.X.X:9200']manage_template => falseindex => '%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}' user => 'elastic' password => 'elastic2021'}} # nginx訪問(wèn)日志 if[type] == 'nginx-access-log' {elasticsearch { hosts => ['192.168.X.X:9200'] index => 'nginx-access-log-%{+YYYY.MM.dd}' # elasticsearch的用戶名、密碼 user => 'elastic' password => 'elastic2021'} } # nginx異常日志 if[type] == 'nginx-error-log'{elasticsearch{ hosts => ['192.168.X.X:9200'] index => 'nginx-error-log-%{+YYYY.MM.dd}' user => 'elastic' password => 'elastic2021'} }# 應(yīng)用系統(tǒng)日志if[type] == 'application-log'{elasticsearch {hosts => ['192.168.X.X:9200'] index => 'application-log-%{+YYYY.MM.dd}'user => 'elastic'password => 'elastic2021'}}}3.啟動(dòng)命令cd /data/app/elk/elk-6.8.5/logstash-6.8.5nohup ./bin/logstash -f config/logstash.conf &4.查看Logstash是否啟動(dòng)成功ps -ef | grep logstash

二、配置應(yīng)用項(xiàng)目的logback環(huán)境1.在pom.xml中添加Logstash依賴<!-- logstash 6.2 --><dependency> <groupId>net.logstash.logback</groupId> <artifactId>logstash-logback-encoder</artifactId> <version>6.2</version></dependency>2.在resouces目錄下添加logback-spring.xml<?xml version='1.0' encoding='UTF-8' ?><configuration debug='false'><!-- 為logstash輸出的JSON格式的Appender --><appender name='logstash_dev' class='net.logstash.logback.appender.LogstashTcpSocketAppender'><destination>192.168.X.X:21021</destination><!-- 日志輸出編碼 --><encoderclass='net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder'><providers><timestamp><timeZone>UTC</timeZone></timestamp><pattern><pattern>{'severity': '%level','service': '${APP_NAME:-}','trace': '%X{X-B3-TraceId:-}','span': '%X{X-B3-SpanId:-}','parent': '%X{X-B3-ParentSpanId:-}','exportable': '%X{X-Span-Export:-}','pid': '${PID:-}','thread': '%thread','class': '%logger','rest': '%message'}</pattern></pattern></providers></encoder></appender><!-- 開發(fā)環(huán)境 --> <springProfile name='develop'><!--設(shè)置根日志級(jí)別--><root level='INFO'> <appender-ref ref='logstash_dev'/></root> </springProfile></configuration>三、在kibana界面查看數(shù)據(jù)

瀏覽器訪問(wèn)192.168.X.X:5601

1.查看索引管理

2.配置索引模式

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Linux
主站蜘蛛池模板: 新乐市| 尚志市| 福泉市| 南陵县| 桑植县| 临汾市| 买车| 慈溪市| 常德市| 永善县| 罗江县| 临湘市| 平潭县| 宁蒗| 绥江县| 旬邑县| 曲阳县| 定州市| 卓资县| 尖扎县| 龙江县| 简阳市| 姜堰市| 丰城市| 翼城县| 柳河县| 定西市| 内黄县| 涟水县| 咸阳市| 广水市| 信丰县| 平江县| 罗定市| 柳州市| 行唐县| 怀远县| 突泉县| 青田县| 尚义县| 松原市|