본문 바로가기

Elastic Stack

elastalert rules 파일

#name : 알람명 고유한 이름으로 사용 name: test-alert #type : 알람의 타입, 다양한 타입이 있는데 이것은 다음 게시글에 따로 정리하겠다.. #frequency - Y 시간에 X 개의 이벤트가있는 위치 일치할때 노티, timeframe, num_events 옵션을 사용한다. type: frequency #index : 해당 rule이 탐색할 elasticsearch의 인덱스 index: filebeat-* # use_strftime_index: true #num_events : 정해진 time_frame 시간동안 일정 횟수이상 document 매치시 알람 발생. num_events: 1 #timeframe : num_events 카운트를측정할 시간 단위 timeframe: hours: 1 #filter : 인덱스에서 매칭시킬 조건. #filter 조건도 자세하게 다음 게시글에 다루겠음.. filter: - query: query_string: query: "src_country: cn" #alert_text: 알람 메시지 형식 alert_text : "\nAttack_name: {0} \nSrc_IP: {1} \nDst_IP: {2} \n Dst_Port: {3}" #alert_text_type: "alert_text_only" - 인덱스 전체 필드 중 설정한 필드만 알람 받음 alert_text_type: "alert_text_only" #alert_text_args : 알람 받을 인덱스 필드 리스트 형식 alert_text_args : ["attack_name', "src_ip", "dst_ip", "dst_port"] # alert : 알람 받을 채널 alert: - command - email - telegram - slack # 알람 행위 command: "echo test >> /home/alert.log" email : test@test.kr telegram_bot_token : "122499....." telegram_room_id : "8011...." slack_webhook_url: "https://hooks.slack.com/services/SLA......." slack_username_override: "ElastAlert-Bot" slack_channel_override: "#monitoring" slack_emoji_override: ":robot_face:" slack_msg_color: "danger"

1. type
https://elastalert.readthedocs.io/en/latest/ruletypes.html#frequency

Rule Types and Configuration Options — ElastAlert 0.0.1 documentation

Each rule may have any number of alerts attached to it. Alerts are subclasses of Alerter and are passed a dictionary, or list of dictionaries, from ElastAlert which contain relevant information. They are configured in the rule configuration file similarly

elastalert.readthedocs.io

(1) frequency
Y 시간에 X 개의 이벤트가있는 위치 일치

(2) spike
이벤트 비율이 증가하거나 감소 할 때 일치
(3) flatline
Y 시간에 X 개 미만의 이벤트가있을 때 일치
(4) blacklist / whitelist
특정 필드가 블랙리스트 / 화이트리스트와 일치 할 때 일치
(5) any
주어진 필터와 일치하는 모든 이벤트에서 일치
(6) change
필드에 일정 시간 내에 두 개의 다른 값이있을 때 일치
(8) new_term
전에 본 적이없는 용어가 필드에 나타날 때 일치
(9) cardinality
필드의 고유 값 수가 임계 값보다 높거나 낮을 때 일치


2. filter
filter : 인덱스에서 매칭시킬 조건.
(1) query_string : 루씬 쿼리 포맷을 사용하는 방식
filter:
- query:
query_string:
query: "username: bob"
- query:
query_string:
query: "_type: login_logs"
- query:
query_string:
query: "field: value OR otherfield: othervalue"
- query:
query_string:
query: "this: that AND these: those"

(2) term : 지정한 필드에 매치할 값을 지정하는 방식
filter:
- term: name_field: "bob"
- term: _type: "login_logs"
(3) terms : term과 같은 개념인데 매칭시킬 값을 여러개로 할수있다. (배열식)
filter:
- terms:
field: ["value1", "value2"] # value1 OR value2
- terms:
fieldX: ["value1", "value2"] fieldY: ["something", "something_else"] fieldZ: ["foo", "bar", "baz"]
(4) wildcard : * 문자를 사용하여 유사값을 매칭 시킬수있는 방식
filter:
- query:
wildcard: field: "foo*bar"

(5) range : 숫자형식 필드에 대해 범위를 지정하는 방식
filter: - range: status_code: from: 500 to: 599

'Elastic Stack' 카테고리의 다른 글

Elasticsearch transform / rollup  (0) 2021.09.10
[Elasticsearch] 싱글노드에서 멀티노드구성으로  (0) 2021.09.07
elastalert 설치하기  (0) 2021.05.15
Elasticsearch 쿼리  (0) 2021.05.13
ELK opendistro-alert Slack 연동  (0) 2021.05.07