1. 개요
Datadog 에이전트를 이용해 Apache HTTP Server의 상태 지표와 로그를 수집하는 기본 설정 절차를 정리한다. Apache 지표 수집에는 Apache의 mod_status가 제공하는 /server-status?auto 엔드포인트가 필요하며, 로그 수집은 Datadog Agent의 로그 수집 기능이 활성화되어 있어야 한다.
2. 설정
2-1. Datadog 에이전트 설치
대상 서버에 Datadog Agent를 설치한다. 설치 방식은 운영체제와 배포 방식에 따라 다르므로, 기존에 사용하는 Datadog 설치 절차에 맞춰 진행한다.
설치 후에는 에이전트 설정 파일과 통합 설정 파일을 수정할 수 있는 권한이 필요하다.
2-2. mod_status 설정
Apache 메트릭을 수집하려면 mod_status 모듈이 활성화되어 있어야 하며, Datadog Agent가 접근할 수 있는 주소에서 /server-status?auto 응답을 확인할 수 있어야 한다.
예를 들어 로컬 에이전트에서만 조회하도록 구성했다면, 다음 URL이 서버 내부에서 정상 응답하는지 확인한다.
$ curl http://127.0.0.1/server-status?auto
접근 제어를 설정할 때는 외부에 상태 페이지가 노출되지 않도록 주의한다. 가능한 경우 127.0.0.1 또는 Datadog Agent가 실행되는 호스트에서만 접근하도록 제한하는 것이 좋다.
2-3. Metric Collection
/etc/datadog-agent/conf.d/apache.d/conf.yaml 파일을 생성하거나 기존 파일을 수정한다.
init_config: instances: - apache_status_url: http://127.0.0.1/server-status?auto # apache_user: example_user # if apache_status_url needs HTTP basic auth # apache_password: example_password # disable_ssl_validation: true # if you need to disable SSL cert validation, i.e. for self-signed certs
apache_status_url 값은 실제 Apache 상태 페이지 주소에 맞게 변경한다. Basic 인증을 사용하는 경우에는 주석 처리된 apache_user, apache_password 항목을 활성화해 사용한다.
2-4. Log Collection
Apache 로그를 수집하려면 Datadog Agent의 기본 설정에서 로그 수집이 활성화되어 있어야 한다. 이후 /etc/datadog-agent/conf.d/apache.d/conf.yaml 파일에 다음 내용을 추가한다.
logs:
- type: file
path: /var/log/access_log_*
source: apache
sourcecategory: http_web_access
service: apache
- type: file
path: /var/log/apache2/error_log_*
source: apache
sourcecategory: http_web_access
service: apache
로그 파일 경로는 배포판이나 Apache 설정에 따라 다를 수 있다. 예를 들어 Ubuntu/Debian 계열에서는 일반적으로 /var/log/apache2/ 아래에 로그가 있고, RHEL/CentOS 계열에서는 /var/log/httpd/ 아래에 있는 경우가 많다. 실제 서버의 access_log, error_log 위치에 맞게 path 값을 조정한다.
2-5. Datadog 에이전트 재시작
설정 파일을 저장한 뒤 Datadog Agent를 재시작한다.
$ sudo service datadog-agent restart
재시작 후에는 Agent 상태 명령으로 Apache 통합이 정상적으로 로드되었는지 확인한다.
$ sudo datadog-agent status
상태 출력에서 Apache 체크 관련 오류가 없는지, 로그 수집이 활성화되어 있는지 확인한다.
3. Datadog Agent 삭제
아래는 apt 기반 시스템에서 Datadog Agent를 제거한 예시 출력이다. 실제 출력은 설치된 Agent 버전, 운영체제, 패키지 상태에 따라 달라질 수 있다.
# apt-get --purge remove datadog-agent -y Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: linux-aws-headers-4.4.0-1066 linux-aws-headers-4.4.0-1069 linux-aws-headers-4.4.0-1070 linux-headers-4.4.0-1066-aws linux-headers-4.4.0-1069-aws linux-headers-4.4.0-1070-aws linux-image-4.4.0-1066-aws linux-image-4.4.0-1069-aws linux-image-4.4.0-1070-aws Use 'apt autoremove' to remove them. The following packages will be REMOVED: datadog-agent* 0 upgraded, 0 newly installed, 1 to remove and 76 not upgraded. After this operation, 359 MB disk space will be freed. (Reading database ... 217517 files and directories currently installed.) Removing datadog-agent (1:6.6.0-1) ... Removed symlink /etc/systemd/system/multi-user.target.wants/datadog-agent-process.service. Removed symlink /etc/systemd/system/multi-user.target.wants/datadog-agent-trace.service. Removed symlink /etc/systemd/system/multi-user.target.wants/datadog-agent.service. find: ‘/opt/datadog-agent/agent’: No such file or directory Unable to delete .pyc files in /opt/datadog-agent/agent Purging configuration files for datadog-agent (1:6.6.0-1) ... Deleting dd-agent user Deleting dd-agent group Force-deleting /opt/datadog-agent dpkg: warning: while removing datadog-agent, directory '/opt' not empty so not removed Processing triggers for systemd (229-4ubuntu21.15) ... Processing triggers for ureadahead (0.100.0-19) ...