- Fleet 和 Elastic Agent 指南其他版本
- Fleet 和 Elastic Agent 概述
- Beats 和 Elastic Agent 功能
- 快速入门
- 从 Beats 迁移到 Elastic Agent
- 部署模型
- 安装 Elastic Agent
- 安装 Fleet 管理的 Elastic Agent
- 安装独立的 Elastic Agent
- 在容器化环境中安装 Elastic Agent
- 在容器中运行 Elastic Agent
- 在 Fleet 管理的 Kubernetes 上运行 Elastic Agent
- 使用 Helm 在 Kubernetes 上安装 Elastic Agent
- 示例:使用 Helm 在 Kubernetes 上安装独立的 Elastic Agent
- 示例:使用 Helm 在 Kubernetes 上安装 Fleet 管理的 Elastic Agent
- Fleet 管理的高级 Elastic Agent 配置
- 在 Elastic Agent 上配置 Kubernetes 元数据增强
- 在 Fleet 管理的 GKE 上运行 Elastic Agent
- 在 Fleet 管理的 Amazon EKS 上运行 Elastic Agent
- 在 Fleet 管理的 Azure AKS 上运行 Elastic Agent
- 在 Kubernetes 上运行独立的 Elastic Agent
- 在 Kubernetes 上扩展 Elastic Agent
- 在 Kubernetes 集成中使用自定义摄取管道
- 环境变量
- 将 Elastic Agent 作为 OTel 收集器运行
- 在没有管理权限的情况下运行 Elastic Agent
- 从 MSI 包安装 Elastic Agent
- 安装布局
- 气隙环境
- 将代理服务器与 Elastic Agent 和 Fleet 一起使用
- 从边缘主机卸载 Elastic Agent
- 在边缘主机上启动和停止 Elastic Agent
- Elastic Agent 配置加密
- 安全连接
- 在 Fleet 中管理 Elastic Agent
- 配置独立的 Elastic Agent
- 创建独立的 Elastic Agent 策略
- 配置文件结构
- 输入
- 提供程序
- 输出
- SSL/TLS
- 日志记录
- 功能标志
- Agent 下载
- 配置文件示例
- 授予独立的 Elastic Agent 对 Elasticsearch 的访问权限
- 示例:将独立的 Elastic Agent 与 Elastic Cloud Serverless 一起使用来监控 nginx
- 示例:将独立的 Elastic Agent 与 Elasticsearch Service 一起使用来监控 nginx
- 调试独立的 Elastic Agent
- 使用 Elastic Agent 进行 Kubernetes 自动发现
- 监控
- 参考 YAML
- 管理集成
- 定义处理器
- 处理器语法
- add_cloud_metadata
- add_cloudfoundry_metadata
- add_docker_metadata
- add_fields
- add_host_metadata
- add_id
- add_kubernetes_metadata
- add_labels
- add_locale
- add_network_direction
- add_nomad_metadata
- add_observer_metadata
- add_process_metadata
- add_tags
- community_id
- convert
- copy_fields
- decode_base64_field
- decode_cef
- decode_csv_fields
- decode_duration
- decode_json_fields
- decode_xml
- decode_xml_wineventlog
- decompress_gzip_field
- detect_mime_type
- dissect
- dns
- drop_event
- drop_fields
- extract_array
- fingerprint
- include_fields
- move_fields
- parse_aws_vpc_flow_log
- rate_limit
- registered_domain
- rename
- replace
- script
- syslog
- timestamp
- translate_sid
- truncate_fields
- urldecode
- 命令参考
- 故障排除
- 发行说明
Kubernetes LeaderElection 提供程序
编辑Kubernetes LeaderElection 提供程序
编辑提供在 Kubernetes 上运行的一组 Elastic Agent 之间启用领导者选举的选项。一次只有一个 Elastic Agent 将持有领导者锁,并且基于此,可以在 Elastic Agent 持有领导权的情况下启用配置。这在以下情况下很有用:一组 Elastic Agent 中的 Elastic Agent 收集 Kubernetes 集群的集群范围指标,例如 kube-state-metrics
端点。
提供程序需要一个 kubeconfig
文件来建立与 Kubernetes API 的连接。如果它在 InCluster 环境中运行(Elastic Agent 作为 Pod 运行),则它可以自动访问 API。
providers.kubernetes_leaderelection: #enabled: true #kube_config: /Users/elastic-agent/.kube/config #kube_client_options: # qps: 5 # burst: 10 #leader_lease: agent-k8s-leader-lock #leader_retryperiod: 2 #leader_leaseduration: 15 #leader_renewdeadline: 10
-
已启用
- (可选)默认为 true。要显式禁用 LeaderElection 提供程序,请设置
enabled: false
。 -
kube_config
- (可选)使用给定的配置文件作为 Kubernetes 客户端的配置。如果未设置
kube_config
,将检查KUBECONFIG
环境变量,如果不存在,则回退到 InCluster。 -
kube_client_options
- (可选)为 Kubernetes 客户端配置其他选项。支持的选项为
qps
和burst
。如果未设置,则使用 Kubernetes 客户端的默认 QPS 和 burst 设置。 -
leader_lease
- (可选)指定领导者租约的名称。默认设置为
elastic-agent-cluster-leader
。 -
leader_retryperiod
- (可选)默认值为 2(秒)。Elastic Agent 尝试获取
leader
角色的时长。 -
leader_leaseduration
- (可选)默认值为 15(秒)。领导者 Elastic Agent 持有
leader
状态的时长。 -
leader_renewdeadline
- (可选)默认值为 10(秒)。领导者重试获取
leader
角色的时长。
可用的键是
键 | 类型 | 描述 |
---|---|---|
|
|
领导标志的值。当 Elastic Agent 是当前领导者时,此值设置为 |
了解领导者计时
编辑如上所述,LeaderElection 配置提供以下参数:租约持续时间(leader_leaseduration
)、续订截止时间(leader_renewdeadline
)和重试周期(leader_retryperiod
)。根据提供的配置,每个代理将触发 Kubernetes API 请求,并尝试检查租约的状态。
对 K8s 控制 API 的领导者调用次数与安装的 Elastic Agent 数量成正比。这意味着请求将来自每个 leader_retryperiod
的所有 Elastic Agent。将 leader_retryperiod
设置为大于默认值 (2 秒) 的值,意味着将向 Kubernetes 控制 API 发出更少的请求,但也会增加可能丢失来自领导者 Elastic Agent 的指标收集的时间。
该库对时间参数应用 特定检查,如果未验证这些参数,Elastic Agent 将退出并出现 panic
错误。
一般来说:- 租约持续时间必须大于续订截止时间 - 续订截止时间必须大于重试周期*抖动因子。
常量抖动因子=1.2 在 leaderelection lib 中定义。
仅在处于领导地位时启用配置
编辑使用基于 kubernetes_leaderelection.leader
键的条件来利用 leaderelection 提供程序,并且仅当 Elastic Agent 持有领导锁时才启用特定输入。以下示例仅在获得领导锁时启用 state_container
指标集
- data_stream: dataset: kubernetes.state_container type: metrics metricsets: - state_container add_metadata: true hosts: - 'kube-state-metrics:8080' period: 10s condition: ${kubernetes_leaderelection.leader} == true
On this page