您好,登錄后才能下訂單哦!
????????Prometheus是一個開源系統監控和警報工具包。可以將Docker配置為Prometheus目標。目前,您只能監控Docker本身。您目前無法使用Docker目標監控應用程序。
監控docker的操作步驟:
1.使用docker的metrics-address向Prometheus暴露監控端口:
修改docker的daemon.json文件
{ ??????"metrics-addr":?"192.168.191.18:9323",??#docker官網上的配置是127.0.0.1:9323在Prometheus無法連接該ip,手動執行curl?-L?127.0.0.1:9323時可以顯示docker的監控指標的,可能由于容器之間的隔離原因無法連接吧。 ?????“experimental":?true }
之后容器docker服務:systemctl restart docker
2.編輯Prometheus.yml
#?my?global?config global: ??scrape_interval:?????15s?#?Set?the?scrape?interval?to?every?15?seconds.?Default?is?every?1?minute. ??evaluation_interval:?15s?#?Evaluate?rules?every?15?seconds.?The?default?is?every?1?minute. ??#?scrape_timeout?is?set?to?the?global?default?(10s). ??#?Attach?these?labels?to?any?time?series?or?alerts?when?communicating?with ??#?external?systems?(federation,?remote?storage,?Alertmanager). ??external_labels: ??????monitor:?'codelab-monitor' #?Load?rules?once?and?periodically?evaluate?them?according?to?the?global?'evaluation_interval'. rule_files: ??#?-?"first.rules" ??#?-?"second.rules" #?A?scrape?configuration?containing?exactly?one?endpoint?to?scrape: #?Here?it's?Prometheus?itself. scrape_configs: ??#?The?job?name?is?added?as?a?label?`job=<job_name>`?to?any?timeseries?scraped?from?this?config. ??-?job_name:?'prometheus' ????#?metrics_path?defaults?to?'/metrics' ????#?scheme?defaults?to?'http'. ????static_configs: ??????-?targets:?['localhost:9090'] ??-?job_name:?'docker' ?????????#?metrics_path?defaults?to?'/metrics' ?????????#?scheme?defaults?to?'http'. ????static_configs: ??????-?targets:?['192.168.191.18:9323']
3.啟動一個Prometheus的容器
????docker環境使用的時swarm集群方式創建服務的命令方式不一樣。swarm集群部署可自行操作
[root@docker?~]#?docker?service?create?--replicas?1?--name?my-prometheus??--mount?type=bind,source=/root/prometheus.yml,destination=/etc/prometheus/prometheus.yml? --publish?published=9090,target=9090,protocol=tcp?????prom/prometheus rgkmwhwqepl1qivlpq8r3nt2n overall?progress:?1?out?of?1?tasks? 1/1:?running???[==================================================>]? verify:?Service?converged
查看創建的服務信息
[root@docker?~]#?docker?service??ls? ID??????????????????NAME????????????????MODE????????????????REPLICAS????????????IMAGE????????????????????PORTS rgkmwhwqepl1????????my-prometheus???????replicated??????????1/1?????????????????prom/prometheus:latest???*:9090->9090/tcp
查看服務的具體信息
[root@docker?~]#?docker?service?ps??my-prometheus ID??????????????????NAME????????????????IMAGE????????????????????NODE????????????????DESIRED?STATE???????CURRENT?STATE????????????ERROR???????????????PORTS y8akc5dmwjrn????????my-prometheus.1?????prom/prometheus:latest???docker??????????????Running?????????????Running?16?minutes?ago
? ? ? ? ? ? ? ? ? ?
4.訪問Prometheus的頁面查看監控值
監控項的查看
prometheus監控docker的基本內容已經部署及驗證完成,docke官網有關Prometheus·監控docker的配置實驗在查看Prometheus的監控target時報錯:dial tcp xxxx: connect: connection refused。
docker官網https://docs.docker.com/config/thirdparty/prometheus/
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。