{"id":163,"date":"2022-12-07T17:56:33","date_gmt":"2022-12-07T09:56:33","guid":{"rendered":"https:\/\/namo.one\/?p=163"},"modified":"2022-12-07T17:56:33","modified_gmt":"2022-12-07T09:56:33","slug":"docker-%e5%ae%89%e8%a3%85netdata%ef%bc%8c-prometheus%e4%bb%a5%e5%8f%8agrafana%e5%ae%8c%e6%88%90%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%9b%91%e6%8e%a7","status":"publish","type":"post","link":"https:\/\/byso.top\/?p=163","title":{"rendered":"Docker \u5b89\u88c5Netdata\uff0c Prometheus\u4ee5\u53caGrafana\u5b8c\u6210\u670d\u52a1\u5668\u76d1\u63a7"},"content":{"rendered":"\n<p>\u9996\u5148\u5728\u76d1\u63a7\u76ee\u6807\u9e21\u4e0a\u5b89\u88c5Netdata\uff0c\u901a\u8fc7portainer\u65b0\u5efastack\u5e76\u8d34\u5165\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>version: '3'\nservices:\n  netdata:\n    image: netdata\/netdata\n    container_name: netdata\n    hostname: example.com # set to fqdn of host\n    ports:\n      - 19999:19999\n    restart: unless-stopped\n    cap_add:\n      - SYS_PTRACE\n    security_opt:\n      - apparmor:unconfined\n    volumes:\n      - netdataconfig:\/etc\/netdata\n      - netdatalib:\/var\/lib\/netdata\n      - netdatacache:\/var\/cache\/netdata\n      - \/etc\/passwd:\/host\/etc\/passwd:ro\n      - \/etc\/group:\/host\/etc\/group:ro\n      - \/proc:\/host\/proc:ro\n      - \/sys:\/host\/sys:ro\n      - \/etc\/os-release:\/host\/etc\/os-release:ro\n\nvolumes:\n  netdataconfig:\n  netdatalib:\n  netdatacache:<\/code><\/pre>\n\n\n\n<p>\u51c6\u5907\u5728\u76d1\u6d4b\u9e21\u4e0a\u7684docker\u5b89\u88c5prometheus\uff0c\u5148\u5efa\u7acb\u5bf9\u5e94\u6587\u4ef6\u5939\/root\/data\/docker_data\/prometheus\uff0c\u5e76\u5728\u6587\u4ef6\u5939\u4e2d\u751f\u6210\u914d\u7f6e\u6587\u4ef6prometheus.yml<\/p>\n\n\n\n<p>mkdir -p \/root\/data\/docker_data\/prometheus<\/p>\n\n\n\n<p>cd \/root\/data\/docker_data\/prometheus<\/p>\n\n\n\n<p>touch prometheus.yml<\/p>\n\n\n\n<p>\u4f7f\u7528\u4ee5\u4e0b\u5185\u5bb9\u5efa\u7acbportainer stack\uff0c\u6216\u76f4\u63a5\u751f\u6210docker-compose\u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>version: '3.3'\r\nservices:\r\n    prometheus:\r\n        ports:\r\n            - '9090:9090'\r\n        volumes:\r\n            - '\/root\/data\/docker_data\/prometheus:\/etc\/prometheus'\r\n        image: prom\/prometheus<\/code><\/pre>\n\n\n\n<p>\u5c06\u4ee5\u4e0b\u5185\u5bb9\u8d34\u5165prometheus.yml\uff0c\u6bcf\u589e\u52a0\u4e00\u4e2anetdata\u6570\u636e\u6e90\uff0c\u53ea\u9700\u589e\u52a0\u4e00\u6bb5##\u53f7\u95f4\u7684\u5185\u5bb9\uff0c\u5e76\u4fee\u6539\u5bf9\u5e94\u7684job_name\u4ee5\u53catargets\u7684ip\u5730\u5740\u548c\u7aef\u53e3\u53f7<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># my global config\nglobal:\n  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.\n  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.\n  # scrape_timeout is set to the global default (10s).\n\n# Alertmanager configuration\nalerting:\n  alertmanagers:\n  - static_configs:\n    - targets:\n      # - alertmanager:9093\n\n# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.\nrule_files:\n  # - \"first_rules.yml\"\n  # - \"second_rules.yml\"\n\n# A scrape configuration containing exactly one endpoint to scrape:\n# Here it's Prometheus itself.\nscrape_configs:\n  # The job name is added as a label `job=&lt;job_name>` to any timeseries scraped from this config.\n  - job_name: 'prometheus'\n\n    # metrics_path defaults to '\/metrics'\n    # scheme defaults to 'http'.\n\n    static_configs:\n    - targets: &#91;'localhost:9090']\n    \n#############################################################################################\n\n  - job_name: 'netdata-scrape'\n\n    metrics_path: '\/api\/v1\/allmetrics'\n    params:\n      # format: prometheus | prometheus_all_hosts\n      # You can use `prometheus_all_hosts` if you want Prometheus to set the `instance` to your hostname instead of IP \n      format: &#91;prometheus]\n      #\n      # source: as-collected | raw | average | sum | volume\n      # default is: average\n      #source: &#91;as-collected]\n      #\n      # server name for this prometheus - the default is the client IP\n      # for Netdata to uniquely identify it\n      #server: &#91;'prometheus1']\n    honor_labels: true\n    static_configs:\n      - targets: &#91;'192.168.1.13:19999']\n      \n#############################################################################################\n#############################################################################################\n\n  - job_name: 'netdata-scrape'\n\n    metrics_path: '\/api\/v1\/allmetrics'\n    params:\n      # format: prometheus | prometheus_all_hosts\n      # You can use `prometheus_all_hosts` if you want Prometheus to set the `instance` to your hostname instead of IP \n      format: &#91;prometheus]\n      #\n      # source: as-collected | raw | average | sum | volume\n      # default is: average\n      #source: &#91;as-collected]\n      #\n      # server name for this prometheus - the default is the client IP\n      # for Netdata to uniquely identify it\n      #server: &#91;'prometheus1']\n    honor_labels: true\n    static_configs:\n      - targets: &#91;'192.168.1.13:19999']\n      \n#############################################################################################<\/code><\/pre>\n\n\n\n<p>\u6700\u540e\u5b89\u88c5grafana\uff0c\u4f7f\u7528\u4ee5\u4e0b\u5185\u5bb9\u521b\u5efadocker stack<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>version: '3.3'\r\nservices:\r\n    grafana:\r\n        ports:\r\n            - '3000:3000'\r\n        container_name: grafana\r\n        image: grafana\/grafana<\/code><\/pre>\n\n\n\n<p>\u5269\u4e0b\u6765\u7684\u5c31\u662f\u914d\u7f6egrafana\u7684target\uff0c\u521b\u5efapanel\uff0c\u7f16\u8f91\u6bcf\u4e00\u4e2a\u76d1\u89c6unit\u4e86<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9996\u5148\u5728\u76d1\u63a7\u76ee\u6807\u9e21\u4e0a\u5b89\u88c5Netdata\uff0c\u901a\u8fc7portainer\u65b0\u5efastack\u5e76\u8d34\u5165\u4ee5\u4e0b\u5185\u5bb9\uff1a \u51c6\u5907\u5728\u76d1\u6d4b\u9e21\u4e0a\u7684d [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,2],"tags":[],"class_list":["post-163","post","type-post","status-publish","format-standard","hentry","category-docker","category-linux-applications"],"_links":{"self":[{"href":"https:\/\/byso.top\/index.php?rest_route=\/wp\/v2\/posts\/163","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/byso.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/byso.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/byso.top\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/byso.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=163"}],"version-history":[{"count":4,"href":"https:\/\/byso.top\/index.php?rest_route=\/wp\/v2\/posts\/163\/revisions"}],"predecessor-version":[{"id":167,"href":"https:\/\/byso.top\/index.php?rest_route=\/wp\/v2\/posts\/163\/revisions\/167"}],"wp:attachment":[{"href":"https:\/\/byso.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/byso.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=163"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/byso.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}