테스트실행으로는 됬다 안됬다만 나타내고 알람이 안와서 제대로 됬는지 알수가없어서 알람을 받기위해 사용한 방법
kibana ---> elastalert_status_status index에 들어가보면 발생한 로그들이 저장되어있었다.
(키바나 인덱스 들어가보면 로그인덱스찾아보기)
터미널을 여러개열고 ~~.yaml을 띄워둔다.
아래는 config.yaml
rules_folder: example_rules
run_every:
minutes: 1
buffer_time:
minutes: 15
es_host: 203.246.~~ #이부분은 맞게고치기
es_port: 39200 #이부분은 맞게고치기
writeback_index: elastalert_status
alert_time_limit:
days: 2
example_rules안에서 여러개 띄워준 터미널들 예시 (아래링크에서 rule들 참조하기)
https://elastalert.readthedocs.io/en/latest/running_elastalert.html#running-elastalert
Running ElastAlert for the First Time — ElastAlert 0.0.1 documentation
Setting Up Elasticsearch ElastAlert saves information and metadata about its queries and its alerts back to Elasticsearch. This is useful for auditing, debugging, and it allows ElastAlert to restart and resume exactly where it left off. This is not require
elastalert.readthedocs.io
d.yaml
name: Example frequency rule
type: flatline
index: logstash-*
timeframe:
- hours: 4
use_count_query: true
query_delay:
- minutes: 5
alert:
- "email"
- "slack"
email:
- "bbbbbbbbb@naver.com"
slack:
slack_webhook_url: "https://hooks.slack.com/services/T~~~~~~~~~~~~~~~~~U~~~9B1OvKw"
slack_username_override: 'h~~~~~~~~~~~~'
slack_channel_override: '#elastalert'
slack_emoji_override: ':pizza:'
ㄴㄴslack은 webhook연결참조하기~!! 참조로 이메일은 알람이 안뜨고 슬렉에서만왔다.
이렇게 rule들을 많이 띄워준다.
그리고 마지막으로 이 yaml은 발생건수가 100000000개 이하이면 알람이온다!!!!!!!!!!!!
use_terms_query를 사용해서 필터를 안써도된다.
이렇게 해주면 좀 기다리다보면 슬렉에서 알람이온다.
slack.yaml
name: flaterrornumber
type: flatline
index: logstash-*
threshold: 10000000000
timeframe:
hours: 1
use_count_query: true
use_terms_query: false
doc_type: "doc"
alert:
- "email"
- "slack"
email:
- "bbbbbbbbbbbb@naver.com"
slack:
slack_webhook_url: "https://hooks.slack.com/services/T0136~~~~~~~~~~~~~~~~2"
slack_username_override: 'hyo~~~~~~~~~~57'
slack_channel_override: '#elastalert'
slack_emoji_override: ':pizza:'
'<수업> > 과제' 카테고리의 다른 글
Isolation forest + lstm autoencoder anomaly detection (0) | 2021.12.24 |
---|---|
Elastalert 실행 (0) | 2021.01.15 |
SSH 원격파일을 로컬파일로 다운로드하기 (대용량 파일) (0) | 2021.01.15 |
ELK 작동순서 + Elasticsearch 명령어 윈도우 (0) | 2021.01.15 |
Software Architecture Style 조사하기 - Elasticsearch (0) | 2021.01.13 |