{"id":3034,"date":"2021-08-22T12:10:01","date_gmt":"2021-08-22T03:10:01","guid":{"rendered":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=3034"},"modified":"2021-08-22T22:58:49","modified_gmt":"2021-08-22T13:58:49","slug":"spring-boot-app-monitoring-with-actuator","status":"publish","type":"post","link":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=3034","title":{"rendered":"Spring Boot App monitoring with Actuator"},"content":{"rendered":"<h1>Spring Boot App monitoring with Actuator<\/h1>\n<p><a href=\"https:\/\/meetup.toast.com\/posts\/237\">\ucc38\uc870<\/a><\/p>\n<p><a href=\"https:\/\/jongmin92.github.io\/2019\/12\/04\/Spring\/prometheus\/\">\ucc38\uc870<\/a><\/p>\n<h2>\ubaa9\ud45c<\/h2>\n<p>Spring Actuator \ub97c \uc774\uc6a9\ud574 Spring Boot App \uc744 \ubaa8\ub2c8\ud130\ub9c1\ud569\ub2c8\ub2e4.<\/p>\n<h2>Application \uc0dd\uc131<\/h2>\n<p>\uc571\uc744 \uc0dd\uc131\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-java\">@SpringBootApplication\n@RestController\npublic class Demo4Application {\n\n    public static void main(String[] args) {\n        SpringApplication.run(Demo4Application.class, args);\n    }\n\n    @GetMapping(&quot;\/&quot;)\n    public String hello() {\n        return &quot;Hello, World!&quot;;\n    }\n}<\/code><\/pre>\n<p>build.gradle<\/p>\n<pre><code class=\"language-gradle\">dependencies {\n    implementation &#039;org.springframework.boot:spring-boot-starter-actuator:2.5.3&#039;\n    implementation &#039;io.micrometer:micrometer-registry-prometheus:1.7.2&#039;\n}<\/code><\/pre>\n<p>application.yml<\/p>\n<pre><code class=\"language-bash\">spring:\n  application:\n    name: myapp\n\nmanagement:\n  endpoints:\n    web:\n      exposure:\n        include: health, info, prometheus\n  metrics:\n    tags:\n      application: ${spring.application.name}<\/code><\/pre>\n<p><a href=\"http:\/\/localhost:8080\/actuator\">http:\/\/localhost:8080\/actuator<\/a> \uc5d0\uc11c actuator \uac00 \ud65c\uc131\ud654\ub41c \uac83\uc744 \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<h2>prometheus \uc124\uce58<\/h2>\n<pre><code class=\"language-bash\">vi \/home\/ubuntu\/work\/actuator\/prometheus.yml\n---------------------\nglobal:\n  scrape_interval: 10s # 10\ucd08 \ub9c8\ub2e4 Metric\uc744 Pulling\n  evaluation_interval: 10s\n\nscrape_configs:\n  - job_name: &#039;spring-boot-app&#039;\n    metrics_path: &#039;\/actuator\/prometheus&#039; # Application prometheus endpoint\n    static_configs:\n      - targets: [&#039;localhost:8080&#039;] # Application host:port\n---------------------<\/code><\/pre>\n<pre><code class=\"language-bash\">sudo docker run \\\n    -d \\\n    -p 9090:9090 \\\n    -v \/home\/ubuntu\/work\/actuator\/prometheus.yml:\/etc\/prometheus\/prometheus.yml \\\n    --network host \\\n    --name prometheus \\\n    prom\/prometheus --config.file=\/etc\/prometheus\/prometheus.yml<\/code><\/pre>\n<p><code>jvm_memory_used_bytes<\/code> \ub97c \uc2e4\ud589\ud574 \ubcf4\uba74 \uc0ac\uc6a9\uc911\uc778 \uba54\ubaa8\ub9ac\ub97c \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/wp-content\/uploads\/2021\/08\/2021-08-22-01.png\"><img decoding=\"async\" src=\"https:\/\/www.skyer9.pe.kr\/wordpress\/wp-content\/uploads\/2021\/08\/2021-08-22-01.png\" alt=\"\" \/><\/a><\/p>\n<h2>grafana \uc5d0\uc11c \uc2dc\uac01\ud654\ud558\uae30<\/h2>\n<p>\uc544\ub798 \uba85\ub839\uc73c\ub85c grafana \ub97c \uc2e4\ud589\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">sudo docker run \\\n    -d \\\n    -p 3000:3000 \\\n    --network host \\\n    --name=grafana \\\n    grafana\/grafana<\/code><\/pre>\n<p>\ube44\ubc00\ubc88\ud638\ub97c \ubd84\uc2e4\ud588\uc744 \ub54c\ub294 \uc544\ub798 \uba85\ub839\uc744 \uc785\ub825\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">sudo docker exec grafana grafana-cli admin reset-admin-password admin<\/code><\/pre>\n<p>10280 \ub85c \ub300\uc2dc\ubcf4\ub4dc\ub97c \uc784\ud3ec\ud2b8 \ud569\ub2c8\ub2e4.<\/p>\n<p><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/wp-content\/uploads\/2021\/08\/2021-08-22-02.png\"><img decoding=\"async\" src=\"https:\/\/www.skyer9.pe.kr\/wordpress\/wp-content\/uploads\/2021\/08\/2021-08-22-02.png\" alt=\"\" \/><\/a><\/p>\n<h2>\uc2a4\ud2b8\ub808\uc2a4 \ud14c\uc2a4\ud2b8 \ud558\uae30<\/h2>\n<pre><code class=\"language-bash\">wget https:\/\/hey-release.s3.us-east-2.amazonaws.com\/hey_linux_amd64\nchmod 777 hey_linux_amd64\nsudo mv hey_linux_amd64 \/usr\/bin\/hey\n\nhey -help<\/code><\/pre>\n<p>5\ubd84\uac04 200\uac1c\uc758 \ub3d9\uc2dc \ucee4\ub125\uc158\uc744 \ud558\ub3c4\ub85d \ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">hey -z 5m -c 200 http:\/\/localhost:8080\/<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Spring Boot App monitoring with Actuator \ucc38\uc870 \ucc38\uc870 \ubaa9\ud45c Spring Actuator \ub97c \uc774\uc6a9\ud574 Spring Boot App \uc744 \ubaa8\ub2c8\ud130\ub9c1\ud569\ub2c8\ub2e4. Application \uc0dd\uc131 \uc571\uc744 \uc0dd\uc131\ud569\ub2c8\ub2e4. @SpringBootApplication @RestController public class Demo4Application { public static void main(String[] args) { SpringApplication.run(Demo4Application.class, args); } @GetMapping(&quot;\/&quot;) public String hello() { return &quot;Hello, World!&quot;; } } build.gradle dependencies { implementation &#039;org.springframework.boot:spring-boot-starter-actuator:2.5.3&#039; implementation &#039;io.micrometer:micrometer-registry-prometheus:1.7.2&#039; }\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=3034\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-3034","post","type-post","status-publish","format-standard","hentry","category-spring-boot"],"_links":{"self":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/3034","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3034"}],"version-history":[{"count":12,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/3034\/revisions"}],"predecessor-version":[{"id":3053,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/3034\/revisions\/3053"}],"wp:attachment":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3034"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3034"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3034"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}