Apache 로그를 ELK 환경에서 시각화했습니다.
                                            
                                                
                                                
                                                
                                                
                                                
                                                 6943 단어  초보자Elasticsearch키바나Logstash
                    
너는 누구야?
IPFactory 소속의 1년입니다
honeypot에 관한 일
했던 일
콘솔에서 로그를 볼 때 너무 힘들다. 우는

그래서 로그를 시각화하기로 결정했습니다.
ELK란?
Elastic search, Kibana, Logstash의 약자
각 역할은 다음과 같습니다.
환경
우분투18.04
Apache2.4.29
소개
Elasticsearch
apt install -y apt-transport-https
wget https://artifacts.elastic.co/GPG-KEY-elasticsearch
apt-key add GPG-KEY-elasticsearch
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
apt update
apt install -y elasticsearch
#elasticsearch起動
systemctl start elasticsearch
시작 후 http://localhost:9200에 액세스하고 이러한 JSON이 반환되면 잘 작동합니다.
{
  "name" : "ubuntu",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "4lR3_HlKTa--IPJr8xLTxA",
  "version" : {
    "number" : "7.5.0",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "e9ccaed468e2fac2275a3761849cbee64b39519f",
    "build_date" : "2019-11-26T01:06:52.518245Z",
    "build_snapshot" : false,
    "lucene_version" : "8.3.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
Logstash
apt install -y logstash
규칙 만들기
/etc/logstash/conf.d/apache2.conf
input {
   file {
      mode => "tail"
      path => ["/var/log/apache2/access.log"]
   }
}
filter {
   grok {
      match => { "message" => "%{COMBINEDAPACHELOG}" }
   }
   date {
      match => [ "timestamp" , "dd/MMM/yyyy:HH:mm:ss Z" ]
      locale => "en"
   }
}
output {
   elasticsearch {
      hosts => ["localhost:9200"]
      index => "apache2"
   }
}
elasticsearch 시작
왜 systemctl로 움직일 때 잘 작동하지 않았기 때문에
/usr/share/logstash -f /etc/logstash/conf.d/apache2.conf
기동 후, 이하의 커멘드를 실행해 동작 확인
curl http://localhost:9200/_cat/health?v
#indexにapache2があればうまく動作している
health status index                    uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open   apache2                   L59zRp1nQqWGdrJJEZS5Gw   1   1         12            0     56.5kb         56.5kb
green  open   .kibana_task_manager_1   CAup6rtVTsi6tD2tFxdy0A   1   0          2            0       57kb           57kb
green  open   .apm-agent-configuration GvocK76nQlaOEsViuM0o2Q   1   0          0            0       283b           283b
green  open   .kibana_2                wPziMyNSSBuIPmQ6wqMpSg   1   0          6            0     29.1kb         29.1kb
green  open   .kibana_1                uRrfym5VS4qC_x70142Emg   1   0          1            0        4kb            4kb
green  open   .tasks                   hQ70Y5N7TsGdOBw-SO8p5g   1   0          1            0      6.3kb          6.3kb
키바나
apt install -y kibana
#kinaba起動
systemctl start kibana
부팅 후
그런 다음 Kibana의 왼쪽 메뉴에서 Management> Index Patterns> Create Index Pattern으로 이동
색인 패턴 부분에 apache2를 입력하고 다음 단계를 누릅니다.
Time Filer field name의 드롭다운 목록에서 http://localhost:5601
왼쪽 메뉴에서 Discover를 클릭하면 로그 표, 그래프를 볼 수 있습니다.
마지막으로
등 몇 가지 문제점이 있으므로 앞으로 해결하고 싶습니다.
Reference
이 문제에 관하여(Apache 로그를 ELK 환경에서 시각화했습니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/N0s3ncE/items/79d1a838fb6c5028c5af텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)