{"id":320197,"date":"2021-03-24T15:01:27","date_gmt":"2021-03-24T15:01:27","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=320197"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=320197","title":{"rendered":"\u0421\u0431\u043e\u0440 \u043c\u0435\u0442\u0440\u0438\u043a Spring Boot \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f c \u043f\u043e\u043c\u043e\u0449\u044c\u044e Prometheus \u0438 Grafana"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ab9\/f82\/e3a\/ab9f82e3aef9a88772cdb979902b66ed.png\" width=\"1792\" height=\"1021\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d \u043f\u043e\u043b\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u043c\u0438. \u0412 \u043d\u0430\u0447\u0430\u043b\u0435, \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u043c\u0435\u0442\u0440\u0438\u043a. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Prometheus \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u0430 \u0438 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u0440\u0438\u043a. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Grafana \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0442\u0440\u0438\u043a.<\/p>\n<h3>\u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f<\/h3>\n<p>1. <strong>Maven<\/strong>, \u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0438.<\/p>\n<p>2. <strong>Docker<\/strong> \u0438 <strong>docker-compose<\/strong> \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 Prometheus \u0438 Grafana.<\/p>\n<p>3. <strong>Spring boot 2<\/strong> \u0438 \u0432\u044b\u0448\u0435, <a href=\"https:\/\/spring.io\/blog\/2018\/03\/16\/micrometer-spring-boot-2-s-new-application-metrics-collector#what-is-it\" rel=\"noopener noreferrer nofollow\">\u043e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u0442\u044c \u0438 \u043f\u043e\u0440\u0442\u044b \u0434\u043b\u044f \u043f\u0440\u043e\u0448\u043b\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u0439<\/a>.<\/p>\n<h3>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p><a href=\"https:\/\/spring.io\/blog\/2018\/03\/16\/micrometer-spring-boot-2-s-new-application-metrics-collector\" rel=\"noopener noreferrer nofollow\">\u0421 \u0432\u044b\u0445\u043e\u0434\u0430 Spring boot 2 Micrometer \u0441\u0442\u0430\u043b \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u043c \u043c\u0435\u0442\u0440\u0438\u043a \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/a>. \u0421 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0430\u043b\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u043e\u0449\u0435 \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043a \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430\u043c. \u0412 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 <strong>Prometheus<\/strong> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0430 \u043c\u0435\u0442\u0440\u0438\u043a.<\/p>\n<p><a href=\"https:\/\/github.com\/Kirya522\/medium-posts\/tree\/main\/spring-metrics\" rel=\"noopener noreferrer nofollow\">\u0412\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430 \u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043d\u0430 github<\/a><\/p>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h3>\n<h4>[\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e spring initilizr] \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e<\/h4>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c spring boot \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<pre><code class=\"xml\">&lt;dependency&gt;     &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;     &lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt; &lt;\/dependency&gt;<\/code><\/pre>\n<h4>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 actuator<\/h4>\n<p>Spring boot \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c.<\/p>\n<pre><code class=\"xml\">&lt;dependency&gt;     &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;     &lt;artifactId&gt;spring-boot-starter-actuator&lt;\/artifactId&gt; &lt;\/dependency&gt;<\/code><\/pre>\n<p>\u041f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, actutor \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 <strong>8080<\/strong> \u0438 uri <strong>\/actuator<\/strong><\/p>\n<p><a href=\"https:\/\/github.com\/Kirya522\/medium-posts\/tree\/main\/spring-metrics\" rel=\"noopener noreferrer nofollow\">\u0412 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438-\u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0430 github<\/a> actuator \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443 <strong>localhost:8080\/actuator<\/strong><\/p>\n<p>\u0415\u0441\u043b\u0438 \u0437\u0430\u0439\u0442\u0438 \u043d\u0430 \u044d\u0442\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043e\u0442\u0432\u0435\u0442.<\/p>\n<pre><code class=\"json\">{    \"_links\":{       \"self\":{          \"href\":\"http:\/\/localhost:8080\/actuator\",          \"templated\":false       },       \"health-path\":{          \"href\":\"http:\/\/localhost:8080\/actuator\/health\/{*path}\",          \"templated\":true       },       \"health\":{          \"href\":\"http:\/\/localhost:8080\/actuator\/health\",          \"templated\":false       },       \"info\":{          \"href\":\"http:\/\/localhost:8080\/actuator\/info\",          \"templated\":false       }    } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c actuator \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d \u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0438.<\/p>\n<h4>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a<\/h4>\n<p><strong>Micrometer<\/strong> \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u043a\u043b\u044e\u0447\u0435\u043d \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 spring boot, \u043d\u0430\u043c \u043b\u0438\u0448\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043d\u0430\u043c \u0444\u043e\u0440\u043c\u0430\u0442, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d <strong>Prometheus <\/strong>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c.<\/p>\n<pre><code class=\"xml\">&lt;dependency&gt;     &lt;groupId&gt;io.micrometer&lt;\/groupId&gt;     &lt;artifactId&gt;micrometer-registry-prometheus&lt;\/artifactId&gt; &lt;\/dependency&gt;<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b <code>application.yml<\/code>\u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u0430 Prometheus \u0432 actuator.<\/p>\n<pre><code class=\"xml\">management:   endpoints:     web:       exposure:         include: health,prometheus   metrics:     export:       prometheus:         enabled: true     distribution:       percentiles-histogram:         \"[http.server.requests]\": true<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u044b <code>health,prometheus<\/code>\u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u044b \u0432 actuator. \u0412\u043a\u043b\u044e\u0447\u0435\u043d \u044d\u043a\u0441\u043f\u043e\u0440\u0442 \u043c\u0435\u0442\u0440\u0438\u043a \u0432 Prometheus, \u0430 \u0442\u0430\u043a\u0436\u0435 `percentiles-histogram`, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0435\u0440\u0445\u043d\u0435\u0443\u0440\u043e\u0432\u043d\u0435\u0433\u043e \u043e\u0446\u0435\u043d\u0438\u0442\u044c sla \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u043e\u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0437\u0430\u0439\u0442\u0438 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <code>http:\/\/localhost:8080\/actuator\/prometheus<\/code>\u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c\u0441\u044f \u0432\u044b\u0432\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f.<\/p>\n<pre><code># TYPE jvm_memory_committed_bytes gauge jvm_memory_committed_bytes{area=\"heap\",id=\"G1 Survivor Space\",} 9437184.0 jvm_memory_committed_bytes{area=\"heap\",id=\"G1 Old Gen\",} 9.961472E7 jvm_memory_committed_bytes{area=\"nonheap\",id=\"Metaspace\",} 4.2254336E7 jvm_memory_committed_bytes{area=\"nonheap\",id=\"CodeHeap 'non-nmethods'\",} 2555904.0 # TYPE jvm_gc_live_data_size_bytes gauge jvm_gc_live_data_size_bytes 0.0 # HELP tomcat_sessions_active_max_sessions   # TYPE tomcat_sessions_active_max_sessions gauge tomcat_sessions_active_max_sessions 0.0 # HELP jvm_threads_live_threads The current number of live threads including both daemon and non-daemon threads # TYPE jvm_threads_live_threads gauge jvm_threads_live_threads 27.0<\/code><\/pre>\n<p>\u0422\u0443\u0442 \u0432\u0438\u0434\u043d\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c, \u0447\u0442\u043e \u043c\u0435\u0442\u0440\u0438\u043a\u0438 jvm \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u0430 \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u0440\u0438\u043a<\/h3>\n<p>\u0424\u0430\u0439\u043b <code>docker-compose.yml<\/code>\u0434\u043b\u044f Prometheus \u0438 Grafana.<\/p>\n<pre><code class=\"go\">version: '3.7'  services:   grafana:     build: '.\/config\/grafana'     ports:       - 3000:3000     volumes:       - .\/grafana:\/var\/lib\/grafana     environment:       - GF_SECURITY_ADMIN_USER=admin       - GF_SECURITY_ADMIN_PASSWORD=admin     networks:       monitoring:         aliases:           - grafana   prometheus:     image: prom\/prometheus     ports:       - 9090:9090     volumes:       - .\/config\/prometheus.yml:\/etc\/prometheus\/prometheus.yml       - .\/prometheus:\/prometheus     networks:       monitoring:         aliases:           - prometheus networks:   monitoring:<\/code><\/pre>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u043e\u0431\u0440\u0430\u0437 Grafana \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f, \u044d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u043e\u0432 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 volume.<\/p>\n<p>\u042f \u0432\u043a\u043b\u044e\u0447\u0438\u043b \u0432 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442 \u0441 grafana \u0434\u0432\u0430 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u0430 \u0434\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430, \u0442.\u0435 <code>Dockerfile<\/code>\u0434\u043b\u044f Grafana \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<pre><code>FROM grafana\/grafana ADD .\/provisioning \/etc\/grafana\/provisioning<\/code><\/pre>\n<p><a href=\"https:\/\/github.com\/Kirya522\/medium-posts\/tree\/main\/spring-metrics\/src\/metricsdemo\/scripts\" rel=\"noopener noreferrer nofollow\">\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043f\u0440\u0435\u0434\u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u044b\u043c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435.<\/a><\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043d\u0435\u0441\u0442\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0444\u0430\u0439\u043b <code>prometheus.yml<\/code>\u0434\u043b\u044f \u0441\u0431\u043e\u0440\u0430 \u043c\u0435\u0442\u0440\u0438\u043a.<\/p>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0444\u0430\u0439\u043b \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<pre><code>scrape_configs:   - job_name: 'sample_monitoring'     scrape_interval: 5s     metrics_path: '\/actuator\/prometheus'     static_configs:       - targets: ['host.docker.internal:8080']<\/code><\/pre>\n<h3>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u043e\u0432<\/h3>\n<p>\u0412 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0432\u0430 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u0430.<\/p>\n<p>1. <a href=\"https:\/\/grafana.com\/grafana\/dashboards\/4701\" rel=\"noopener noreferrer nofollow\">JVM<\/a><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/49c\/2f8\/899\/49c2f889940fa2d9323647b38052ab58.png\" width=\"1792\" height=\"1021\"><figcaption><\/figcaption><\/figure>\n<p>2. <a href=\"https:\/\/grafana.com\/grafana\/dashboards\/5373\" rel=\"noopener noreferrer nofollow\">Response throughput<\/a><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7e1\/6a0\/3ce\/7e16a03ce33c22269476cfd4ff575f14.png\" width=\"1792\" height=\"1021\"><figcaption><\/figcaption><\/figure>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>1. \u041d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u0435\u0442\u0440\u0438\u043a\u0438.<\/p>\n<p>2. \u041d\u0430\u0441\u0442\u0440\u043e\u0435\u043d \u0441\u0431\u043e\u0440 \u043c\u0435\u0442\u0440\u0438\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Prometheus.<\/p>\n<p>3. \u041d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u044b \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432 Grafana.<\/p>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p><a href=\"https:\/\/github.com\/Kirya522\/medium-posts\/tree\/main\/spring-metrics\" rel=\"noopener noreferrer nofollow\">\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430 github<\/a><\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/548700\/\"> https:\/\/habr.com\/ru\/post\/548700\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d \u043f\u043e\u043b\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u043c\u0438. \u0412 \u043d\u0430\u0447\u0430\u043b\u0435, \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u043c\u0435\u0442\u0440\u0438\u043a. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Prometheus \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u0430 \u0438 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u0440\u0438\u043a. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Grafana \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0442\u0440\u0438\u043a.<\/p>\n<h3>\u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f<\/h3>\n<p>1. <strong>Maven<\/strong>, \u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0438.<\/p>\n<p>2. <strong>Docker<\/strong> \u0438 <strong>docker-compose<\/strong> \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 Prometheus \u0438 Grafana.<\/p>\n<p>3. <strong>Spring boot 2<\/strong> \u0438 \u0432\u044b\u0448\u0435, <a href=\"https:\/\/spring.io\/blog\/2018\/03\/16\/micrometer-spring-boot-2-s-new-application-metrics-collector#what-is-it\" rel=\"noopener noreferrer nofollow\">\u043e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u0442\u044c \u0438 \u043f\u043e\u0440\u0442\u044b \u0434\u043b\u044f \u043f\u0440\u043e\u0448\u043b\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u0439<\/a>.<\/p>\n<h3>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p><a href=\"https:\/\/spring.io\/blog\/2018\/03\/16\/micrometer-spring-boot-2-s-new-application-metrics-collector\" rel=\"noopener noreferrer nofollow\">\u0421 \u0432\u044b\u0445\u043e\u0434\u0430 Spring boot 2 Micrometer \u0441\u0442\u0430\u043b \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u043c \u043c\u0435\u0442\u0440\u0438\u043a \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/a>. \u0421 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0430\u043b\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u043e\u0449\u0435 \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043a \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430\u043c. \u0412 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 <strong>Prometheus<\/strong> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0430 \u043c\u0435\u0442\u0440\u0438\u043a.<\/p>\n<p><a href=\"https:\/\/github.com\/Kirya522\/medium-posts\/tree\/main\/spring-metrics\" rel=\"noopener noreferrer nofollow\">\u0412\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430 \u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043d\u0430 github<\/a><\/p>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h3>\n<h4>[\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e spring initilizr] \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e<\/h4>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c spring boot \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<pre><code class=\"xml\">&lt;dependency&gt;     &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;     &lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt; &lt;\/dependency&gt;<\/code><\/pre>\n<h4>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 actuator<\/h4>\n<p>Spring boot \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c.<\/p>\n<pre><code class=\"xml\">&lt;dependency&gt;     &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;     &lt;artifactId&gt;spring-boot-starter-actuator&lt;\/artifactId&gt; &lt;\/dependency&gt;<\/code><\/pre>\n<p>\u041f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, actutor \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 <strong>8080<\/strong> \u0438 uri <strong>\/actuator<\/strong><\/p>\n<p><a href=\"https:\/\/github.com\/Kirya522\/medium-posts\/tree\/main\/spring-metrics\" rel=\"noopener noreferrer nofollow\">\u0412 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438-\u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0430 github<\/a> actuator \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443 <strong>localhost:8080\/actuator<\/strong><\/p>\n<p>\u0415\u0441\u043b\u0438 \u0437\u0430\u0439\u0442\u0438 \u043d\u0430 \u044d\u0442\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043e\u0442\u0432\u0435\u0442.<\/p>\n<pre><code class=\"json\">{    \"_links\":{       \"self\":{          \"href\":\"http:\/\/localhost:8080\/actuator\",          \"templated\":false       },       \"health-path\":{          \"href\":\"http:\/\/localhost:8080\/actuator\/health\/{*path}\",          \"templated\":true       },       \"health\":{          \"href\":\"http:\/\/localhost:8080\/actuator\/health\",          \"templated\":false       },       \"info\":{          \"href\":\"http:\/\/localhost:8080\/actuator\/info\",          \"templated\":false       }    } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c actuator \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d \u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0438.<\/p>\n<h4>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a<\/h4>\n<p><strong>Micrometer<\/strong> \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u043a\u043b\u044e\u0447\u0435\u043d \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 spring boot, \u043d\u0430\u043c \u043b\u0438\u0448\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043d\u0430\u043c \u0444\u043e\u0440\u043c\u0430\u0442, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d <strong>Prometheus <\/strong>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c.<\/p>\n<pre><code class=\"xml\">&lt;dependency&gt;     &lt;groupId&gt;io.micrometer&lt;\/groupId&gt;     &lt;artifactId&gt;micrometer-registry-prometheus&lt;\/artifactId&gt; &lt;\/dependency&gt;<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b <code>application.yml<\/code>\u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u0430 Prometheus \u0432 actuator.<\/p>\n<pre><code class=\"xml\">management:   endpoints:     web:       exposure:         include: health,prometheus   metrics:     export:       prometheus:         enabled: true     distribution:       percentiles-histogram:         \"[http.server.requests]\": true<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u044b <code>health,prometheus<\/code>\u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u044b \u0432 actuator. \u0412\u043a\u043b\u044e\u0447\u0435\u043d \u044d\u043a\u0441\u043f\u043e\u0440\u0442 \u043c\u0435\u0442\u0440\u0438\u043a \u0432 Prometheus, \u0430 \u0442\u0430\u043a\u0436\u0435 `percentiles-histogram`, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0435\u0440\u0445\u043d\u0435\u0443\u0440\u043e\u0432\u043d\u0435\u0433\u043e \u043e\u0446\u0435\u043d\u0438\u0442\u044c sla \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u043e\u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0437\u0430\u0439\u0442\u0438 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <code>http:\/\/localhost:8080\/actuator\/prometheus<\/code>\u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c\u0441\u044f \u0432\u044b\u0432\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f.<\/p>\n<pre><code># TYPE jvm_memory_committed_bytes gauge jvm_memory_committed_bytes{area=\"heap\",id=\"G1 Survivor Space\",} 9437184.0 jvm_memory_committed_bytes{area=\"heap\",id=\"G1 Old Gen\",} 9.961472E7 jvm_memory_committed_bytes{area=\"nonheap\",id=\"Metaspace\",} 4.2254336E7 jvm_memory_committed_bytes{area=\"nonheap\",id=\"CodeHeap 'non-nmethods'\",} 2555904.0 # TYPE jvm_gc_live_data_size_bytes gauge jvm_gc_live_data_size_bytes 0.0 # HELP tomcat_sessions_active_max_sessions   # TYPE tomcat_sessions_active_max_sessions gauge tomcat_sessions_active_max_sessions 0.0 # HELP jvm_threads_live_threads The current number of live threads including both daemon and non-daemon threads # TYPE jvm_threads_live_threads gauge jvm_threads_live_threads 27.0<\/code><\/pre>\n<p>\u0422\u0443\u0442 \u0432\u0438\u0434\u043d\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c, \u0447\u0442\u043e \u043c\u0435\u0442\u0440\u0438\u043a\u0438 jvm \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u0430 \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u0440\u0438\u043a<\/h3>\n<p>\u0424\u0430\u0439\u043b <code>docker-compose.yml<\/code>\u0434\u043b\u044f Prometheus \u0438 Grafana.<\/p>\n<pre><code class=\"go\">version: '3.7'  services:   grafana:     build: '.\/config\/grafana'     ports:       - 3000:3000     volumes:       - .\/grafana:\/var\/lib\/grafana     environment:       - GF_SECURITY_ADMIN_USER=admin       - GF_SECURITY_ADMIN_PASSWORD=admin     networks:       monitoring:         aliases:           - grafana   prometheus:     image: prom\/prometheus     ports:       - 9090:9090     volumes:       - .\/config\/prometheus.yml:\/etc\/prometheus\/prometheus.yml       - .\/prometheus:\/prometheus     networks:       monitoring:         aliases:           - prometheus networks:   monitoring:<\/code><\/pre>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u043e\u0431\u0440\u0430\u0437 Grafana \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f, \u044d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u043e\u0432 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 volume.<\/p>\n<p>\u042f \u0432\u043a\u043b\u044e\u0447\u0438\u043b \u0432 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442 \u0441 grafana \u0434\u0432\u0430 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u0430 \u0434\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430, \u0442.\u0435 <code>Dockerfile<\/code>\u0434\u043b\u044f Grafana \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<pre><code>FROM grafana\/grafana ADD .\/provisioning \/etc\/grafana\/provisioning<\/code><\/pre>\n<p><a href=\"https:\/\/github.com\/Kirya522\/medium-posts\/tree\/main\/spring-metrics\/src\/metricsdemo\/scripts\" rel=\"noopener noreferrer nofollow\">\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043f\u0440\u0435\u0434\u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u044b\u043c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435.<\/a><\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043d\u0435\u0441\u0442\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0444\u0430\u0439\u043b <code>prometheus.yml<\/code>\u0434\u043b\u044f \u0441\u0431\u043e\u0440\u0430 \u043c\u0435\u0442\u0440\u0438\u043a.<\/p>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0444\u0430\u0439\u043b \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<pre><code>scrape_configs:   - job_name: 'sample_monitoring'     scrape_interval: 5s     metrics_path: '\/actuator\/prometheus'     static_configs:       - targets: ['host.docker.internal:8080']<\/code><\/pre>\n<h3>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u043e\u0432<\/h3>\n<p>\u0412 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0432\u0430 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u0430.<\/p>\n<p>1. <a href=\"https:\/\/grafana.com\/grafana\/dashboards\/4701\" rel=\"noopener noreferrer nofollow\">JVM<\/a><\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>2. <a href=\"https:\/\/grafana.com\/grafana\/dashboards\/5373\" rel=\"noopener noreferrer nofollow\">Response throughput<\/a><\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>1. \u041d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u0435\u0442\u0440\u0438\u043a\u0438.<\/p>\n<p>2. \u041d\u0430\u0441\u0442\u0440\u043e\u0435\u043d \u0441\u0431\u043e\u0440 \u043c\u0435\u0442\u0440\u0438\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Prometheus.<\/p>\n<p>3. \u041d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u044b \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432 Grafana.<\/p>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p><a href=\"https:\/\/github.com\/Kirya522\/medium-posts\/tree\/main\/spring-metrics\" rel=\"noopener noreferrer nofollow\">\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430 github<\/a><\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/548700\/\"> https:\/\/habr.com\/ru\/post\/548700\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-320197","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/320197","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=320197"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/320197\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=320197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=320197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=320197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}