-
Notifications
You must be signed in to change notification settings - Fork 0
Pinpoint의 알람을 슬랙에 전송하는 기능 구현 #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
| import java.util.List; | ||
|
|
||
| /** | ||
| * https://api.slack.com/reference/block-kit |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 | |||
There was a problem hiding this comment.
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 채널 만들어져있고, 해당 채널에 메시지가 갑니다.
요구 사항
초기에는 어플리케이션에서 400이나 500에러를 발생시키면 핀포인트가 이를 감지해 슬랙으로 보내주는 것을 생각했었는데요.
핀포인트가 기능을 제공하긴 하지만 디테일한 예외 정보(ex. 예외 타입, 메시지, Status Code, ...)는 주지 않아서 핀포인트로는 서버의 인프라 적인 요소만 봐야할 것 같습니다 😥
추가로 PINPOINT 서버도 완료했습니다.
URL은 http://dev.homework.codes:8090/ 입니다.
현재 방화벽 설정이 덜 되어서 아마 접근이 안될거에요.
추후 해당 설정까지 끝내면 또 말씀드릴게요.