Skip to content

Conversation

@hsik0225
Copy link
Contributor

@hsik0225 hsik0225 commented May 1, 2023

요구 사항

  • 서버의 CPU, 메모리 등의 사용량이 Pinpoint에 설정해놓은 임계치에 도달할 경우 슬랙에 알람을 보냅니다.

초기에는 어플리케이션에서 400이나 500에러를 발생시키면 핀포인트가 이를 감지해 슬랙으로 보내주는 것을 생각했었는데요.
핀포인트가 기능을 제공하긴 하지만 디테일한 예외 정보(ex. 예외 타입, 메시지, Status Code, ...)는 주지 않아서 핀포인트로는 서버의 인프라 적인 요소만 봐야할 것 같습니다 😥

추가로 PINPOINT 서버도 완료했습니다.
URL은 http://dev.homework.codes:8090/ 입니다.
현재 방화벽 설정이 덜 되어서 아마 접근이 안될거에요.
추후 해당 설정까지 끝내면 또 말씀드릴게요.

@hsik0225 hsik0225 requested a review from suhyunsim May 1, 2023 00:07
import java.util.List;

/**
* https://api.slack.com/reference/block-kit
Copy link
Contributor Author

@hsik0225 hsik0225 May 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

block kit 데모 사이트입니다.

https://app.slack.com/block-kit-builder/T02TM7502NM#%7B%22type%22:%22home%22,%22blocks%22:%5B%5D%7D

block kit은 사이트에서 보이다시피 JSON으로 슬랙의 메시지를 표현해줘요!

@AllArgsConstructor
@Entity
@Table(indexes = {@Index(name = "IDX_KEY_CODE", columnList = "keyCode", unique = true)})
public class Slack extends DeletableEntity {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slack 엔티티를 따로 만든 이유는 추후 다른 모니터링 도구(ex. 센트리, 그라파나, ...)에서 슬랙으로 알림을 보낼 수 있기 때문입니다.
슬랙 채널마다 고유의 경로(path)를 가지고 있습니다.
그걸 yml파일에 적어놓을 수도 있지만 그렇게 하면 path가 변경될 때마다 어플리케이션을 새로 빌드해야 합니다.
설정 하나 변경하려고 어플리케이션을 새로 띄우는 건 좋지 않아보여 DB에서 관리하도록 했습니다.

@@ -0,0 +1,37 @@
### send infra emergency
POST {{host}}/api/webhook/from/pinpoint/to/slack
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intellij의 HttpClient로 Slack에 메세지 보내는 것을 테스트할 수 있습니다.
어플리케이션을 로컬에서 띄운 후 HttpClient의 환경 설정을 local로 한 후 실행시키면 됩니다.
Homework 워크 스페이스에 infra-emergency 채널 만들어져있고, 해당 채널에 메시지가 갑니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants