Elasticsearch, Kibana설정은 이전글 참고
https://bo20cy.tistory.com/30
ubuntu 20.04
nginx log수집
Elastic-agent ?
Elastic Agent는 데이터를 수집하고, 이를 Elastic Stack으로 보내는 단일 에이전트입니다. 다양한 데이터 소스를 수집하고 관리할 수 있게 해줍니다. Elastic Agent는 Fleet 또는 Standalone(단독) 모드로 운영할 수 있습니다.
- Fleet 모드: Elastic Stack의 중앙 집중식 관리 기능을 제공하는 방식
- Standalone 모드 : Elastic Agent가 개별적으로 독립적으로 실행되는 모드입니다. 소규모 환경이나, 특정 서버에 적용
- Elastic-agent 설치
간단하게 테스트 용으로 elastic이 잘 받는지 확인하기 위해 alone 서버를 사용 합니다.
설치 공홈
https://www.elastic.co/guide/en/fleet/current/install-standalone-elastic-agent.html
Install standalone Elastic Agents | Fleet and Elastic Agent Guide [8.17] | Elastic
On macOS, Linux (tar package), and Windows, run the install command to install Elastic Agent as a managed service and start the service. The DEB and RPM packages include a service unit for Linux systems with systemd, so just enable then start the service.
www.elastic.co
다운로드 링크(7.17.26)
https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-7.17.26-linux-x86_64.tar.gz
- Elastic-agent 다운
## 7.17.26 다운
curl -L -O [<https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-7.17.26-linux-x86_64.tar.gz>](<https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-7.17.26-linux-x86_64.tar.gz>)
tar -xzvf elastic-agent-7.17.xx-linux-x86_64.tar.gz
## 이동
cd elastic-agent-7.17.xx-linux-x86_64
## kibana 연동
vim elastic-agent.yml
- elasticsearch와 연동
elastic-agent.yml
파일을 수정하여 Kibana와 연결 정보를 설정합니다. Elastic Agent install 되면 위치에 저장됨
vim elastic-agent.yml
----------------------------------------------------------
outputs:
default:
type: elasticsearch
hosts: [##ES##:9200]
username: elastic
password: qwe123
inputs:
- id: logfile-apache
name: apache-log
revision: 1
type: logfile
use_output: default
data_stream:
namespace: default
streams:
- id: apache-access-stream
data_stream:
dataset: apache.access
type: logs
exclude_files:
- .gz$
paths:
- /var/log/nginx/access.log*
- id: apache-error-stream
data_stream:
dataset: apache.error
type: logs
exclude_files:
- .gz$
paths:
- /var/log/nginx/error.log*
아래와 같이 metrics를 구성하여 상태를 확인
(다양한 방식이 많습니다.)
- type: system/metrics
data_stream.namespace: default
use_output: default
streams:
- metricset: cpu
data_stream.dataset: system.cpu
- metricset: memory
data_stream.dataset: system.memory
- metricset: network
data_stream.dataset: system.network
- metricset: filesystem
data_stream.dataset: system.filesystem
- Elastic-agent 설치
./elastic-agent install
## 여기서 fleet에 등록하겠습니까 나오니 fleet버전도 사용가능
## /opt/Elastic/Agent/ 이하에 설치됨
## yml파일 변경시
systemctl restart elastic-agent
nginx ?
Nginx는 고성능의 웹 서버이자 리버스 프록시 서버로, 높은 성능과 적은 리소스를 사용하고 있습니다.
여기서는 다른 VM에 nginx와 elastic-agent를 설치하여 log가 잘 받아지는 지 확인용입니다.
- nginx 설치
apt update
apt install nginx
localhost:80
다크모드일뿐 잘 나옵니다.
- Kibana 확인
Stack Managerment - Index Patterns - Create index pattern
index pattern 추가
- log 발생
localhost:80
## 으로 들어가면 access.log 발생
localhost:80/$%&^$#%&$%
## 뒤에 이상한 걸 쳐서 error.log 발생!
변경 내용이 있으면 재시작하시면 됩니다.
#적용된다
systemctl restart elastic-agent
'ELK' 카테고리의 다른 글
Elasticsearch, Kibana 7.17 설치 (2) | 2024.12.23 |
---|