{"id":1559,"date":"2023-03-25T15:51:06","date_gmt":"2023-03-25T07:51:06","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1559"},"modified":"2023-04-27T21:36:49","modified_gmt":"2023-04-27T13:36:49","slug":"prometheus-grafana-monitoring-spring-cloud-application","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/25\/prometheus-grafana-monitoring-spring-cloud-application\/","title":{"rendered":"Prometheus + Grafana \u76d1\u63a7 Spring Cloud \u5e94\u7528"},"content":{"rendered":"<h2>\u5e94\u7528\u4f9d\u8d56<\/h2>\n<pre><code class=\"language-xml\">&lt;dependency&gt;\n    &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n    &lt;artifactId&gt;spring-boot-starter-actuator&lt;\/artifactId&gt;\n&lt;\/dependency&gt;\n&lt;!-- Micrometer Prometheus registry --&gt;\n&lt;dependency&gt;\n    &lt;groupId&gt;io.micrometer&lt;\/groupId&gt;\n    &lt;artifactId&gt;micrometer-registry-prometheus&lt;\/artifactId&gt;\n&lt;\/dependency&gt;<\/code><\/pre>\n<p><!-- more --><\/p>\n<h2>\u5e94\u7528\u914d\u7f6e<\/h2>\n<pre><code class=\"language-yml\">#metrics\nmanagement:\n  metrics:\n    export:\n      prometheus:\n        enabled: true\n  endpoints:\n    web:\n      exposure:\n        include: health, info, httptrace, metrics, threaddump, mappings, prometheus\n  endpoint:\n    health:\n      show-details: always<\/code><\/pre>\n<h2>Prometheus\u914d\u7f6e<\/h2>\n<pre><code class=\"language-yml\">- job_name: &#039;spring_cloud_application&#039;\n  metrics_path: &#039;\/actuator\/prometheus&#039;\n  static_configs:\n    - targets: [&#039;192.168.16.8:8801&#039;]\n      labels:\n        application: appblog\n        instance: service-a\n        group: inner\n    - targets: [&#039;192.168.16.8:8802&#039;]\n      labels:\n        application: appblog\n        instance: service-b\n        group: inner\n    - targets: [&#039;192.168.16.8:8803&#039;]\n      labels:\n        application: appblog\n        instance: service-c\n        group: inner\n    - targets: [&#039;192.168.16.10:8804&#039;]\n      labels:\n        application: appblog\n        instance: service-d\n        group: inner\n    - targets: [&#039;192.168.16.10:8805&#039;]\n      labels:\n        application: appblog\n        instance: service-e\n        group: inner<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5e94\u7528\u4f9d\u8d56 &lt;dependency&gt; &lt;groupId&gt;org.springframew [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[386],"tags":[385,387],"class_list":["post-1559","post","type-post","status-publish","format-standard","hentry","category-monitor","tag-grafana","tag-prometheus"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1559","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1559"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1559\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1559"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1559"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1559"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}