有几个网站能在百度做推广,网站快速建设视频,网站开发 架构设计,模板建站价格简介
Etcd 是一个高可用的分布式键值存储系统#xff0c;它提供了一个可靠的、强一致性的存储服务#xff0c;用于配置管理和服务发现。它最初由 CoreOS 开发#xff0c;现在由 Cloud Native Computing Foundation (CNCF) 维护。Etcd 使用 Raft 算法来实现数据的一致性它提供了一个可靠的、强一致性的存储服务用于配置管理和服务发现。它最初由 CoreOS 开发现在由 Cloud Native Computing Foundation (CNCF) 维护。Etcd 使用 Raft 算法来实现数据的一致性能保证数据在所有节点间保持同步。
Etcd 作为一个关键的分布式键值存储系统广泛应用于 Docker、Kubernetes等分布式系统中用于存储配置信息、服务发现、领导者选举等它保证了集群数据的强一致性和高可用性。因此对 Etcd 可观测是非常重要的尤其是在生产环境中观测 Etcd 的运行指标可以帮助及时发现和解决潜在的问题确保集群的稳定性和可靠性。
Etcd 自带 metrics 接口可以通过 curl 命令访问默认的 “/metrics” 端点来查看可用的指标。如果 Etcd 集群配置了 TLS还需要指定客户端证书和密钥等信息 。
curl http://etcd-node-ip:2379/metrics观测云是一款统一的可观测平台可实现对多云、云原生、中间件、应用等进行实时可观测。观测云数据的采集是通过 DataKit 来实现的DataKit 自带的有 Etcd 采集器不依赖 Prometheus只需要安装 DataKit开通 Etcd 采集器配置 metrics url 、证书、密钥等信息即可采集到 Etcd 指标到观测云。下面是在 Kubernetes 集群部署 DataKit 并开通 Etcd 采集器的示例。
操作步骤
部署 DataKit
登录观测云控制台点击「集成」 -「DataKit」 - 「Kubernetes」下载 datakit.yaml拷贝第 3 步中的 token。 编辑 datakit.yaml 把 token 粘贴到 ENV_DATAWAY 环境变量值中“token”后面设置环境变量 ENV_CLUSTER_NAME_K8S 的值并增加环境变量 ENV_NAMESPACE这两个环境变量的值一般和集群名称对应一个工作空间集群名称要唯一。 - name: ENV_NAMESPACEvalue: xxxx把 datakit.yaml 上传到可以连接到 Kubernetes 集群的主机上执行如下命令。
kubectl apply -f datakit.yaml
kubectl get pod -n datakit开通 Etcd 采集
KubernetesPrometheus 是 DataKit 的一个采集器它根据自定义配置实现自动发现 Prometheus 服务并进行采集极大简化了采集 Kubernetes 集群中 Etcd 指标的复杂度。
apiVersion: v1
kind: ConfigMap
metadata:name: datakit-confnamespace: datakit
data:etcd.conf: |- [inputs.kubernetesprometheus] [[inputs.kubernetesprometheus.instances]]role podnamespaces [kube-system]selector componentetcd,tiercontrol-plane scrape truescheme httpsport 2379path /metricsinterval 60s[inputs.kubernetesprometheus.instances.custom]measurement etcdjob_as_measurement false[inputs.kubernetesprometheus.instances.custom.tags]node_name __kubernetes_node_namecluster_name_k8s k8s-dev[inputs.kubernetesprometheus.instances.auth]bearer_token_file /var/run/secrets/kubernetes.io/serviceaccount/token[inputs.kubernetesprometheus.instances.auth.tls_config]insecure_skip_verify falseca_certs [/rootfs/etc/kubernetes/pki/etcd/ca.crt]cert /rootfs/etc/kubernetes/pki/etcd/peer.crtcert_key /rootfs/etc/kubernetes/pki/etcd/peer.key
再把 etcd.conf 挂载到 DataKit 的 /usr/local/datakit/conf.d/kubernetesprometheus/etcd.conf 下面最后重新部署 DataKit。- mountPath: /usr/local/datakit/conf.d/kubernetesprometheus/etcd.confname: datakit-confsubPath: etcd.conf指标
登录观测云控制台点击「指标」 -「指标管理」输入“etcd”就能查询采集到的指标。 Etcd 采集器默认会把所有指标都采集到观测云为了减少时间线需要使用 pipelinedrop 未被使用的指标。登录观测云控制台点击「管理」 -「新建Pipeline」选择“指标”、“etcd”drop_key(grpc_server_started_total) 即是不采集 grpc_server_started_total 指标。 完整解析规则如下
drop_key(grpc_server_started_total)
drop_key(etcd_cluster_version)
drop_key(etcd_debugging_auth_revision)
drop_key(etcd_debugging_disk_backend_commit_rebalance_duration_seconds_bucket)
drop_key(etcd_debugging_disk_backend_commit_rebalance_duration_seconds_count)
drop_key(etcd_debugging_disk_backend_commit_rebalance_duration_seconds_sum)
drop_key(etcd_debugging_disk_backend_commit_spill_duration_seconds_bucket)
drop_key(etcd_debugging_disk_backend_commit_spill_duration_seconds_count)
drop_key(etcd_debugging_disk_backend_commit_spill_duration_seconds_sum)
drop_key(etcd_debugging_disk_backend_commit_write_duration_seconds_bucket)
drop_key(etcd_debugging_disk_backend_commit_write_duration_seconds_count)
drop_key(etcd_debugging_disk_backend_commit_write_duration_seconds_sum)
drop_key(etcd_debugging_lease_granted_total)
drop_key(etcd_debugging_lease_renewed_total)
drop_key(etcd_debugging_lease_revoked_total)
drop_key(etcd_debugging_lease_ttl_total_bucket)
drop_key(etcd_debugging_lease_ttl_total_count)
drop_key(etcd_debugging_lease_ttl_total_sum)
drop_key(etcd_debugging_mvcc_compact_revision)
drop_key(etcd_debugging_mvcc_current_revision)
drop_key(etcd_debugging_mvcc_db_compaction_keys_total)
drop_key(etcd_debugging_mvcc_db_compaction_last)
drop_key(etcd_debugging_mvcc_db_compaction_pause_duration_milliseconds_bucket)
drop_key(etcd_debugging_mvcc_db_compaction_pause_duration_milliseconds_count)
drop_key(etcd_debugging_mvcc_db_compaction_pause_duration_milliseconds_sum)
drop_key(etcd_debugging_mvcc_db_compaction_total_duration_milliseconds_bucket)
drop_key(etcd_debugging_mvcc_db_compaction_total_duration_milliseconds_count)
drop_key(etcd_debugging_mvcc_db_compaction_total_duration_milliseconds_sum)
drop_key(etcd_debugging_mvcc_events_total)
drop_key(etcd_debugging_mvcc_index_compaction_pause_duration_milliseconds_bucket)
drop_key(etcd_debugging_mvcc_index_compaction_pause_duration_milliseconds_count)
drop_key(etcd_debugging_mvcc_index_compaction_pause_duration_milliseconds_sum)
drop_key(etcd_debugging_mvcc_pending_events_total)
drop_key(etcd_debugging_mvcc_range_total)
drop_key(etcd_debugging_mvcc_slow_watcher_total)
drop_key(etcd_debugging_mvcc_total_put_size_in_bytes)
drop_key(etcd_debugging_mvcc_watch_stream_total)
drop_key(etcd_debugging_mvcc_watcher_total)
drop_key(etcd_debugging_server_lease_expired_total)
drop_key(etcd_debugging_snap_save_marshalling_duration_seconds_bucket)
drop_key(etcd_debugging_snap_save_marshalling_duration_seconds_count)
drop_key(etcd_debugging_snap_save_marshalling_duration_seconds_sum)
drop_key(etcd_debugging_snap_save_total_duration_seconds_bucket)
drop_key(etcd_debugging_snap_save_total_duration_seconds_count)
drop_key(etcd_debugging_snap_save_total_duration_seconds_sum)
drop_key(etcd_debugging_store_expires_total)
drop_key(etcd_debugging_store_reads_total)
drop_key(etcd_debugging_store_watch_requests_total)
drop_key(etcd_debugging_store_watchers)
drop_key(etcd_debugging_store_writes_total)
drop_key(etcd_disk_backend_defrag_duration_seconds_bucket)
drop_key(etcd_disk_backend_defrag_duration_seconds_count)
drop_key(etcd_disk_backend_defrag_duration_seconds_sum)
drop_key(etcd_disk_backend_snapshot_duration_seconds_bucket)
drop_key(etcd_grpc_proxy_cache_hits_total)
drop_key(etcd_grpc_proxy_cache_keys_total)
drop_key(etcd_grpc_proxy_cache_misses_total)
drop_key(etcd_grpc_proxy_events_coalescing_total)
drop_key(etcd_grpc_proxy_watchers_coalescing_total)
drop_key(etcd_mvcc_db_open_read_transactions)
drop_key(etcd_mvcc_delete_total)
drop_key(etcd_mvcc_hash_duration_seconds_bucket)
drop_key(etcd_mvcc_hash_duration_seconds_count)
drop_key(etcd_mvcc_hash_duration_seconds_sum)
drop_key(etcd_mvcc_hash_rev_duration_seconds_bucket)
drop_key(etcd_mvcc_hash_rev_duration_seconds_count)
drop_key(etcd_mvcc_hash_rev_duration_seconds_sum)
drop_key(etcd_mvcc_put_total)
drop_key(etcd_mvcc_range_total)
drop_key(etcd_mvcc_txn_total)
drop_key(etcd_server_apply_duration_seconds_bucket)
drop_key(etcd_server_apply_duration_seconds_count)
drop_key(etcd_server_apply_duration_seconds_sum)
drop_key(etcd_server_client_requests_total)
drop_key(etcd_server_go_version)drop_key(etcd_server_id)
drop_key(etcd_server_is_leader)
drop_key(etcd_server_is_learner)
drop_key(etcd_server_learner_promote_successes)
drop_key(etcd_server_quota_backend_bytes)
drop_key(etcd_server_slow_apply_total)
drop_key(etcd_server_slow_read_indexes_total)
drop_key(etcd_server_version)
drop_key(etcd_snap_db_fsync_duration_seconds_bucket)
drop_key(etcd_snap_db_fsync_duration_seconds_count)
drop_key(etcd_snap_db_fsync_duration_seconds_sum)
drop_key(etcd_snap_db_save_total_duration_seconds_bucket)
drop_key(etcd_snap_db_save_total_duration_seconds_count)
drop_key(etcd_snap_db_save_total_duration_seconds_sum)
drop_key(etcd_snap_fsync_duration_seconds_bucket)
drop_key(etcd_snap_fsync_duration_seconds_count)
drop_key(etcd_snap_fsync_duration_seconds_sum)
drop_key(go_gc_duration_seconds)
drop_key(go_gc_duration_seconds_count)
drop_key(go_gc_duration_seconds_sum)
drop_key(go_goroutines)
drop_key(go_info)
drop_key(go_memstats_frees_total)
drop_key(go_memstats_gc_cpu_fraction)
drop_key(go_memstats_gc_sys_bytes)
drop_key(go_memstats_heap_idle_bytes)
drop_key(go_memstats_heap_inuse_bytes)
drop_key(go_memstats_heap_objects)
drop_key(go_memstats_heap_released_bytes)
drop_key(go_memstats_heap_sys_bytes)
drop_key(go_memstats_last_gc_time_seconds)
drop_key(go_memstats_lookups_total)
drop_key(go_memstats_mallocs_total)
drop_key(go_memstats_mcache_inuse_bytes)
drop_key(go_memstats_mcache_sys_bytes)
drop_key(go_memstats_mspan_sys_bytes)
drop_key(go_memstats_next_gc_bytes)
drop_key(go_memstats_other_sys_bytes)
drop_key(go_memstats_stack_inuse_bytes)
drop_key(go_memstats_stack_sys_bytes)
drop_key(go_memstats_sys_bytes)
drop_key(go_threads)
drop_key(grpc_server_msg_received_total)
drop_key(grpc_server_msg_sent_total)
drop_key(process_resident_memory_bytes)
drop_key(process_start_time_seconds)
drop_key(process_virtual_memory_bytes)
drop_key(process_virtual_memory_max_bytes)
drop_key(promhttp_metric_handler_requests_in_flight)
drop_key(promhttp_metric_handler_requests_total)监控视图
登录观测云控制台点击「场景」 -「新建仪表板」输入 “etcd” 选择“Etcd 监控视图”点击“确定”。 关键指标
Etcd 的监控指标主要包括 Server、Disk 和 Network 三大类。
Server 指标描述了 Etcd 服务器的状态包括是否有 leader、leader 切换次数、已提交和已应用的提案总数、等待提交的提案数以及失败的提案数等。Disk 指标描述了磁盘操作的状态例如 WAL fsync 调用的延迟和后端提交操作的延迟。Network 指标描述了网络状态包括发送和接收的字节数、发送和接收失败数以及节点间的 RTT 时间等。
指标描述单位etcd_server_has_leader这个指标表示 Etcd 集群中是否存在 Leader。countetcd_server_health_successetcd 服务器健康检查成功的次数countetcd_server_health_failuresetcd 服务器健康检查失败的次数countprocess_resident_memory_bytes用于表示 etcd 进程当前占用的常驻内存resident memory大小Bytesetcd_server_proposals_committed_total成功提交到 Raft 日志中的提案proposals总数countetcd_server_proposals_applied_total成功应用或执行Apply的提案proposals总数countetcd_server_proposals_pending当前等待处理的提案数量countetcd_server_proposals_failed_total失败的提案总数countetcd_mvcc_db_total_size_in_bytes数据库的总大小Bytesetcd_disk_wal_fsync_duration_seconds_sum当前日志执行 fsync 操作的总耗时Secondsetcd_disk_backend_commit_duration_seconds_sum后台数据库提交操作的总耗时Secondsetcd_network_client_grpc_received_bytes_totaletcd 服务器从客户端通过 gRPC 协议接收到的总字节数Bytesetcd_network_client_grpc_sent_bytes_totaletcd 服务器通过 gRPC 协议发送给客户端的总字节数Bytesetcd_server_leader_changes_seen_totalleader 的切换次数countprocess_open_fds操作系统进程当前打开的文件描述符数量countprocess_max_fds操作系统允许一个进程打开的最大文件描述符数量count
提案Proposal
Etcd 基于 Raft 实现一致性算法。在 Raft 中任何试图更改系统状态的动作都以提案Proposal的形式被提出。
etcd_server_proposals_pending 表示正在等待处理的 Proposal 数量。
etcd_server_proposals_committed_total 和 etcd_server_proposals_applied_total 这两个指标分别表示成功提交到 Raft 日志中的提案数量和成功应用或执行Apply的提案数量。它们可以帮助监控集群处理请求的能力。如果提交和应用的提案数之间存在较大差异可能表明集群正在处理大量请求或者存在性能瓶颈。
etcd_server_proposals_failed_total 这个指标记录了处理失败的提案数量。提案失败可能由于多种原因包括网络问题、集群不稳定或资源限制。监控这个指标有助于及时发现和解决影响 Etcd 集群稳定性的问题。
同步时间
etcd_disk_wal_fsync_duration_seconds_bucket 和 etcd_disk_backend_commit_duration_seconds_bucket 这两个指标反映了 Etcd 存储数据的效率高延迟可能表明磁盘性能问题或集群过载。
WAL 日志同步时间 etcd_disk_wal_fsync_duration_seconds_bucket 表示 WAL 日志同步到磁盘时WAL 调用 fsync 的延迟正常应该低于10ms当 99 百分位的 fsync 延迟超过某个阈值比如 100 毫秒时触发告警。
库同步时间 etcd_disk_backend_commit_duration_seconds_bucket 当 etcd 将其最新的增量快照提交到磁盘时会调用 backend_commit 正常应该低于120ms。
Leader 是否存在
etcd_server_has_leader 这个指标表示 Etcd 集群中是否存在 Leader。Leader 对于 Etcd 集群至关重要因为它负责处理所有的写请求。0 表示不是1表示是如果这个值为 0意味着集群中没有 Leader这将导致写操作无法进行整个集群不可用。因此监控这个指标可以帮助及时发现集群是否处于正常工作状态。
Leader 切换频次
etcd_server_leader_changes_seen_total 指标记录了 leader 的切换次数。当 Etcd 通过 Raft 协议选举出 leader 后leader 应该是固定不变的。频繁的 Leader 切换可能是由于网络问题或集群不稳定造成的这会影响集群的性能和稳定性。监控这个指标有助于发现潜在的网络问题或集群健康问题。生产环境如果在一个小时内发生超过三次的 leader 切换需要触发告警。
监控器告警
通过合理配置监控器可以及时处理 etcd 故障观测云也提供了相应的模板供客户参考使用。
Leader 监控器 值为 0 触发紧急告警。 Leader 频繁切换监控 如需更多监控器可以按照实际生产需求进行配置。
总结
总之对 Etcd 进行可观测是确保分布式系统稳定运行的关键步骤观测云是一款实用的可观测产品建议把生产环境中 Etcd 接入观测云使用观测云的监控器对重要指标进行监控告警。