'2021/11/18'에 해당되는 글 2건

  1. 2021.11.18 [Logstash] filter split 예제
  2. 2021.11.18 [Shell] for loop example

[Logstash] filter split 예제

Elastic/Logstash 2021. 11. 18. 12:12

참고문서)

https://www.elastic.co/guide/en/logstash/current/plugins-filters-split.html

https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html#plugins-filters-mutate-split

 

예제코드)

라인단위로 정보가 작성 되어 있을 때

데이터 예시)
1|A|가
2|B|나

filter {
	split { }

	mutate {
		split => { "message" => "|" }
		add_field => {
			"first" => "%{[message][0]}"
			"second" => "%{[message][1]}"
			"third" => "%{[message][2]}"
		}
	}
}

 

:

[Shell] for loop example

ITWeb/개발일반 2021. 11. 18. 11:25

간혹 서버간 ssh tunneling 을 위해 pub key 를 등록 해야 할 일이 있습니다.

노가다 하기 귀찮으니까 instance 목록만 가지고 쭈욱 돌리면 되겠죠.

 

#!/bin/bash

PUB="abcdefg"
HOSTS=("ip1" "ip2" "ip3" ...)

for host in "${HOSTS[@]}"
do
  echo "ssh -o StrictHostKeychecking=no USER@$host \"echo '$PUB' >> .ssh/authorized_keys\""
  ssh -o StrictHostKeychecking=no USER@$host "echo '$PUB' >> .ssh/authorized_keys"
done

이런것도 맨날 기억을 못해서 기록을 합니다.

: