前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Etcd 监控

Etcd 监控

作者头像
用户5760343
发布2019-10-29 14:48:58
6010
发布2019-10-29 14:48:58
举报
文章被收录于专栏:sktjsktj

curl -L http://localhost:2379/metrics

获取状态

etcdctl endpoint health --

prometheus

Prometheus

Running a Prometheus monitoring service is the easiest way to ingest and record etcd’s metrics.

First, install Prometheus:

<pre class="prettyprint linenums prettyprinted" style="box-sizing: border-box; overflow: auto; font: 400 13.566px/1.6 "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; display: block; padding: 10px; margin: 0px 0px 16px; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background: rgb(246, 246, 246); border: 1px solid transparent; border-radius: 3px; -webkit-tap-highlight-color: transparent; position: relative; white-space: pre-wrap; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">

  1. PROMETHEUS_VERSION="1.3.1"
  2. wget https://github.com/prometheus/prometheus/releases/download/v$PROMETHEUS_VERSION/prometheus-$PROMETHEUS_VERSION.linux-amd64.tar.gz -O /tmp/prometheus-$PROMETHEUS_VERSION.linux-amd64.tar.gz
  3. tar -xvzf /tmp/prometheus-$PROMETHEUS_VERSION.linux-amd64.tar.gz --directory /tmp/ --strip-components=1
  4. /tmp/prometheus -version

</pre>

Set Prometheus’s scraper to target the etcd cluster endpoints:

<pre class="prettyprint linenums prettyprinted" style="box-sizing: border-box; overflow: auto; font: 400 13.566px/1.6 "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; display: block; padding: 10px; margin: 0px 0px 16px; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background: rgb(246, 246, 246); border: 1px solid transparent; border-radius: 3px; -webkit-tap-highlight-color: transparent; position: relative; white-space: pre-wrap; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">

  1. cat > /tmp/test-etcd.yaml <<EOF
  2. global:
  3. scrape_interval: 10s
  4. scrape_configs:
  5. - job_name: test-etcd
  6. static_configs:
  7. - targets: ['10.240.0.32:2379','10.240.0.33:2379','10.240.0.34:2379']
  8. EOF
  9. cat /tmp/test-etcd.yaml

</pre>

Set up the Prometheus handler:

<pre class="prettyprint linenums prettyprinted" style="box-sizing: border-box; overflow: auto; font: 400 13.566px/1.6 "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; display: block; padding: 10px; margin: 0px 0px 16px; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background: rgb(246, 246, 246); border: 1px solid transparent; border-radius: 3px; -webkit-tap-highlight-color: transparent; position: relative; white-space: pre-wrap; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">

  1. nohup /tmp/prometheus \
  2. -config.file /tmp/test-etcd.yaml \
  3. -web.listen-address ":9090" \
  4. -storage.local.path "test-etcd.data" >> /tmp/test-etcd.log 2>&1 &

</pre>

Now Prometheus will scrape etcd metrics every 10 seconds.

Grafana

Grafana has built-in Prometheus support; just add a Prometheus data source:

<pre class="prettyprint linenums prettyprinted" style="box-sizing: border-box; overflow: auto; font: 400 13.566px/1.6 "YaHei Consolas Hybrid", Consolas, "Meiryo UI", "Malgun Gothic", "Segoe UI", "Trebuchet MS", Helvetica, monospace, monospace; display: block; padding: 10px; margin: 0px 0px 16px; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background: rgb(246, 246, 246); border: 1px solid transparent; border-radius: 3px; -webkit-tap-highlight-color: transparent; position: relative; white-space: pre-wrap; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">

  1. Name: test-etcd
  2. Type: Prometheus
  3. Url: http://localhost:9090
  4. Access: proxy

</pre>

Then import the default etcd dashboard template and customize. For instance, if Prometheus data source name is my-etcd, the datasource field values in JSON also need to be my-etcd.

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019.10.25 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 获取状态
  • prometheus
    • Prometheus
      • Grafana
      相关产品与服务
      Prometheus 监控服务
      Prometheus 监控服务(TencentCloud Managed Service for Prometheus,TMP)是基于开源 Prometheus 构建的高可用、全托管的服务,与腾讯云容器服务(TKE)高度集成,兼容开源生态丰富多样的应用组件,结合腾讯云可观测平台-告警管理和 Prometheus Alertmanager 能力,为您提供免搭建的高效运维能力,减少开发及运维成本。
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档