Filebeat를 어떻게 설치하고 구성하나요? 개발/생산 환경을 위한 경량 로그 포워더
게시 됨: 2020-05-03 지난 몇 년 동안 저는 Filebeat
를 사용해 왔으며 프로덕션 애플리케이션을 위한 최고의 lightweight
로그/데이터 전달자 중 하나입니다.
분석을 위해 한 클라이언트 위치에서 중앙 위치로 로그를 전송해야 하는 시나리오를 고려하십시오. Splunk
는 로그를 전달하는 대안 중 하나이지만 비용이 너무 많이 듭니다. 제 생각에는 너무 비용이 많이 듭니다.
이것이 Filebeat가 등장하는 곳입니다. 초경량, 간단하고 설정하기 쉽고 메모리를 덜 사용하고 너무 효율적입니다. Filebeat는 Elastic.co
의 제품입니다.
견고하고 비트를 놓치지 않습니다. guarantees delivery of logs
합니다.
모든 유형의 컨테이너가 준비되어 있습니다.
- 쿠버네티스
- 도커
간단한 하나의 라이너 명령으로 Filebeat는 아래 환경에서 로그 수집, 구문 분석 및 시각화를 처리합니다.
- 아파치
- NGINX
- 체계
- MySQL
- 아파치2
- 감사
- 엘라스틱서치
- 하프록시
- 아이싱가
- IIS
- iptables
- 카프카
- 키바나
- 로그스태시
- 몽고DB
- 타조
- PostgreSQL
- 레디스
- 수리카타
- 트라에픽
- 그리고 더…
Filebeat는 공통 로그 형식의 수집, 구문 분석 및 시각화를 단일 명령으로 단순화하는 내부 모듈(auditd, Apache, NGINX, System, MySQL 등)과 함께 제공됩니다.
Linux 환경에 Filebeat를 설치하는 방법은 무엇입니까?
아래 질문 중 하나가 있으면 올바른 위치에 있습니다.
- Filebeat 시작하기
- Filebeat 튜토리얼: 시작하기
- FileBeat 설치, 구성 및 사용 – Elasticsearch
- Filebeat 설정 및 구성 예
- Elasticsearch, Logstash를 설치하는 방법?
- Ubuntu에 Elastic Stack을 설치하는 방법은 무엇입니까?
1단계) 설치
아래 명령을 사용하여 Filebeat 바이너리를 다운로드하고 압축을 풉니다.
리눅스 환경:
1 2 3 4 5 6 |
root @ localhost : ~ # curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.7.0-linux-x86_64.tar.gz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 11.1M 100 11.1M 0 0 13.2M 0 -- : -- : -- -- : -- : -- -- : -- : -- 13.2M root @ localhost : ~ # tar xzvf filebeat-6.7.0-linux-x86_64.tar.gz |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
root @ localhost : ~ # cd filebeat-6.7.0-linux-x86_64/ root @ localhost : ~ / filebeat - 6.7.0 - linux - x86_64 # pwd / root / filebeat - 6.7.0 - linux - x86_64 root @ localhost : ~ / filebeat - 6.7.0 - linux - x86_64 # ls -ltra total 36720 - rw - r -- r -- 1 root root 13675 Mar 21 14 : 30 LICENSE . txt - rw - r -- r -- 1 root root 163444 Mar 21 14 : 30 NOTICE . txt drwxr - xr - x 4 root root 4096 Mar 21 14 : 31 kibana drwxr - xr - x 2 root root 4096 Mar 21 14 : 33 modules . d drwxr - xr - x 21 root root 4096 Mar 21 14 : 33 module - rw - r -- r -- 1 root root 146747 Mar 21 14 : 33 fields . yml - rw ------- 1 root root 7714 Mar 21 14 : 33 filebeat . yml - rw - r -- r -- 1 root root 69996 Mar 21 14 : 33 filebeat . reference . yml - rwxr - xr - x 1 root root 37161549 Mar 21 14 : 34 filebeat - rw - r -- r -- 1 root root 802 Mar 21 14 : 35 README . md - rw - r -- r -- 1 root root 41 Mar 21 14 : 35 . build_hash . txt drwx ------ 9 root root 4096 Mar 30 13 : 46 . . drwxr - xr - x 5 root root 4096 Mar 30 13 : 46 . |
맥 다운로드:
1 2 |
curl - L - O https : //artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.7.0-darwin-x86_64.tar.gz tar xzvf filebeat - 6.7.0 - darwin - x86_64 . tar . gz |
RPM 다운로드:
1 2 |
curl - L - O https : //artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.7.0-x86_64.rpm sudo rpm - vi filebeat - 6.7.0 - x86_64 . rpm |
2단계) filebeat.yml 구성 파일 구성
filebeat.yml
파일을 확인하십시오. 파일비트 구성 파일입니다.
다음은 간단한 파일 내용입니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
root @ localhost : ~ / filebeat - 6.7.0 - linux - x86_64 # cat filebeat.yml ###################### Filebeat Configuration Example ######################### # This file is an example configuration file highlighting only the most common # options. The filebeat.reference.yml file from the same directory contains all the # supported options with more comments. You can use it as a reference. # # You can find the full configuration reference here: # https://www.elastic.co/guide/en/beats/filebeat/index.html # For more available modules and options, please see the filebeat.reference.yml sample # configuration file. #=========================== Filebeat inputs ============================= filebeat . inputs : # Each - is an input. Most options can be set at the input level, so # you can use different inputs for various configurations. # Below are the input specific configurations. - type : log # Change to true to enable this input configuration. enabled : false # Paths that should be crawled and fetched. Glob based paths. paths : - / var / log /* . log #- c:\programdata\elasticsearch\logs\* # Exclude lines. A list of regular expressions to match. It drops the lines that are # matching any regular expression from the list. #exclude_lines: ['^DBG'] # Include lines. A list of regular expressions to match. It exports the lines that are # matching any regular expression from the list. #include_lines: ['^ERR', '^WARN'] # Exclude files. A list of regular expressions to match. Filebeat drops the files that # are matching any regular expression from the list. By default, no files are dropped. #exclude_files: ['.gz$'] # Optional additional fields. These fields can be freely picked # to add additional information to the crawled log files for filtering #fields: # level: debug # review: 1 ### Multiline options # Multiline can be used for log messages spanning multiple lines. This is common # for Java Stack Traces or C-Line Continuation # The regexp Pattern that has to be matched. The example pattern matches all lines starting with [ #multiline.pattern: ^\[ # Defines if the pattern set under pattern should be negated or not. Default is false. #multiline.negate: false # Match can be set to "after" or "before". It is used to define if lines should be append to a pattern # that was (not) matched before or after or as long as a pattern is not matched based on negate. # Note: After is the equivalent to previous and before is the equivalent to to next in Logstash #multiline.match: after #============================= Filebeat modules =============================== filebeat . config . modules : # Glob pattern for configuration loading path : $ { path . config } / modules . d /* . yml # Set to true to enable config reloading reload . enabled : false # Period on which files under path should be checked for changes #reload.period: 10s #==================== Elasticsearch template setting ========================== setup . template . settings : index . number_of_shards : 3 #index.codec: best_compression #_source.enabled: false #================================ General ===================================== # The name of the shipper that publishes the network data. It can be used to group # all the transactions sent by a single shipper in the web interface. #name: # The tags of the shipper are included in their own field with each # transaction published. #tags: ["service-X", "web-tier"] # Optional fields that you can specify to add additional information to the # output. #fields: # env: staging #============================== Dashboards ===================================== # These settings control loading the sample dashboards to the Kibana index. Loading # the dashboards is disabled by default and can be enabled either by setting the # options here, or by using the `-setup` CLI flag or the `setup` command. #setup.dashboards.enabled: false # The URL from where to download the dashboards archive. By default this URL # has a value which is computed based on the Beat name and version. For released # versions, this URL points to the dashboard archive on the artifacts.elastic.co # website. #setup.dashboards.url: #============================== Kibana ===================================== # Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API. # This requires a Kibana endpoint configuration. setup . kibana : # Kibana Host # Scheme and port can be left out and will be set to the default (http and 5601) # In case you specify and additional path, the scheme is required: http://localhost:5601/path # IPv6 addresses should always be defined as: https://[2001:db8::1]:5601 #host: "localhost:5601" # Kibana Space ID # ID of the Kibana Space into which the dashboards should be loaded. By default, # the Default Space will be used. #space.id: #============================= Elastic Cloud ================================== # These settings simplify using filebeat with the Elastic Cloud (https://cloud.elastic.co/). # The cloud.id setting overwrites the `output.elasticsearch.hosts` and # `setup.kibana.host` options. # You can find the `cloud.id` in the Elastic Cloud web UI. #cloud.id: # The cloud.auth setting overwrites the `output.elasticsearch.username` and # `output.elasticsearch.password` settings. The format is `<user>:<pass>`. #cloud.auth: #================================ Outputs ===================================== # Configure what output to use when sending the data collected by the beat. #-------------------------- Elasticsearch output ------------------------------ output . elasticsearch : # Array of hosts to connect to. hosts : [ "localhost:9200" ] # Enabled ilm (beta) to use index lifecycle management instead daily indices. #ilm.enabled: false # Optional protocol and basic auth credentials. #protocol: "https" #username: "elastic" #password: "changeme" #----------------------------- Logstash output -------------------------------- #output.logstash: # The Logstash hosts #hosts: ["localhost:5044"] # Optional SSL. By default is off. # List of root certificates for HTTPS server verifications #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] # Certificate for SSL client authentication #ssl.certificate: "/etc/pki/client/cert.pem" # Client Certificate Key #ssl.key: "/etc/pki/client/cert.key" #================================ Processors ===================================== # Configure processors to enhance or manipulate events generated by the beat. processors : - add_host_metadata : ~ - add_cloud_metadata : ~ #================================ Logging ===================================== # Sets log level. The default log level is info. # Available log levels are: error, warning, info, debug #logging.level: debug # At debug level, you can selectively enable logging only for some components. # To enable all selectors use ["*"]. Examples of other selectors are "beat", # "publish", "service". #logging.selectors: ["*"] #============================== Xpack Monitoring =============================== # filebeat can export internal metrics to a central Elasticsearch monitoring # cluster. This requires xpack monitoring to be enabled in Elasticsearch. The # reporting is disabled by default. # Set to true to enable the monitoring reporter. #xpack.monitoring.enabled: false # Uncomment to send the metrics to Elasticsearch. Most settings from the # Elasticsearch output are accepted here as well. Any setting that is not set is # automatically inherited from the Elasticsearch output configuration, so if you # have the Elasticsearch output configured, you can simply uncomment the # following line. #xpack.monitoring.elasticsearch: |

filebeat.yml 파일을 열고 로그 파일 위치를 설정합니다.
3단계) ElasticSearch에 로그 보내기
Filebeat를 실행하기 전에 로컬에서 ElasticSearch
를 시작했는지 확인하십시오. 오늘 나중에 간단한 단계를 통해 how to install and run ElasticSearch
에 대한 기사를 게시하겠습니다.
다음은 ElasticSearch에 대한 filebeat.yml 파일 구성입니다.
ElasticSearch는 포트 9200에서 실행됩니다.
1 2 3 |
output . elasticsearch : # Array of hosts to connect to. hosts : [ "localhost:9200" ] |
모든 준비가 완료되었습니다.
4단계) 파일비트 실행
1 2 |
bash - 3.2 $ sudo chown root filebeat . yml bash - 3.2 $ sudo . / filebeat - e |
filebeat 루트 디렉터리에서 위의 두 명령을 실행하면 아래와 같이 filebeat 시작 로그가 표시됩니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
root @ localhost : / user / crunchify / filebeat - 6.6.2 - linux - x86_64 # sudo chown root filebeat.yml root @ localhost : / user / crunchify / filebeat - 6.6.2 - linux - x86_64 # sudo ./filebeat -e 2019 - 03 - 30T14 : 52 : 02.608Z INFO instance / beat . go : 616 Home path : [ / user / crunchify / filebeat - 6.6.2 - linux - x86_64 ] Config path : [ / user / crunchify / filebeat - 6.6.2 - linux - x86_64 ] Data path : [ / user / crunchify / filebeat - 6.6.2 - linux - x86_64 / data ] Logs path : [ / user / crunchify / filebeat - 6.6.2 - linux - x86_64 / logs ] 2019 - 03 - 30T14 : 52 : 02.608Z INFO instance / beat . go : 623 Beat UUID : da7e202d - d480 - 42df - 907a - 1073b19c8e2d 2019 - 03 - 30T14 : 52 : 02.609Z INFO [ seccomp ] seccomp / seccomp . go : 116 Syscall filter successfully installed 2019 - 03 - 30T14 : 52 : 02.609Z INFO [ beat ] instance / beat . go : 936 Beat info { "system_info" : { "beat" : { "path" : { "config" : "/user/crunchify/filebeat-6.6.2-linux-x86_64" , "data" : "/user/crunchify/filebeat-6.6.2-linux-x86_64/data" , "home" : "/user/crunchify/filebeat-6.6.2-linux-x86_64" , "logs" : "/user/crunchify/filebeat-6.6.2-linux-x86_64/logs" } , "type" : "filebeat" , "uuid" : "da7e202d-d480-42df-907a-1073b19c8e2d" } } } 2019 - 03 - 30T14 : 52 : 02.609Z INFO [ beat ] instance / beat . go : 945 Build info { "system_info" : { "build" : { "commit" : "1eea934ce81be553337f2828bd12131896fea8e4" , "libbeat" : "6.6.2" , "time" : "2019-03-06T14:17:59.000Z" , "version" : "6.6.2" } } } 2019 - 03 - 30T14 : 52 : 02.609Z INFO [ beat ] instance / beat . go : 948 Go runtime info { "system_info" : { "go" : { "os" : "linux" , "arch" : "amd64" , "max_procs" : 2 , "version" : "go1.10.8" } } } 2019 - 03 - 30T14 : 52 : 02.611Z INFO [ beat ] instance / beat . go : 952 Host info { "system_info" : { "host" : { "architecture" : "x86_64" , "boot_time" : "2019-01-15T18:44:58Z" , "containerized" : false , "name" : "localhost" , "ip" : [ "127.0.0.1/8" , "::1/128" , "50.116.13.161/24" , "192.168.177.126/17" , "2600:3c01::f03c:91ff:fe17:4534/64" , "fe80::f03c:91ff:fe17:4534/64" ] , "kernel_version" : "4.18.0-13-generic" , "mac" : [ "f2:3c:91:17:45:34" ] , "os" : { "family" : "debian" , "platform" : "ubuntu" , "name" : "Ubuntu" , "version" : "18.10 (Cosmic Cuttlefish)" , "major" : 18 , "minor" : 10 , "patch" : 0 , "codename" : "cosmic" } , "timezone" : "UTC" , "timezone_offset_sec" : 0 , "id" : "1182104d1089460dbcc0c94ff1954c8c" } } } 2019 - 03 - 30T14 : 52 : 02.611Z INFO [ beat ] instance / beat . go : 981 Process info { "system_info" : { "process" : { "capabilities" : { "inheritable" : null , "permitted" : [ "chown" , "dac_override" , "dac_read_search" , "fowner" , "fsetid" , "kill" , "setgid" , "setuid" , "setpcap" , "linux_immutable" , "net_bind_service" , "net_broadcast" , "net_admin" , "net_raw" , "ipc_lock" , "ipc_owner" , "sys_module" , "sys_rawio" , "sys_chroot" , "sys_ptrace" , "sys_pacct" , "sys_admin" , "sys_boot" , "sys_nice" , "sys_resource" , "sys_time" , "sys_tty_config" , "mknod" , "lease" , "audit_write" , "audit_control" , "setfcap" , "mac_override" , "mac_admin" , "syslog" , "wake_alarm" , "block_suspend" , "audit_read" ] , "effective" : [ "chown" , "dac_override" , "dac_read_search" , "fowner" , "fsetid" , "kill" , "setgid" , "setuid" , "setpcap" , "linux_immutable" , "net_bind_service" , "net_broadcast" , "net_admin" , "net_raw" , "ipc_lock" , "ipc_owner" , "sys_module" , "sys_rawio" , "sys_chroot" , "sys_ptrace" , "sys_pacct" , "sys_admin" , "sys_boot" , "sys_nice" , "sys_resource" , "sys_time" , "sys_tty_config" , "mknod" , "lease" , "audit_write" , "audit_control" , "setfcap" , "mac_override" , "mac_admin" , "syslog" , "wake_alarm" , "block_suspend" , "audit_read" ] , "bounding" : [ "chown" , "dac_override" , "dac_read_search" , "fowner" , "fsetid" , "kill" , "setgid" , "setuid" , "setpcap" , "linux_immutable" , "net_bind_service" , "net_broadcast" , "net_admin" , "net_raw" , "ipc_lock" , "ipc_owner" , "sys_module" , "sys_rawio" , "sys_chroot" , "sys_ptrace" , "sys_pacct" , "sys_admin" , "sys_boot" , "sys_nice" , "sys_resource" , "sys_time" , "sys_tty_config" , "mknod" , "lease" , "audit_write" , "audit_control" , "setfcap" , "mac_override" , "mac_admin" , "syslog" , "wake_alarm" , "block_suspend" , "audit_read" ] , "ambient" : null } , "cwd" : "/user/crunchify/filebeat-6.6.2-linux-x86_64" , "exe" : "/user/crunchify/filebeat-6.6.2-linux-x86_64/filebeat" , "name" : "filebeat" , "pid" : 20394 , "ppid" : 20393 , "seccomp" : { "mode" : "filter" , "no_new_privs" : true } , "start_time" : "2019-03-30T14:52:01.740Z" } } } 2019 - 03 - 30T14 : 52 : 02.611Z INFO instance / beat . go : 281 Setup Beat : filebeat ; Version : 6.6.2 2019 - 03 - 30T14 : 52 : 05.613Z INFO add_cloud_metadata / add_cloud_metadata . go : 319 add_cloud_metadata : hosting provider type not detected . 2019 - 03 - 30T14 : 52 : 05.614Z INFO elasticsearch / client . go : 165 Elasticsearch url : http : //localhost:9200 2019 - 03 - 30T14 : 52 : 05.615Z INFO [ publisher ] pipeline / module . go : 110 Beat name : localhost 2019 - 03 - 30T14 : 52 : 05.615Z INFO instance / beat . go : 403 filebeat start running . 2019 - 03 - 30T14 : 52 : 05.615Z INFO registrar / registrar . go : 134 Loading registrar data from / user / crunchify / filebeat - 6.6.2 - linux - x86_64 / data / registry 2019 - 03 - 30T14 : 52 : 05.615Z INFO [ monitoring ] log / log . go : 117 Starting metrics logging every 30s 2019 - 03 - 30T14 : 52 : 05.616Z INFO registrar / registrar . go : 141 States Loaded from registrar : 0 2019 - 03 - 30T14 : 52 : 05.616Z INFO crawler / crawler . go : 72 Loading Inputs : 1 2019 - 03 - 30T14 : 52 : 05.616Z INFO log / input . go : 138 Configured paths : [ / crunchify / tutorials / log / crunchify - filebeat - test . log ] 2019 - 03 - 30T14 : 52 : 05.616Z INFO input / input . go : 114 Starting input of type : log ; ID : 7740765267175828127 2019 - 03 - 30T14 : 52 : 05.617Z INFO crawler / crawler . go : 106 Loading and starting Inputs completed . Enabled inputs : 1 2019 - 03 - 30T14 : 52 : 05.617Z INFO cfgfile / reload . go : 150 Config reloader started 2019 - 03 - 30T14 : 52 : 05.617Z INFO cfgfile / reload . go : 205 Loading of config files completed . |
5단계) 결과
다음 단계는 Elastic Search에 오는 로그와 시각화 방법을 확인하는 것입니다. 우리는 곧 자세한 튜토리얼을 살펴볼 것입니다. 계속 지켜봐 주세요.
무엇 향후 계획? Elastic Search 설정
개발/프로덕션 환경에서 Elasticsearch를 설치 및 구성하는 방법은 무엇입니까?