• EnglishEspañol日本語한국어Português
  • 로그인지금 시작하기

사용자의 편의를 위해 제공되는 기계 번역입니다.

In the event of any inconsistency between the English version and the translated version, the English versionwill take priority. Please visit this page for more information.

문제 신고

TCP 엔드포인트를 사용하여 New Relic에 로그 전달

우리는 로그 데이터를 New Relic으로 가져오기 위한 광범위한 솔루션을 제공합니다. 그러나 로그 전달자가 없는 다른 상황(예: CDN, 하드웨어 장치 또는 관리 서비스)에서는 TCP 끝점을 통해 syslog 프로토콜을 사용할 수 있습니다. rsyslogsyslog-ng 과 같은 syslog 클라이언트를 사용하여 로그를 New Relic에 전달할 수 있습니다.

호환성 및 요구 사항

syslog 클라이언트를 사용하여 New Relic에 로그를 전달하려면 다음이 필요합니다.

  • 로그를 보내려는 계정에 대한 유효한 뉴렐릭

  • 이 문서에 설명된 대로 syslog 클라이언트 구성에 대한 몇 가지 사소한 변경

rsyslog 버전 8 이상 구성(Amazon Linux, Redhat, Centos)

중요

EU 리전 계정을 사용하는 경우 newrelic.syslog.nr-data.net 대신 newrelic.syslog.eu.nr-data.net 을 엔드포인트로 사용해야 합니다. 구성 파일에서 교체하는 것을 잊지 마십시오. EU 계정에 대해 미국 끝점을 사용하면 작동하지 않습니다.

Amazon Linux, Redhat 및 Centos 배포용 rsyslog 를 사용하여 New Relic에 로그를 전달하려면 다음을 수행합니다.

  1. rsyslog 에서 TLS 암호화를 사용하여 로그를 전송하는 데 필요한 패키지를 설치합니다.

    bash
    $
    sudo yum install rsyslog-gnutls ca-certificates
  2. 선택 사항: 로그 파일을 테일링하고 해당 콘텐츠를 New Relic으로 전달하도록 rsyslog 을 구성합니다. 텍스트 파일 입력 모듈을 활성화하려면 /etc/rsyslog.conf 파일에 다음을 추가하세요.

    module(load="imfile"
    PollingInterval="10"
    )
  3. /etc/rsyslog.d/ 디렉토리에서 newrelic.conf 이라는 텍스트 파일을 만듭니다.

  4. /etc/rsyslog.conf 아래의 $IncludeConfig 옵션에 /etc/rsyslog.d 디렉토리 아래 새로 생성된 newrelic.conf 파일을 포함할 일치하는 와일드카드가 이미 있는지 확인하십시오. 그렇지 않으면 다음을 사용하여 /etc/rsyslog.conf/etc/rsyslog.d/newrelic.conf 를 명시적으로 포함해야 합니다. $IncludeConfig /etc/rsyslog.d/newrelic.conf

  5. newrelic.conf 에 다음을 추가합니다. 강조 표시된 값을 바꿉니다. YOUR_LICENSE_KEY 의 경우 뉴렐릭 을(를) 사용하세요.

    ## Specify each of the files to be tailed in case step 1 is done
    input(type="imfile" Tag="YOUR_FILE_TAG" File="PATH_TO_FILE")
    ## Template expected by the New Relic Syslog endpoint
    template(name="newrelic-rfc5424"
    type="string"
    string="YOUR_LICENSE_KEY <%pri%>%protocol-version% %timestamp:::date-rfc3339% %hostname% %app-name% %procid% %msgid% %structured-data% %msg%\n"
    )
    ## Configure TLS and log forwarding
    global(DefaultNetstreamDriver="gtls"
    ##Specify the full path to the system's CA certificate:
    DefaultNetstreamDriverCAFile="<path to certificate>"
    ## RHEL/CentOS/Amazon Linux:
    ##/etc/pki/tls/certs/ca-bundle.crt
    ## Ubuntu:
    ##/etc/ssl/certs/ca-certificates.crt
    ##Other systems:
    ##Specify the full path to the system's generic CA certificate.
    )
    action(type="omfwd"
    Target="newrelic.syslog.nr-data.net"
    Port="6514"
    Protocol="tcp"
    Template="newrelic-rfc5424"
    ResendLastMSGOnReconnect="on"
    StreamDriver="gtls"
    StreamDriverAuthMode="x509/name"
    StreamDriverPermittedPeers="*.syslog.nr-data.net"
    StreamDriverMode="1"
    )
  6. (선택사항): syslog 데이터에 맞춤 속성을 추가합니다.

    syslog 데이터를 나머지 원격 측정 데이터와 일치시키려면 사용자 정의 속성을 추가할 수 있습니다. 이를 수행하는 두 가지 방법이 있습니다.

    • Add custom attributes directly in the template string. 문자열 값에 대해서는 큰따옴표(")를 이스케이프해야 합니다. 예를 들어:

      [<STRUCTURED_DATA_ID> <ATTR_NAME_1>="<ATTR_VALUE_1>" <ATTR_NAME_2>="<ATTR_VALUE_2>" ...]

      template(name="newrelic-rfc5424"
      type="string"
      string="YOUR_LICENSE_KEY <%pri%>%protocol-version% %timestamp:::date-rfc3339% %hostname% %app-name% %procid% %msgid% [someId environment=\"prod\" region=\"US\"] %msg%\n"
      )
    • Add custom attributes using a custom property variable in the template string. 이 방법을 사용하면 문자열 값을 이스케이프할 필요가 없습니다.

      template(name="newrelic-rfc5424"
      type="string"
      string="YOUR_LICENSE_KEY <%pri%>%protocol-version% %timestamp:::date-rfc3339% %hostname% %app-name% %procid% %msgid% %!custom-structured-data% %msg%\n"
      )
      set $!custom-structured-data = '[someId1 environment="prod" region="US"][someId2 team="sre" cost-center="123"]';

템플릿 문자열의 %structured-data% 섹션을 사용자 정의 태그/속성으로 교체해야 합니다.

  1. 다음을 실행하여 rsyslog 서비스를 다시 시작합니다.

    bash
    $
    sudo systemctl restart rsyslog
  2. 로그에 대한 New Relic 계정을 확인하십시오 .

압축을 사용하여 rsyslog 버전 8 이상 구성(Amazon Linux, Redhat, Centos)

Amazon Linux, Redhat 및 Centos 배포에 대해 rsyslog 버전 8 이상을 구성하려면 다음 안내를 따르세요.

  1. configure rsyslog 에 설명된 1-4단계를 따르십시오.

    중요

    구성된 포트 번호는 { 6514 6516 입니다.

  2. newrelic.conf 에 다음을 추가합니다. 강조 표시된 값을 모두 바꿉니다. YOUR_LICENSE_KEY 의 경우 뉴렐릭 을(를) 사용하세요.

    ## Specify each of the files to be tailed in case step 1 is done
    input(type="imfile" Tag="YOUR_FILE_TAG" File="PATH_TO_FILE"
    ## Template expected by the New Relic Syslog endpoint
    template(name="newrelic-rfc5424"
    type="string"
    string="YOUR_LICENSE_KEY <%pri%>%protocol-version% %timestamp:::date-rfc3339% %hostname% %app-name% %procid% %msgid% %structured-data% %msg%\n"
    )
    ## Configure TLS and log forwarding
    global(DefaultNetstreamDriver="gtls"
    ##Specify the full path to the system's CA certificate:
    DefaultNetstreamDriverCAFile="<path to certificate>"
    ## RHEL/CentOS/Amazon Linux:
    ##/etc/pki/tls/certs/ca-bundle.crt
    ## Ubuntu:
    ##/etc/ssl/certs/ca-certificates.crt
    ##Other systems:
    ##Specify the full path to the system's generic CA certificate.
    )
    action(type="omfwd"
    Target="newrelic.syslog.nr-data.net"
    Port="6516"
    Protocol="tcp"
    Template="newrelic-rfc5424"
    ResendLastMSGOnReconnect="on"
    StreamDriver="gtls"
    StreamDriverAuthMode="x509/name"
    StreamDriverPermittedPeers="*.syslog.nr-data.net"
    StreamDriverMode="1"
    compression.Mode="stream:always"
    )
  3. 다음을 실행하여 rsyslog 서비스를 다시 시작합니다.

    bash
    $
    sudo systemctl restart rsyslog
  4. 로그에 대한 New Relic 계정을 확인하십시오 .

rsyslog 버전 7 이하(Amazon Linux, Redhat, Centos)용 레거시 구성 파일

rsyslog 버전 7 이하를 사용하는 경우 구성 파일을 더 이상 사용되지 않는 레거시 형식으로 조정해야 합니다. 이 형식은 레트로 호환성 목적으로만 유지됩니다. rsyslog 설명서 에 명시된 대로 사용하지 않는 것이 좋습니다. Amazon Linux, Redhat 및 Centos 배포에 대한 로그를 구성하려면:

  1. rsyslog 에서 TLS 암호화를 사용하여 로그를 전송하는 데 필요한 패키지를 설치합니다.

    bash
    $
    sudo yum install rsyslog-gnutls ca-certificates
  2. 선택 사항: 로그 파일을 테일링하고 해당 콘텐츠를 New Relic으로 전달하도록 rsyslog 을 구성합니다. 텍스트 파일 입력 모듈을 활성화하려면 /etc/rsyslog.conf 파일에 다음을 추가하세요.

    $ModLoad imfile
    $InputFilePollInterval 10
    $PrivDropToGroup adm
    $WorkDirectory /var/spool/rsyslog
  3. /etc/rsyslog.d/ 디렉토리에서 newrelic.conf 이라는 텍스트 파일을 만듭니다.

  4. /etc/rsyslog.conf 아래의 $IncludeConfig 옵션에 /etc/rsyslog.d 디렉토리 아래 새로 생성된 newrelic.conf 파일을 포함할 일치하는 와일드카드가 이미 있는지 확인하십시오. 그렇지 않으면 $IncludeConfig /etc/rsyslog.d/newrelic.conf }을 사용하여 /etc/rsyslog.conf/etc/rsyslog.d/newrelic.conf 를 명시적으로 포함해야 합니다.

  5. newrelic.conf 에 다음을 추가합니다. 강조 표시된 값을 바꿉니다. YOUR_LICENSE_KEY 의 경우 뉴렐릭 을(를) 사용하세요.

    ## Template expected by the New Relic Syslog endpoint
    $template NRLogFormat,"YOUR_LICENSE_KEY <%pri%>%protocol-version% %timestamp:::date-rfc3339% %hostname% %app-name% %procid% %msgid% %structured-data% %msg%\n"
    ## Specify each of the files to be tailed in case step 1 is done
    $InputFileName /path/to/file
    $InputFileTag YOUR_FILE_TAG
    $InputFileSeverity info
    $InputRunFileMonitor
    ## Configure TLS and log forwarding
    ##Specify the full path to the system's CA certificate:
    $DefaultNetstreamDriverCAFile <path to certificate>
    ## RHEL/CentOS/Amazon Linux:
    ##/etc/pki/tls/certs/ca-bundle.crt
    ## Ubuntu:
    ##/etc/ssl/certs/ca-certificates.crt
    ##Other systems:
    ##Specify the full path to the system's generic CA certificate.
    $ActionSendStreamDriver gtls
    $ActionSendStreamDriverMode 1
    $ActionSendStreamDriverAuthMode x509/name
    $ActionSendStreamDriverPermittedPeer *.syslog.nr-data.net
    *.* @@newrelic.syslog.nr-data.net:6514;NRLogFormat
  6. 다음을 실행하여 rsyslog 서비스를 다시 시작합니다.

    bash
    $
    sudo systemctl restart rsyslog
  7. 로그에 대한 New Relic 계정을 확인하십시오 .

syslog-ng 구성

syslog-ng 을(를) 사용하여 로그를 New Relic에 전달하려면 다음을 수행합니다.

  1. syslog-ng 이(가) TLS 암호화를 사용하여 로그를 보내도록 허용하려면 ca-certificates 을(를) 설치해야 합니다.

    bash
    $
    sudo yum install ca-certificates
  2. 텍스트 편집기에서 syslog-ng 구성 파일( /etc/syslog-ng/syslog-ng.conf )을 엽니다.

  3. 다음을 추가하여 모니터링할 소스를 정의합니다.

    source s_src {
    internal();
    };
  4. 선택사항: Sources 구성 블록에 다음을 추가하여 꼬리 파일에 syslog-ng 을 구성합니다.

    source s_files {
    file("PATH_TO_FILE");
    };
  5. 뉴렐릭 syslog 형식을 정의합니다. YOUR_LICENSE_KEY 의 경우 뉴렐릭 을(를) 사용하세요.

    template NRFormat { template("YOUR_LICENSE_KEY <${PRI}>1 ${ISODATE} ${HOST:--} ${PROGRAM:--} ${PID:--} ${MSGID:--} ${SDATA:--} $MSG\n");
    template_escape(no);
    };
  6. New Relic Syslog 엔드포인트를 추가합니다.

    destination d_newrelic {
    network("newrelic.syslog.nr-data.net" port(6514)
    transport("tls")
    tls(peer-verify(no))
    template(NRFormat)
    );
    };
  7. 로그 경로 구성 블록에 다음 출력을 추가합니다.

    log {
    source(s_src);
    source(s_files); ## in case step 4 is implemented.
    destination(d_newrelic);
    };
  8. 다음을 실행하여 syslog-ng 을(를) 다시 시작합니다.

    bash
    $
    sudo service syslog-ng restart
  9. 로그에 대한 New Relic 계정을 확인하십시오 .

Docker 컨테이너에서 syslog-ng를 실행 중이고 문제가 발생하면 balait/syslog 이미지 설명서 를 확인하십시오.

Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.