본문 바로가기
오라클 클라우드/우분투팁

Datadog 설치(불완전)

by xavi2019 2022. 3. 4.

이 글은 공부하며 쓴 글이라 불완전합니다.

 

아파치 설치 

# 데이터독 에이전트 설치
DD_AGENT_MAJOR_VERSION=7 DD_API_KEY=YOURAPIKEY DD_SITE="datadoghq.com" bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script.sh)"


cd /etc/datadog-agent/conf.d/apache.d/
sudo vi /etc/datadog-agent/conf.d/apache.d/conf.yaml

# 파일 내용 시작
init_config:

instances:
  ## @param apache_status_url - string - required
  ## Status url of your Apache server.
  #
  - apache_status_url: http://localhost/server-status?auto

# 파일 내용 끝 

sudo systemctl restart datadog-agent

# 로그 활성화
sudo vi /etc/datadog-agent/datadog.yaml

# 파일 내용중 아래와 같이 수정
logs_enabled: true

sudo vi /etc/datadog-agent/conf.d/apache.d/conf.yaml
내용 추가

logs:
  - type: file
    path: /var/log/apache2/access.log
    source: apache
    service: apache
    sourcecategory: http_web_access

  - type: file
    path: /var/log/apache2/error.log
    source: apache
    service: apache
    sourcecategory: http_web_error
sudo systemctl restart datadog-agent

 

MySql 설치

 

CREATE USER 'datadog'@'%' IDENTIFIED WITH mysql_native_password by 'pw112233';

bash 쉘
mysql -u datadog --password=pw112233 -e "show status" | \
grep Uptime && echo -e "\033[0;32mMySQL user - OK\033[0m" || \
echo -e "\033[0;31mCannot connect to MySQL\033[0m"


ALTER USER 'datadog'@'%' WITH MAX_USER_CONNECTIONS 5;

GRANT SELECT ON performance_schema.* TO 'datadog'@'%';



sudo vi /etc/datadog-agent/conf.d/mysql.d/conf.yaml

init_config:

instances:
  - server: 127.0.0.1
    user: datadog
    pass: "<YOUR_CHOSEN_PASSWORD>" # from the CREATE USER step earlier
    port: "<YOUR_MYSQL_PORT>" # e.g. 3306
    options:
      replication: false
      galera_cluster: true
      extra_status_metrics: true
      extra_innodb_metrics: true
      extra_performance_metrics: true
      schema_size_metrics: false
      disable_innodb_metrics: false


sudo systemctl restart datadog-agent

sudo vi /etc/mysql/my.cnf

[mysqld_safe]
  log_error = /var/log/mysql/mysql_error.log

  [mysqld]
  general_log = on
  general_log_file = /var/log/mysql/mysql.log
  log_error = /var/log/mysql/mysql_error.log
  slow_query_log = on
  slow_query_log_file = /var/log/mysql/mysql_slow.log
  long_query_time = 2

sudo systemctl restart mysql

sudo vi /etc/datadog-agent/conf.d/mysql.d/conf.yaml

logs:
  - type: file
    path: /var/log/mysql/mysql_error.log
    source: mysql
    service: mysql

  - type: file
    path: /var/log/mysql/mysql_slow.log
    source: mysql
    service: mysql
    log_processing_rules:
      - type: multi_line
        name: new_slow_query_log_entry
        pattern: "# Time:"
        # If mysqld was started with `--log-short-format`, use:
        # pattern: "# Query_time:"
        # If using mysql version <5.7, use the following rules instead:
        # - type: multi_line
        #   name: new_slow_query_log_entry
        #   pattern: "# Time|# User@Host"
        # - type: exclude_at_match
        #   name: exclude_timestamp_only_line
        #   pattern: "# Time:"

  - type: file
    path: /var/log/mysql/mysql.log
    source: mysql
    service: mysql
    # For multiline logs, if they start by the date with the format yyyy-mm-dd uncomment the following processing rule
    log_processing_rules:
      - type: multi_line
        name: new_log_start_with_date
        pattern: \d{4}\-(0?[1-9]|1[012])\-(0?[1-9]|[12][0-9]|3[01])
    # If the logs start with a date with the format yymmdd but include a timestamp with each new second, rather than with each log, uncomment the following processing rule
    # log_processing_rules:
    #   - type: multi_line
    #     name: new_logs_do_not_always_start_with_timestamp
    #     pattern: \t\t\s*\d+\s+|\d{6}\s+\d{,2}:\d{2}:\d{2}\t\s*\d+\s+



sudo systemctl restart datadog-agent

댓글