Elastic + logstash + filebeat Nginx 로그 분석
적합 한 버 전 다운로드: curl - L - Ohttps://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.0.tar.gztar -xvf elasticsearch-6.4.0.tar.gzcd elasticsearch-6.4.0/bin./elasticsearch
2. 집단 건강 검진 curl - XGEThttp://127.0.0.1:9200/_cat / health? v 클 러 스 터 건강 보기 curl - XGEThttp://127.0.0.1:9200/_cat / nodes? v 노드 상태 보기 curl - XGEThttp://127.0.0.1:9200/_cat / indices? v 색인 컬 보기 - XPUThttp://127.0.0.1:9200/customer?pretty customer 인덱스 컬 추가 - XDELETEhttp://127.0.0.1:9200/customer?pretty 색인 삭제
3. Config cluster. name: 클 러 스 터 이름 node. name: 노드 이름 path. data: 데이터 저장 경로 path. logs: 로그 저장 경로 network. host: 감청 주소 http. port: 감청 포트 JVM 설정, logging 설정 은 공식 문서 의 중요 한 매개 변 수 를 참고 합 니 다.
Path settingsCluster nameNode nameNetwork hostDiscovery settingsHeap sizeHeap dump pathGC loggingTemp directory 중요 한 시스템 매개 변수:
Disable swappingIncrease file descriptorsEnsure sufficient virtual memoryEnsure sufficient threadsJVM DNS cache settings
4. Running as daemon. / bin / elasticsearch - d - p pid 시작 kill
cat pid
정지5 、 Set up X - Pack 참고 x - pack 해독 방법
2. kibana 설치 및 설정
wget https://artifacts.elastic.co/downloads/kibana/kibana-6.4.0-linux-x86_64.tar.gz
tar -xzf kibana-6.4.0-linux-x86_64.tar.gzcd kibana-6.4.0-linux-x86_64/
1、 ./bin/kibana
2、config:
server.port: 5601server.host: "192.168.12.81"kibana.index: ".kibana"elasticsearch.username: "elastic"elasticsearch.password: "dinpay"
3. logstash 설치 및 설정 wgethttps://artifacts.elastic.co/downloads/logstash/logstash-6.4.0.tar.gz
filebeat 설정 Nginx 로그 수집: (Nginx. conf)
input {beats {port => 5044 codec => "json" } }
output { elasticsearch { hosts => ["127.0.0.1:9200"] index => "test1-nginx-access-%{+YYYY.MM.dd}" template_overwrite => true user => elasticpassword => dinpay } }
logstash. yml elastic 을 이 컴퓨터 에 설치 하도록 설정 합 니 다 (https 설정 하지 않 음)
xpack.monitoring.enabled: true xpack.monitoring.elasticsearch.username: elastic xpack.monitoring.elasticsearch.password: dinpay xpack.monitoring.elasticsearch.url: ["http://127.0.0.1:9200"]
4. filebeat 설치 및 설정
wget https://artifacts.elastic.co/downloads/beats/filebeat/https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.4.0-linux-x86_64.tar.gz
tar -xf filebeat-6.4.0-linux-x86_64.tar.gz
cd filebeat-6.4.0-linux-x86_64
filebeat. yml 설정
output.logstash:
hosts: ["192.168.12.81:5044"]
xpack.monitoring:enabled: trueelasticsearch: hosts: ["http://192.168.12.81:9200", "http://192.168.12.81:9200"]username: elasticpassword: dinpay
5. Nginx 로그 형식 설정:
log_format json '{"@timestamp":"$time_iso8601",' '"host":"$server_addr",''"clientip":"$clientRealIp",''"remote_user":"$remote_user",''"request":"$request",' '"http_user_agent":"$http_user_agent",''"size":$body_bytes_sent,' '"responsetime":$request_time,''"upstreamtime":"$upstream_response_time",' '"upstreamhost":"$upstream_addr",''"http_host":"$host",''"url":"$uri",''"domain":"$host",''"xff":"$http_x_forwarded_for",''"referer":"$http_referer",' '"status":"$status",''"ss":"$upstream_status"}';
access_log /var/log/nginx/access.log json;
map $http_x_forwarded_for $clientRealIp {
"" $remote_addr;
~^(?P[0-9\.]+),?.*$ $firstAddr;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
간단! Certbot을 사용하여 웹 사이트를 SSL(HTTPS)화하는 방법초보자가 인프라 주위를 정돈하는 것은 매우 어렵습니다. 이번은 사이트를 간단하게 SSL화(HTTP에서 HTTPS통신)로 변경하는 방법을 소개합니다! 이번에는 소프트웨어 시스템 Nginx CentOS7 의 환경에서 S...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.