{"id":162,"date":"2024-10-30T18:23:27","date_gmt":"2024-10-30T10:23:27","guid":{"rendered":"https:\/\/zhoujibin.com\/?p=162"},"modified":"2024-10-30T18:23:28","modified_gmt":"2024-10-30T10:23:28","slug":"prometheus%e3%80%81grafana%e5%ae%89%e8%a3%85","status":"publish","type":"post","link":"https:\/\/zhoujibin.com\/?p=162","title":{"rendered":"Prometheus\u3001Grafana\u5b89\u88c5"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u4e0a\u4f20\u6587\u4ef6\u81f3\u6307\u5b9a\u76ee\u5f55<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code># \u4e0a\u4f20\u6587\u4ef6\u81f3\/home\/zhoujibin\/package\n# \u4e3b\u7a0b\u5e8f\n\/home\/zhoujibin\/package\/prometheus-2.45.0.linux-amd64.tar.gz\n# node\u8282\u70b9\u7a0b\u5e8f\n\/home\/zhoujibin\/package\/node_exporter-1.6.1.linux-amd64.tar.gz\n# \u53ef\u89c6\u5316\u8f6f\u4ef6\n\/home\/zhoujibin\/package\/grafana-10.1.1.linux-amd64.tar.gz<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b89\u88c5\u8f6f\u4ef6<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u5b89\u88c5prometheus<\/h3>\n\n\n\n<p>\u53c2\u8003\uff1ahttps:\/\/blog.csdn.net\/qq_31725371\/article\/details\/114697770<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u89e3\u538b\u5b89\u88c5\u5305<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>tar -xvf \/home\/zhoujibin\/package\/prometheus-2.45.0.linux-amd64.tar.gz -C \/home\/zhoujibin<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u7f16\u5199\u81ea\u542f\u670d\u52a1<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>vim \/usr\/lib\/systemd\/system\/prometheus.service\n# begin\n&#91;Unit]\nDescription=https:\/\/prometheus.io\n&#91;Service]\n Restart=on-failure\n ExecStart=\/home\/zhoujibin\/prometheus-2.45.0.linux-amd64\/prometheus --config.file=\/home\/zhoujibin\/prometheus-2.45.0.linux-amd64\/prometheus.yml --web.listen-address=:19090 --storage.tsdb.retention.time=12h --web.enable-lifecycle\n&#91;Install]\n  WantedBy=multi-user.target\n# end\n:wq\nsystemctl daemon-reload\n# \u8bbe\u7f6e\u5f00\u673a\u81ea\u542f\nsystemctl enable prometheus.service<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u542f\u52a8\u670d\u52a1<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>service prometheus start\n# \u67e5\u770b\u542f\u52a8\u72b6\u6001\nservice prometheus status<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u5b89\u88c5node_export<\/h3>\n\n\n\n<p>\u9700\u8981\u76d1\u63a7\u7684\u7684\u8282\u70b9\u90fd\u9700\u8981\u5b89\u88c5<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u89e3\u538b\u5b89\u88c5\u5305<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>tar -xvf \/home\/zhoujibin\/package\/node_exporter-1.6.1.linux-amd64.tar.gz -C \/home\/zhoujibin\/<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u7f16\u5199\u81ea\u542f\u670d\u52a1<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>vim \/usr\/lib\/systemd\/system\/node_exporter.service\n# begin\n&#91;Unit]\nDescription=node_exporter\nAfter=network.target \n\n&#91;Service]\nExecStart=\/home\/zhoujibin\/node_exporter-1.6.1.linux-amd64\/node_exporter\nRestart=on-failure\n\n&#91;Install]\nWantedBy=multi-user.target\n# end\n:wq\nsystemctl daemon-reload\n# \u8bbe\u7f6e\u5f00\u673a\u81ea\u542f\nsystemctl enable node_exporter.service<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u542f\u52a8\u670d\u52a1<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>service node_exporter start\n# \u67e5\u770b\u542f\u52a8\u72b6\u6001\nservice node_exporter status<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u5b89\u88c5nginx-exporter<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u89e3\u538b\u5b89\u88c5\u5305<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir \/home\/zhoujibin\/nginx-prometheus-exporter_0.11.0_linux_amd64;\ntar -xvf \/home\/zhoujibin\/package\/nginx-prometheus-exporter_0.11.0_linux_amd64.tar.gz -C \/home\/zhoujibin\/nginx-prometheus-exporter_0.11.0_linux_amd64<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u7f16\u5199\u81ea\u542f\u670d\u52a1<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>vim \/usr\/lib\/systemd\/system\/nginx_exporter.service\n# begin\n&#91;Unit]\nDescription=nginx_exporter\nAfter=network.target \n\n&#91;Service]\nExecStart=\/home\/zhoujibin\/nginx-prometheus-exporter_0.11.0_linux_amd64\/nginx-prometheus-exporter -nginx.scrape-uri=http:\/\/192.168.0.12:28888\/nginx_status\nRestart=on-failure\n\n&#91;Install]\nWantedBy=multi-user.target\n# end\n:wq\nsystemctl daemon-reload\n# \u8bbe\u7f6e\u5f00\u673a\u81ea\u542f\nsystemctl enable nginx_exporter.service<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u542f\u52a8\u670d\u52a1<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>service nginx_exporter start\n# \u67e5\u770b\u542f\u52a8\u72b6\u6001\nservice nginx_exporter status<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u914d\u7f6e\u76d1\u63a7\u8282\u70b9\u4fe1\u606f<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u4fee\u6539\u914d\u7f6e<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># \u914d\u7f6e\u8282\u70b9\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u8c03\u6574\u5373\u53ef\uff0c\u6b64\u6b21\u76d1\u63a7nginx\u548cappn01\nvim \/home\/zhoujibin\/prometheus-2.45.0.linux-amd64\/prometheus.yml\n# \u6ce8\u610f\uff0c\u82e5web.listen-address\u4e2d\u7684\u7aef\u53e3\u505a\u4e86\u4fee\u6539\uff0c- targets: &#91;\"localhost:19090\"] \u4e2d\u7684\u7aef\u53e3\u4e5f\u9700\u8981\u505a\u5bf9\u5e94\u7684\u6539\u52a8\n  - job_name: 'nginx'\n    static_configs:\n    - targets: &#91;\"nginx:9100\"]\n  - job_name: 'appn01'\n    static_configs:\n    - targets: &#91;\"appn01:9100\"]<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u91cd\u542f\u670d\u52a1<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>service prometheus restart<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b89\u88c5grafana<\/h2>\n\n\n\n<h4 class=\"wp-block-heading\">\u89e3\u538b\u5b89\u88c5\u5305<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>tar -xvf \/home\/zhoujibin\/package\/grafana-10.1.1.linux-amd64.tar.gz -C \/home\/zhoujibin\/<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u7f16\u5199\u81ea\u542f\u670d\u52a1<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>vim \/usr\/lib\/systemd\/system\/grafana-server.service\n# begin\n&#91;Unit]\nDescription=grafana\nAfter=network.target \n\n&#91;Service]\nExecStart=\/home\/zhoujibin\/grafana-10.1.1\/bin\/grafana-server -homepath \/home\/zhoujibin\/grafana-10.1.1\nRestart=on-failure\n\n&#91;Install]\nWantedBy=multi-user.target\n\n# end\n:wq\nsystemctl daemon-reload\n# \u8bbe\u7f6e\u5f00\u673a\u81ea\u542f\nsystemctl enable grafana-server.service<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u542f\u52a8\u670d\u52a1<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>service grafana-server start\n# \u67e5\u770b\u542f\u52a8\u72b6\u6001\nservice grafana-server status<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0a\u4f20\u6587\u4ef6\u81f3\u6307\u5b9a\u76ee\u5f55 \u5b89\u88c5\u8f6f\u4ef6 \u5b89\u88c5prometheus \u53c2\u8003\uff1ahttps:\/\/blog.csdn.net\/qq [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[30,45],"class_list":["post-162","post","type-post","status-publish","format-standard","hentry","category-linux","tag-linux","tag-45"],"_links":{"self":[{"href":"https:\/\/zhoujibin.com\/index.php?rest_route=\/wp\/v2\/posts\/162"}],"collection":[{"href":"https:\/\/zhoujibin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhoujibin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhoujibin.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhoujibin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=162"}],"version-history":[{"count":1,"href":"https:\/\/zhoujibin.com\/index.php?rest_route=\/wp\/v2\/posts\/162\/revisions"}],"predecessor-version":[{"id":163,"href":"https:\/\/zhoujibin.com\/index.php?rest_route=\/wp\/v2\/posts\/162\/revisions\/163"}],"wp:attachment":[{"href":"https:\/\/zhoujibin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhoujibin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhoujibin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}