๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Spring/Spring Boot

Actuator (์•ก์ธ„์—์ดํ„ฐ)

by Soono991 2023. 4. 2.
๐Ÿ’ก์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” Spring Boot์˜ Actuator (์•ก์ธ„์—์ดํ„ฐ)์— ๋Œ€ํ•ด์„œ ์ •๋ฆฌํ•ด ๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.
๐Ÿ’ก์ด๋ฒˆ ํฌ์ŠคํŒ…์˜ ํ•ต์‹ฌ์€ Spring Boot์˜ Actuator๋ž€ ๋ฌด์—‡์ธ์ง€, ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์— ์ดˆ์ ์„ ๋งž์ท„๊ธฐ ๋•Œ๋ฌธ์— ์กฐ๊ธˆ ๋” ์ž์„ธํ•œ ๋‚ด์šฉ์€ ์ถ”ํ›„ ๋”ฐ๋กœ ์ •๋ฆฌํ•ด ๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

 

์œ„์™€ ๊ฐ™์€ ์ด์œ ๋กœ ์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ ์ •๋ฆฌํ•  ๋‚ด์šฉ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

  • Actuator๋ž€?
  • Actuator ์‚ฌ์šฉํ•˜๊ธฐ
  • Actuator Endpoint
  • Enabling Endpoints
  • Exposing Endpoints
  • Implementing Custom Endpoint

 

Actuator (์•ก์ธ„์—์ดํ„ฐ) ๋ž€?

actuator๋ฅผ ๊ฐ„๋‹จํ•˜๊ฒŒ ์ •์˜ํ•˜๋ฉด Spring Boot ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ์ œ์–ดํ•˜๊ณ  ๋ชจ๋‹ˆํ„ฐ๋งํ•˜๊ธฐ ์œ„ํ•œ ๋„๊ตฌ๋ผ๊ณ  ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

actuator๋ฅผ ์‚ดํŽด๋ณด๋ฉด Production-ready Features (ํ”„๋กœ๋•์…˜ ์ค€๋น„ ๊ธฐ๋Šฅ)๋ผ๋Š” ๋‹จ์–ด๊ฐ€ ๋“ฑ์žฅํ•ฉ๋‹ˆ๋‹ค.

 

Production-ready Features (ํ”„๋กœ๋•์…˜ ์ค€๋น„ ๊ธฐ๋Šฅ)

Spring Boot ๊ณต์‹ ๋ฌธ์„œ์—์„œ๋Š” ํ”„๋กœ๋•์…˜ ์ค€๋น„ ๊ธฐ๋Šฅ์— ๋Œ€ํ•ด ์•„๋ž˜์™€ ๊ฐ™์ด ์„ค๋ช…ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

Shttps://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html#actuator.enabling

Spring Boot์—๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ํ”„๋กœ๋•์…˜์œผ๋กœ ํ‘ธ์‹œํ•  ๋•Œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜๊ณ  ๊ด€๋ฆฌํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋˜๋Š” ์—ฌ๋Ÿฌ ๊ฐ€์ง€ ์ถ”๊ฐ€ ๊ธฐ๋Šฅ์ด ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.
HTTP ์—”๋“œํฌ์ธํŠธ ๋˜๋Š” JMX๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๊ด€๋ฆฌํ•˜๊ณ  ๋ชจ๋‹ˆํ„ฐ๋งํ•˜๋„๋ก ์„ ํƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
auditing, health ๋ฐ metrics ์ˆ˜์ง‘์„ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์— ์ž๋™์œผ๋กœ ์ ์šฉํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

actuator๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ๋งค์šฐ ๊ฐ„๋‹จํ•ฉ๋‹ˆ๋‹ค.

Spring Boot์—์„œ ์ œ๊ณตํ•˜๋Š” starter-actuator ์˜์กด์„ฑ์„ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ๋งŒ์œผ๋กœ actuator ๊ธฐ๋Šฅ์„ ์‰ฝ๊ฒŒ ํ™œ์„ฑํ™” ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

// maven
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
</dependencies>

// gradle
dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
}

๐Ÿ’กActuator
actuator๋Š” ๋ฌด์–ธ๊ฐ€๋ฅผ ์›€์ง์ด๊ฑฐ๋‚˜ ์ œ์–ดํ•˜๊ธฐ ์œ„ํ•œ ๊ธฐ๊ณ„ ์žฅ์น˜๋ฅผ ๊ฐ€๋ฆฌํ‚ค๋Š” ์ œ์กฐ ์šฉ์–ด์ž…๋‹ˆ๋‹ค.
actuator๋Š” ์ž‘์€ ๋ณ€ํ™”๋กœ ๋งŽ์€ ์–‘์˜ ๋™์ž‘์„ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

 

actuator endpoint๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜๊ณ  ์ƒํ˜ธ ์ž‘์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
Spring Boot์—๋Š” ์—ฌ๋Ÿฌ ๊ฐ€์ง€ ๊ธฐ๋ณธ ์ œ๊ณต endpoint๊ฐ€ ํฌํ•จ๋˜์–ด ์žˆ์œผ๋ฉฐ ์‚ฌ์šฉ์ž๊ฐ€ ์ง์ ‘ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์˜ˆ๋ฅผ ๋“ค์–ด health endpoint๋Š” ๊ธฐ๋ณธ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ health ์ •๋ณด๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

๊ฐ ๊ฐœ๋ณ„ endpoint๋ฅผ ํ™œ์„ฑํ™” ๋˜๋Š” ๋น„ํ™œ์„ฑํ™”ํ•˜๊ณ  HTTP ๋˜๋Š” JMX๋ฅผ ํ†ตํ•ด ๋…ธ์ถœ(์›๊ฒฉ ์•ก์„ธ์Šค ๊ฐ€๋Šฅ)ํ•  โ€‹โ€‹์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
endpoint๋Š” ํ™œ์„ฑํ™”๋˜๊ณ  ๋…ธ์ถœ๋œ ๊ฒฝ์šฐ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๊ฒƒ์œผ๋กœ ๊ฐ„์ฃผ๋ฉ๋‹ˆ๋‹ค.
๊ธฐ๋ณธ ์ œ๊ณต endpoint๋Š” ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๊ฒฝ์šฐ์—๋งŒ ์ž๋™ ๊ตฌ์„ฑ๋ฉ๋‹ˆ๋‹ค.
๋Œ€๋ถ€๋ถ„์˜ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์€ endpoint์˜ ID์™€ ์ ‘๋‘์‚ฌ /actuator๊ฐ€ URL์— ๋งคํ•‘๋˜๋Š” HTTP๋ฅผ ํ†ตํ•œ ๋…ธ์ถœ์„ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ๊ธฐ๋ณธ์ ์œผ๋กœ health endpoint๋Š” /actuator/health์— ๋งคํ•‘๋ฉ๋‹ˆ๋‹ค.

 

์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” endpoint

์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” endpoint๋Š” ์œ„์™€ ๊ฐ™์œผ๋ฉฐ ํ”„๋กœ์ ํŠธ ์‹คํ–‰ ํ›„ /actuator url๋กœ ์ ‘์†ํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด endpoint๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๊ทธ๋ฆฌ๊ณ  Spring Boot ๊ณต์‹ ๋ฌธ์„œ์— ๋”ฐ๋ฅด๋ฉด Web ํ™˜๊ฒฝ์—์„œ๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด ์ถ”๊ฐ€ endpoint๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ’กActuator Endpoints์— ๋Œ€ํ•ด ์ž์„ธํ•œ ๋‚ด์šฉ์„ ํ™•์ธํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด, ์•„๋ž˜ ๋งํฌ๋ฅผ ํ™•์ธํ•ด๋ณด์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

HTML ๋ฌธ์„œ
PDF ๋ฌธ์„œ

 

 

Enabling Endpoints

endpoint ์ค‘ shutdown์„ ์ œ์™ธํ•œ ๋ชจ๋“  endpoint๊ฐ€ ๊ธฐ๋ณธ์ ์œผ๋กœ ํ™œ์„ฑํ™”๋˜์–ด ์žˆ๋‹ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. 

์—”๋“œํฌ์ธํŠธ ํ™œ์„ฑํ™”๋ฅผ ๊ตฌ์„ฑํ•˜๋ ค๋ฉด management.endpoint.<id>.enabled ์†์„ฑ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

management:
  endpoint:
    shutdown:
      enabled: true // shutdown endpoint ํ™œ์„ฑํ™”
    health:
      enabled: false // health endpoint ๋น„ํ™œ์„ฑํ™”

 

๋น„ํ™œ์„ฑํ™”๋ฅผ ํ•˜๋ฉด endpoint๊ฐ€ ๋…ธ์ถœ๋˜์ง€ ์•Š์ง€๋งŒ, ํ™œ์„ฑํ™”์˜ ๊ฒฝ์šฐ ๋…ธ์ถœ ์—ฌ๋ถ€๋„ ์„ค์ •์„ ํ•ด์•ผ์ง€๋งŒ ๋น„๋กœ์†Œ endpoint๋กœ ๋…ธ์ถœ๋ฉ๋‹ˆ๋‹ค.

 

Exposing Endpoints

๊ธฐ๋ณธ์ ์œผ๋กœ๋Š” health endpoint๋งŒ ๋…ธ์ถœ๋ฉ๋‹ˆ๋‹ค. endpoint์—๋Š” ๋ฏผ๊ฐํ•œ ์ •๋ณด๋“ค์ด ํฌํ•จ๋  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ ์–ธ์ œ ๋…ธ์ถœํ• ์ง€ ์‹ ์ค‘ํ•˜๊ฒŒ ๊ณ ๋ คํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

 

๐Ÿ’กEndpoint์˜ ๋ฏผ๊ฐํ•œ ์ •๋ณด, ์ฆ‰ ๋ณด์•ˆ๊ณผ ๊ด€๋ จ๋œ ๋‚ด์šฉ์— ๋Œ€ํ•ด์„œ๋Š” ์šฐ์•„ํ•œ ํ˜•์ œ๋“ค ๊ธฐ์ˆ  ๋ธ”๋กœ๊ทธ์— ์ •๋ฆฌ๋œ ๋‚ด์šฉ์ด ์žˆ๋Š”๋ฐ ์ฐธ๊ณ ํ•ด๋ณด์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

 

๋ชจ๋“  endpoints๋ฅผ includeํ•˜๊ฑฐ๋‚˜ exclude ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” *(asterisk)๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•˜๋Š”๋ฐ,
YAML์—์„œ *(asterisk)๋Š” ํŠน๋ณ„ํ•œ ์˜๋ฏธ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.
๋”ฐ๋ผ์„œ YAML์—์„œ *(asterisk)๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” "(๋”ฐ์˜ดํ‘œ)๋กœ ๊ฐ์‹ธ์ค˜์•ผ ํ•ฉ๋‹ˆ๋‹ค.

ex)
* → X
"*" → O

 

์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ๊ณต๊ฐœ์ ์œผ๋กœ ๋…ธ์ถœ๋œ ๊ฒฝ์šฐ endpoint๋„ ๋ณดํ˜ธํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

 

 

endpoint๊ฐ€ ๋…ธ์ถœ๋˜๋Š” ๊ฒฝ์šฐ์— ๋Œ€ํ•œ ์ž์ฒด ์ „๋žต์„ ๊ตฌํ˜„ํ•˜๋ ค๋Š” ๊ฒฝ์šฐ EndpointFilter ๋นˆ์„ ๋“ฑ๋กํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

Implementing Custom Endpoints

Custom Endpoint๋ฅผ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด์„œ๋Š” @Endpoint annotation์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

Spring Boot๋Š” @Endpoint๊ฐ€ ์žˆ๋Š” @Bean์„ ์ถ”๊ฐ€ํ•˜๋ฉด @ReadOperation, @WriteOperation, @DeleteOperation annotation์ด ๋‹ฌ๋ฆฐ ๋ฉ”์„œ๋“œ๋“ค์„ ๋ชจ๋‘ JMX, HTTP์— ์ž๋™์œผ๋กœ ๋…ธ์ถœํ•ฉ๋‹ˆ๋‹ค.

 

 

endpoint์— ๋Œ€ํ•œ ์ž‘์—…์€ ๋งค๊ฐœ ๋ณ€์ˆ˜๋ฅผ ํ†ตํ•ด ์ž…๋ ฅ ๋ฐ›์Šต๋‹ˆ๋‹ค. ์›น์„ ํ†ตํ•ด ๋…ธ์ถœ๋  ๋•Œ ์ด๋Ÿฌํ•œ ๋งค๊ฐœ๋ณ€์ˆ˜์˜ ๊ฐ’์€ URL์˜ ์ฟผ๋ฆฌ ๋งค๊ฐœ๋ณ€์ˆ˜์™€ JSON Request Body์—์„œ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค. 

 

 

endpoint๋Š” ๊ธฐ์ˆ ์— ๊ตฌ์• ๋ฐ›์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ๋ฉ”์„œ๋“œ ์„œ๋ช…์— ๋‹จ์ˆœ ํ˜•์‹๋งŒ ์ง€์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํŠนํžˆ ์ด๋ฆ„ ๋ฐ ์นด์šดํ„ฐ ์†์„ฑ์„ ์ •์˜ํ•˜๋Š” CustomData ์œ ํ˜•์œผ๋กœ ๋‹จ์ผ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์„ ์–ธํ•˜๋Š” ๊ฒƒ์€ ์ง€์›๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

// ์ด ๋ฐฉ์‹์€ OK
@WriteOperation
public void updateData(String name, int counter) {
    // injects "test" and 42
}

// ์ด ๋ฐฉ์‹์€ Not OK
// Object๋กœ ๋ฌถ์–ด์„œ ๋ฐ›์„ ์ˆ˜๋Š” ์—†์Œ
@WriteOperation
public void updateData(CustomData customData) {
    // Not OK
}โ€‹

 

predicate์˜ ๊ฒฝ๋กœ๋Š” endpoint์˜ ID์™€ ์›น์— ๋…ธ์ถœ๋œ endpoint์˜ ๊ธฐ๋ณธ ๊ฒฝ๋กœ์— ์˜ํ•ด ๊ฒฐ์ •๋ฉ๋‹ˆ๋‹ค.
๊ธฐ๋ณธ ๊ธฐ๋ณธ ๊ฒฝ๋กœ๋Š” /actuator์ž…๋‹ˆ๋‹ค.
์˜ˆ๋ฅผ ๋“ค์–ด ID๊ฐ€ sessions์ธ endpoint๋Š” predicate์˜ ๊ฒฝ๋กœ๋กœ /actuator/sessions๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

 

@Selector๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ž‘์—… ๋ฉ”์„œ๋“œ์˜ ํ•˜๋‚˜ ์ด์ƒ์˜ ๋งค๊ฐœ ๋ณ€์ˆ˜์— ์ฃผ์„์„ ๋‹ฌ์•„ ๊ฒฝ๋กœ๋ฅผ ์ถ”๊ฐ€๋กœ ์‚ฌ์šฉ์ž ์ง€์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์ด๋Ÿฌํ•œ ๋งค๊ฐœ๋ณ€์ˆ˜๋Š” ๊ฒฝ๋กœ ์กฐ๊ฑด์ž์— ๊ฒฝ๋กœ ๋ณ€์ˆ˜๋กœ ์ถ”๊ฐ€๋ฉ๋‹ˆ๋‹ค.
๋ณ€์ˆ˜์˜ ๊ฐ’์€ endpoint ์ž‘์—…์ด ํ˜ธ์ถœ๋  ๋•Œ ์ž‘์—… ๋ฉ”์„œ๋“œ๋กœ ์ „๋‹ฌ๋ฉ๋‹ˆ๋‹ค.
๋‚˜๋จธ์ง€ ๋ชจ๋“  ๊ฒฝ๋กœ ์š”์†Œ๋ฅผ ์บก์ฒ˜ํ•˜๋ ค๋ฉด ๋งˆ์ง€๋ง‰ ๋งค๊ฐœ ๋ณ€์ˆ˜์— @Selector(Match=ALL_REMAINING)๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ  String[]๊ณผ ๋ณ€ํ™˜ ํ˜ธํ™˜๋˜๋Š” ์œ ํ˜•์œผ๋กœ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

Request Body๋ฅผ ์‚ฌ์šฉํ•˜๋Š” @WriteOperation(HTTP POST)์˜ ๊ฒฝ์šฐ predicate์˜ consumes๋Š”
application/vnd.spring-boot.actuator.v2+json ๋˜๋Š” application/json์ž…๋‹ˆ๋‹ค.
๋‹ค๋ฅธ ๋ชจ๋“  ์ž‘์—…์˜ โ€‹โ€‹๊ฒฝ์šฐ consumes๊ฐ€ ๋น„์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

 

predicate์˜ produces๋Š” @DeleteOperation, @ReadOperation ๋ฐ @WriteOperation ์ฃผ์„์˜ ์ƒ์„ฑ ํŠน์„ฑ์— ์˜ํ•ด ๊ฒฐ์ •๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์†์„ฑ์€ ์„ ํƒ ์‚ฌํ•ญ์ž…๋‹ˆ๋‹ค.
์‚ฌ์šฉํ•˜์ง€ ์•Š์œผ๋ฉด produces๊ฐ€ ์ž๋™์œผ๋กœ ๊ฒฐ์ •๋ฉ๋‹ˆ๋‹ค.

์ž‘์—… ๋ฉ”์„œ๋“œ๊ฐ€ void ๋˜๋Š” Void๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋ฉด produces๊ฐ€ ๋น„์–ด ์žˆ์Šต๋‹ˆ๋‹ค.
์ž‘์—… ๋ฉ”์„œ๋“œ๊ฐ€ org.springframework.core.io.Resource๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ๊ฒฝ์šฐ consumes๋Š” application/octet-stream์ž…๋‹ˆ๋‹ค.
๋‹ค๋ฅธ ๋ชจ๋“  ์ž‘์—…์˜ โ€‹โ€‹๊ฒฝ์šฐ produces๋Š” application/vnd.spring-boot.actuator.v2+json ๋˜๋Š” application/json์ž…๋‹ˆ๋‹ค.

 

๊ณต์‹ ๋ฌธ์„œ๋ฅผ ํ† ๋Œ€๋กœ Custom Endpoint๋ฅผ ๋งŒ๋“ค์–ด๋ณด๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ๋งŒ๋“ค์–ด๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

@Component
@Endpoint(id = "my")
public class MyEndPoint {

    private String value = "hello world";

    @ReadOperation
    public String getValue() {
        return value;
    }

    @WriteOperation
    public void setValue(String value) {
        this.value = value;
    }

    @DeleteOperation
    public void deleteValue() {
        this.value = "hello world";
    }
}

 

Custom Endpoint๋ฅผ ๋งŒ๋“  ํ›„ ํ”„๋กœ์ ํŠธ๋ฅผ ์‹คํ–‰ํ•˜์—ฌ /actuator๋ฅผ ํ™•์ธํ•ด๋ณด๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ์ง์ ‘ ๋งŒ๋“  endpoint๊ฐ€ ๋…ธ์ถœ๋˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” ์ฒ˜์Œ์— ์–ธ๊ธ‰ํ–ˆ๋˜ ๋Œ€๋กœ ๊ณต์‹ ๋ฌธ์„œ๋ฅผ ํ† ๋Œ€๋กœ ๊ฐ„๋‹จํ•˜๊ฒŒ actuator๊ฐ€ ๋ฌด์—‡์ธ์ง€, ์–ด๋–ป๊ฒŒ ์‚ฌ์šฉํ•ด์•ผ ํ•˜๋Š”์ง€ ๊ทธ๋ฆฌ๊ณ  endpoint์—๋Š” ์–ด๋–ค ๊ฒƒ๋“ค์ด ์žˆ๋Š”์ง€์— ๋Œ€ํ•ด ์•Œ์•„๋ดค์Šต๋‹ˆ๋‹ค.

 

๊ณต์‹ ๋ฌธ์„œ๋ฅผ ์ฝ๋‹ค๋ณด๋‹ˆ endpoint ๋ณ„๋กœ ๋” ์ƒ์„ธํ•œ ๋‚ด์šฉ๋“ค์ด ์žˆ๊ณ  security ์„ค์ • ๋ถ€๋ถ„๋„ ์žˆ์—ˆ๋Š”๋ฐ, ์ด๋Ÿฐ ๋ถ€๋ถ„๋“ค์€ ์ถ”ํ›„ ๋” ์ž์„ธํ•˜๊ฒŒ ๊ณต๋ถ€ํ•œ ํ›„ ๋”ฐ๋กœ ํฌ์ŠคํŒ…์„ ์ž‘์„ฑํ•ด ๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

๋Œ“๊ธ€