SpringBoot Management
Actuator
์คํ๋ง ๋ถํธ ๊ณต์๋ฌธ์(https://docs.spring.io/spring-boot/docs/2.1.8.RELEASE/reference/html/production-ready.html)
Spring Boot includes a number of additional features to help you monitor and manage your application when you push it to production. You can choose to manage and monitor your application by using HTTP endpoints or with JMX. Auditing, health, and metrics gathering can also be automatically applied to your application.
์คํ๋ง ๋ถํธ์๋ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ด์์ ์ฌ๋ ธ์ ๋, ํด๋น ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ชจ๋ํฐ๋ง ํด์ฃผ๊ณ ๊ด๋ฆฌํด์ฃผ๋ ๋ค์์ ๊ธฐ๋ฅ๋ค์ด ์๋ค ๊ทธ๊ฒ์ Actuator๋ผ๊ณ ๋ถ๋ฅธ๋ค. ์ฌ์ฉ์๋ ๋ชจ๋ํฐ๋ง, ๊ด๋ฆฌํด์ฃผ๋ ๊ธฐ๋ฅ์ธ actuator๋ฅผ HTTP endpoints๋ JMX์ ํตํด์ ์ฌ์ฉํ ์ ์๋ค.
์ ์ฉ
์๋ ๊ฒ 2๊ฐ์ ์์กด์ฑ์ ์ถ๊ฐํด์ฃผ๊ณ ์ ํ๋ฆฌ์ผ์ด์ ์ ์คํํ๊ณ
/actuator
์ ์ฃผ์๋ก ์ ์ํ๊ฒ ๋๋ฉด ํ์ฌ ์ ํ๋ฆฌ์ผ์ด์ ์ ํตํด์ ์ ์ํ ์ ์๋ ๋ชจ๋ ์๋ํฌ์ธํธ๋ค์ ๋ํ ์ ๋ณด๋ค์ ์ ๊ณตํด์ค๋ค โ parse๋์ง ์์ ์ํ๋ก ์ถ๋ ฅ๋๊ธฐ ๋๋ฌธ์ ๋ธ๋ผ์ฐ์ ์์ json parser ํ๋ฌ๊ทธ์ธ์ ํตํด์ ๋ ๊ฐ๋ ์ฑ ์ข๊ฒ ํ์ธํ์
๊ธฐ๋ณธ์ ์ผ๋ก ์ ๊ณตํด์ฃผ๋ ์๋ ํฌ์ธํธ๋ค์ actuator, health, info๊ฐ ์๊ณ ์ถ๊ฐ์ ์ผ๋ก ์ฌ์ฉํ๋ ๋ชจ๋ ์๋ ํฌ์ธํธ๋ค์ actuator/{์๋ํฌ์ธํธ} ์ด๋ ๊ฒ ์ฌ์ฉํ๋ค.
actuator : ํ์ฌ ์ ํ๋ฆฌ์ผ์ด์ ์์ ์ ๊ณตํด์ฃผ๊ณ ์๋ ๋ชจ๋ endpoint๋ฅผ ๋ณด์ฌ์ค
health : ํ์ฌ ๊ตฌ๋ ์ค์ธ ์ ํ๋ฆฌ์ผ์ด์ ์ ๊ฑด๊ฐ ์ํ์ ๋ํด์ ํ์
info : ๊ฐ๋ฐ์๊ฐ ์ ์ํ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ ๋ณด๋ค์ ํ์
์ฌ์ฉ ๋ฐฉ๋ฒ
application.properties์ ์ฌ์ฉํ๊ณ ์ถ์ ๊ฑธ include, excludeํ๋ฉด ๋จ
์ํ๋ ํฌ๊ฒ UP๊ณผ DOWN์ ๋ณผ ์ ์๋๋ฐ UP์ ์์คํ ์ด ์ ์๋ ์ค์ด๊ณ ์ ๊ทผ์ด ๊ฐ๋ฅํ๋ค๋ ๋ป์ด๊ณ DOWN์ ์์คํ ์ด ์๋ ์ค์ด์ง ์๊ณ ์ ๊ทผํ ์ ์๋ค๋ ์๋ฏธ์ด๋ค
์ฌ๋ฌ๊ฐ์ง actuator์์ ์ ๊ณตํด์ฃผ๋ ๋ค์ํ ์๋ ํฌ์ธํธ๋ค์ด ์กด์ฌํ๊ณ ํ์ํ ๊ฒ๋ค์ include์ ์ถ๊ฐํด์ค์ ์ฌ์ฉํ๋ฉด ๋๊ฒ ๋ค..!
Spring Boot Admin
์๋์ spring boot ์์ ์ ๊ณตํด์ฃผ๋ actuator๋ฅผ ๊น๋ํ UI๋ก ๋ชจ๋ํฐ๋ง ํ ์ ์๋๋ก ์ ๊ณตํด์ฃผ๋ ์๋น์ค์ด๋ค
ํฌ๊ฒ ์๋ฒ์ ํด๋ผ์ด์ธํธ๋ก ๋๋ ์ง๋๋ฐ โ ํญ์ ์๋ฒ์ ํด๋ผ์ด์ธํธ์ ๋ฒ์ ์ ๋ง์ถฐ์ค์ผํ๋ ๊ฒ์ด ํฌ์ธํธ`
์ผ๋จ ์๋ฒ ๋จผ์
์ผ๋จ์ ์ฌ์ฉํ๊ธฐ ์ํด์๋ build.gradle์ ์ถ๊ฐ + spring security๋ ์ฌ์ฉํด์ผํจ
์ถ๊ฐ์ ์ผ๋ก application.properties์ ํ์ํ ์ธํ ๋ค์ ์ถ๊ฐ
์ดํ์๋ ํด๋น ์ ํ๋ฆฌ์ผ์ด์ ์ @SpringBootApplication์ด ์๋ ์์น์ @EnableAdminServer๋ฅผ ํตํด์ UI๋ฅผ ์ฌ์ฉํ๊ฒ ๋ค๊ณ ์คํ๋ง์๊ฒ ์๋ ค์ค
๊ทธ๋ฆฌ๊ณ config ํ์ผ์ ๋ง๋ค์ด์ ์ํ๋ฆฌํฐ๋ฅผ ์ ์ฉ
์๋ฒ์ ์ค์ ์ ์ด๋ ๊ฒ ํด๋๊ณ localhost:8080/applications ๋ก ์ ์ํด๋ณด๋ฉด ํ์ฌ 0๊ฐ์ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ณด์ฌ์ฃผ๊ณ ์๋ค๊ณ ํ์๋๋ค. ๊ทธ๋ ๊ธฐ ๋๋ฌธ์ ํด๋ผ์ด์ธํธ ์ฌ์ด๋์์๋ ์ถ๊ฐ๋ฅผ ํด์ค์ผํ๋ค
adminํ์ด์ง๋ฅผ ํตํด์ ๊ด๋ฆฌ๊ฐ ํ์ํ๋ค๊ณ ์๊ฐ์ด ๋๋ ์น ์ ํ๋ฆฌ์ผ์ด์ ์ด ํด๋ผ์ด์ธํธ๊ฐ ๋๋ ๊ฒ์ด๋ค
ํด๋ผ์ด์ธํธ ์ธก์์๋ application.properties์ ํ์ํ ๊ฐ๋ค ๋ช๊ฐ์ง๋ง ํด์ฃผ๋ฉด ๊ด๋ฆฌํ ์ ์์
์์ผ๋ก ์ฌ์ฉํ๋ฉด์ ๋ ์ถ๊ฐ์ ์ผ๋ก ์ฌ์ฉํ๋๊ฒ ์๋ค๋ฉด ๊ธฐ๋กํ์!
์ฐธ๊ณ
Last updated
Was this helpful?