如何监控容器或K8s中的OpenSearch

news2025/9/19 5:38:09

概述

当前 OpenSearch 使用的越来越多, 但是 OpenSearch 生态还不尽完善.

针对如下情况:

  • 监控容器化或运行在 K8s 中的 OpenSearch

我查了下, 官方还没有提供完备的方案.

这里如何监控 K8s 中的 OpenSearch, 包括安装 exporter 插件、采集、展示全环节。

OpenSearch 简介

  • OpenSearch 是一款开源的分布式搜索引擎(从 ElasticSearch 特定版本分叉而来),可以执行快速、可扩展的全文搜索、应用程序和基础设施监控、安全和事件信息管理、运营健康跟踪等用例。
  • OpenSearch 具有多种功能和插件,可以帮助索引、保护、监控和分析数据。
  • OpenSearch 包含一个演示配置,以便您可以快速启动和运行,但在生产环境中使用 OpenSearch 之前,您必须使用自己的证书、身份验证方法、用户和密码手动配置安全插件。
  • OpenSearch 由 AWS 支持,所有组件均可在 GitHub 上获得 Apache 许可证版本 2.0。

Prometheus Exporter Plugin for OpenSearch 简介

  • Prometheus Exporter 插件用于将 OpenSearch 指标暴露为 Prometheus 格式。
  • 插件版本必须与 OpenSearch 版本完全匹配,因此需要保持 prometheus-exporter-plugin-for-opensearch 版本与 OpenSearch 版本同步。
  • 可以通过在每个要由 Prometheus 抓取的 OpenSearch 节点上安装插件来安装插件。
  • 可以通过在 config/opensearch.yml 中配置静态设置和动态设置来配置插件。
  • 指标可以直接在 http(s)://<opensearch-host>:9200/_prometheus/metrics 获得。

📚️相关参考资料

本文会使用到 2 个资源:

  • OpenSearch
  • Prometheus Exporter Plugin for OpenSearch

具体实现

两种方案:

  1. 自己制作包含 prometheus-exporter 插件的镜像
  2. 通过 OpenSearch Helm Chart 安装prometheus-exporter 插件

(方案一)制作包含 prometheus-exporter 插件的镜像并使用

📝Notes:

这里以 opensearch:2.12 版本为例

Dockerfile 内容如下:

FROM opensearchproject/opensearch:2.12.0
LABEL maintainer="cuikaidong@foxmail.com"
ARG EXPORTER_PLUGIN_URL="https://github.com/Aiven-Open/prometheus-exporter-plugin-for-opensearch/releases/download/2.12.0.0/prometheus-exporter-2.12.0.0.zip"
RUN opensearch-plugin install -b ${EXPORTER_PLUGIN_URL}

📝Notes

如果 docker build 过程下载超时, 可以将对应EXPORTER_PLUGIN_URL行替换为相关代理的 URL(这里不详述). 或者, 下载后, 通过 COPY 复制进去后再执行: opensearch-plugin install -b file:///path/to/prometheus-exporter-2.12.0.0.zip

构建并推送镜像:

docker build -t xxxxx/opensearch:2.12.0-prometheus-exporter -f ./Dockerfile
docker push xxxx/opensearch:2.12.0-prometheus-exporter

📝Notes

您可以通过 CICD Pipeline, 随着 OpenSearch 和 prometheus-exporter-plugin-for-opensearch 的更新, 自动构建新的镜像. 我相信, 随着 OpenSearch 生态的完善, 应该会有已经包含 exporter 的 OpenSearch 镜像.

对于容器化或 K8s 运行的 OpenSearch, 只需要将镜像改为构建后的, 带 prometheus-exporter 的镜像即可.

如:

原来是:

image: opensearchproject/opensearch:2.12.0

修改为:

image: xxxx/opensearch:2.12.0-prometheus-exporter

(方案二)使用 OpenSearch Helm Chart

如果你是在 K8s 中运行 OpenSearch, 也可以考虑使用 OpenSearch 的 Helm Chart, 它包含了安装第三方插件的功能, 具体 values.yaml 如下:

## Enable to add 3rd Party / Custom plugins not offered in the default OpenSearch image.
plugins:
  enabled: true
  installList:
    - https://github.com/Aiven-Open/prometheus-exporter-plugin-for-opensearch/releases/download/2.12.0.0/prometheus-exporter-2.12.0.0.zip

📚️参考文档:

OpenSearch Helm Chart

修改 pometheus-exporter 的配置

另外, 可以按需修改prometheus-exporter 的配置, 详细配置说明见:

  • prometheus-exporter-plugin-for-opensearch config

示例配置如下:

config/opensearch.yml, 追加如下内容:

plugins.security.disabled: true
prometheus.indices_filter.selected_indices: "log-*,*log,*log*,log*-test"
prometheus.indices_filter.selected_option: "STRICT_EXPAND_OPEN_FORBID_CLOSED"

📝声明

plugins.security.disabled: true 可选项, 允许通过 http 协议访问插件 url. 生产不建议使用. 建议只在快速验证时采用

prometheus.indices_filter.selected_indices 仅供参考. 请按需调整.

prometheus.indices_filter.selected_option 使用默认配置. 请阅读细节后按需调整.

修改完配置后, 重启容器正常生效.

验证插件已启用

指标可直接在以下位置获取:

http(s)://opensearch-host:9200/_prometheus/metrics

作为示例结果,你将得到如下内容:

# HELP opensearch_process_mem_total_virtual_bytes Memory used by ES process
# TYPE opensearch_process_mem_total_virtual_bytes gauge
opensearch_process_mem_total_virtual_bytes{cluster="develop",node="develop01",} 3.626733568E9
# HELP opensearch_indices_indexing_is_throttled_bool Is indexing throttling ?
# TYPE opensearch_indices_indexing_is_throttled_bool gauge
opensearch_indices_indexing_is_throttled_bool{cluster="develop",node="develop01",} 0.0
# HELP opensearch_jvm_gc_collection_time_seconds Time spent for GC collections
# TYPE opensearch_jvm_gc_collection_time_seconds counter
opensearch_jvm_gc_collection_time_seconds{cluster="develop",node="develop01",gc="old",} 0.0
opensearch_jvm_gc_collection_time_seconds{cluster="develop",node="develop01",gc="young",} 0.0
# HELP opensearch_indices_requestcache_memory_size_bytes Memory used for request cache
# TYPE opensearch_indices_requestcache_memory_size_bytes gauge
opensearch_indices_requestcache_memory_size_bytes{cluster="develop",node="develop01",} 0.0
# HELP opensearch_indices_search_open_contexts_number Number of search open contexts
# TYPE opensearch_indices_search_open_contexts_number gauge
opensearch_indices_search_open_contexts_number{cluster="develop",node="develop01",} 0.0
# HELP opensearch_jvm_mem_nonheap_used_bytes Memory used apart from heap
# TYPE opensearch_jvm_mem_nonheap_used_bytes gauge
opensearch_jvm_mem_nonheap_used_bytes{cluster="develop",node="develop01",} 5.5302736E7
...

使用 Prometheus 采集指标

(仅作为参考示例, 请按需调整), 在 Prometheus 的 scrape 下面, 追加如下内容:

    - job_name: opensearch
      metrics_path: /_prometheus/metrics
      relabel_configs:
        - replacement: '<your-instance-name>'
          target_label: node
      static_configs:
        - targets: ['<your-host-name>:9200']
配置 Prometheus Rules 和 Alerts

这里随便举一个简单例子, 现在使用 OpenSearch 的, 之前应该有完备的 ES 相关的 rules 和 alerts. 略作修改即可.

alert: OpenSearchYellowCluster
for: 5m
annotations:
  summary: At least one of the clusters is reporting a yellow status.
  description: '{{$labels.cluster}} health status is yellow over the last 5 minutes'
  runbook_url: ''
labels:
  severity: warning
  '': ''
expr: |
  opensearch_cluster_status == 1

使用 Grafana 查看

可以使用如下 Grafana Dashboard 进行查看:

  • https://grafana.com/grafana/dashboards/20827-opensearch/

效果如下:

OpenSearch Dashboard

更多 OpenSearch Dashboard 可以在 https://grafana.com/grafana/dashboards/ 中搜索关键词 "OpenSearch".

总结

如何监控容器或 K8s 中的 OpenSearch?

  1. 先安装 OpenSearch Prometheus Exporter 插件, 有 2 种办法:
    1. 自己制作包含 OpenSearch Prometheus Exporter 插件的镜像
    2. 使用 OpenSearch Helm Chart 安装
  2. 配置 Prometheus scrape config
  3. 配置 Prometheus Rules 和 Alerts
  4. 使用 Grafana 查看

以上.

三人行, 必有我师; 知识共享, 天下为公. 本文由东风微鸣技术博客 EWhisper.cn 编写.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1585983.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

数据库数据恢复—Sql Server数据库文件丢失如何恢复数据?

服务器数据恢复环境&#xff1a; 一台安装windows server操作系统的服务器。一组由8块硬盘组建的RAID5&#xff0c;划分LUN供这台服务器使用。 在windows服务器内装有SqlServer数据库。存储空间LUN划分了两个逻辑分区。 服务器故障&初检&#xff1a; 由于未知原因&#xf…

git 删除本地分支 删除远程仓库分支

语法&#xff1a; 删除本地分支 git branch -D <分支名>删除远程分支 git push <remote名称> <分支名> --delete 示例&#xff1a; 删除本地分支 git branch -D feature/test_listview删除远程分支 git push origin feature/test_listview --delete 两个…

润色问题解惑

上博士为了毕业写学术论文头都大了&#xff0c;但更难受的是英语不咋地&#xff0c;投稿后经常会因为语言问题而惨遭拒稿&#xff0c;每每想起就令人心情郁郁&#xff0c;天台可期。有些审稿人也会直接告知需要专业的修改&#xff0c;那咋整呢&#xff0c;让润色呗&#xff0c;…

腾讯社交广告推广如何开户和费用攻略

腾讯社交广告平台&#xff0c;依托腾讯系庞大的用户基数与丰富的应用场景&#xff0c;为广告主提供了极具潜力的营销渠道。从微信朋友圈、QQ空间到腾讯新闻、腾讯视频等多款热门应用&#xff0c;腾讯社交广告覆盖了亿万级用户群体&#xff0c;是企业提升品牌知名度、推动产品销…

如何做好谷歌广告投放?谷歌广告投放要点解析

市场是在不断变化的&#xff0c;搜索引擎上的网站排名也随着市场的变化而变化。如果你的广告战术一成不变&#xff0c;很容易花冤枉钱。从本质上来讲&#xff0c;谷歌广告的优化工作就是让商家在搜索引擎上保持长久的市场竞争力。 如果商家不经常优化Google广告&#xff0c;可能…

谈谈系列之OA又见OA

确实没想到&#xff0c;绕了一圈&#xff0c;居然又回到了OA&#xff0c;当年从HW从来&#xff0c;就是不想仅仅只做给内部人用的产品&#xff0c;没想到兜兜转转&#xff0c;又回到了给“内部人做产品”的“老路”。 当然&#xff0c;就像先哲赫拉克利特说的——人不能两次走进…

【随笔】Git 高级篇 -- 提交的技巧(下) cherry-pick commit --amend(十九)

&#x1f48c; 所属专栏&#xff1a;【Git】 &#x1f600; 作  者&#xff1a;我是夜阑的狗&#x1f436; &#x1f680; 个人简介&#xff1a;一个正在努力学技术的CV工程师&#xff0c;专注基础和实战分享 &#xff0c;欢迎咨询&#xff01; &#x1f496; 欢迎大…

【CSS】CSS三大特性、盒子模型

目录 CSS三大特性 1、层叠性 2、继承性 3、优先级 盒子模型 1、网页布局的本质 2、盒子模型&#xff08;Box Model&#xff09;组成 3、边框&#xff08;border&#xff09; 3.1、边框的使用 3.2、表格的细线边框 3.3、边框会影响盒子实际大小 4、内边距&#xff0…

【AUTOSAR网络管理测试】PowerOn→BSM

&#x1f64b;‍♂️【AUTOSAR网络管理测试】系列&#x1f481;‍♂️点击跳转 文章目录 1.状态机分析2.环境搭建3.测试步骤4.结果分析 1.状态机分析 PowerOn→BSM&#xff1a;上电初始化的&#xff0c;会默认进入BSM状态 测试点&#xff1a;确认上电后&#xff0c;任何唤醒源…

C语言进阶课程学习记录-第29课 - 指针和数组分析(下)

C语言进阶课程学习记录-第29课 - 指针和数组分析&#xff08;下&#xff09; 数组名与指针实验-数组形式转换实验-数组名与指针的差异实验-转化后数组名加一的比较实验-数组名作为函数形参小结 本文学习自狄泰软件学院 唐佐林老师的 C语言进阶课程&#xff0c;图片全部来源于课…

Docker 安装MySql并操作日志

一、在Linux系统里新建这几个文件夹 1.1 在conf.d文件夹下新建一个my.cnf文件 1.2 用vscode 打开&#xff08;防止乱码&#xff09;&#xff0c;复制以下内容 [mysqld] log_timestampsSYSTEM default-time-zone8:00server-id1log-binmysql-binbinlog-do-db mall # 要监听的库…

python使用uiautomator2操作雷电模拟器9找图(二)

昨天写过一篇文章 python使用uiautomator2操作雷电模拟器9找图&#xff08;一&#xff09;-CSDN博客 今天在实际中有遇到了新的问题&#xff1a;一幅主图中&#xff0c;可能存在多个相同的子图&#xff0c;想要找到所有的子图&#xff0c;并操作。比如&#xff1a; 主图&…

头歌-机器学习 第1次实验 Python机器学习软件包Scikit-Learn的学习与运用

第1关&#xff1a;使用scikit-learn导入数据集 scikit-learn包括一些标准数据集&#xff0c;不需要从外部下载&#xff0c;可直接导入使用&#xff0c;比如与分类问题相关的Iris数据集和digits手写图像数据集&#xff0c;与回归问题相关的波士顿房价数据集。 以下列举一些简单…

计算机网络-浏览器解析到URL对应的IP地址的时间

声明&#xff1a;原文转载链接出自&#xff1a; 哈工大Mooc——计算机网络&#xff1a;作业3 假设你在浏览某网页时点击了一个超链接&#xff0c;URL为“https://www.kicker.com.cn/index.html”&#xff0c;且该URL对应的IP地址在你的计算机上没有缓存&#xff1b;文件index…

OCR常用识别算法综述

参考&#xff1a;https://aistudio.baidu.com/education/lessonvideo/3279888 语种&#xff1a;常用字符36与常用汉字6623&#xff0c;区别。 标注&#xff1a;文本型位置/单字符位置&#xff0c;后者标注成本大 挑战&#xff1a;场景文字识别&#xff1a;字符大小、颜色、字体…

智能网络新纪元:机器学习赋能未来计算机网络高速发展

&#x1f9d1; 作者简介&#xff1a;阿里巴巴嵌入式技术专家&#xff0c;深耕嵌入式人工智能领域&#xff0c;具备多年的嵌入式硬件产品研发管理经验。 &#x1f4d2; 博客介绍&#xff1a;分享嵌入式开发领域的相关知识、经验、思考和感悟,欢迎关注。提供嵌入式方向的学习指导…

2024-04-11最新dubbo+zookeeper下载安装,DEMO展示

dubbozookeeper下载安装 下载zookeeper&#xff1a; 下载地址 解压&#xff0c;并进入bin目录&#xff0c;启动 如果闪退可以编辑脚本&#xff0c;在指定位置加上暂停脚本 报错内容说没有conf/zoo.cfg&#xff0c;就复制zoo_sample.cfg重命名为zoo.cfg 再次启动脚本&#x…

CentOS部署Apache Superset大数据可视化BI分析工具并实现无公网IP远程访问

文章目录 前言1. 使用Docker部署Apache Superset1.1 第一步安装docker 、docker compose1.2 克隆superset代码到本地并使用docker compose启动 2. 安装cpolar内网穿透&#xff0c;实现公网访问3. 设置固定连接公网地址 前言 Superset是一款由中国知名科技公司开源的“现代化的…

GPT中的Transformer架构以及Transformer 中的注意力机制

目录 1 GPT中的Transformer架构 2 transformer中的注意力机制 参考文献&#xff1a; 看了两个比较好的视频&#xff0c;简单做了下笔记。 1 GPT中的Transformer架构 GPT是Generative Pre-trained Transformer单词的缩写&#xff0c;其中transformer是一种特定的神经网络&a…

关于无人机,你必须知道的事!!(科技篇)

飞行器的五脏六腑 电机&#xff1a;无人机的动力单元&#xff0c;俗称“马达”。通过电机转动来驱动螺旋桨旋转&#xff0c;最终让飞机上天。 电调&#xff1a;无人机的动力单元&#xff0c;是接收油门信号并调整电机转速的控制枢纽&#xff0c;俗称电机的“黑屋调教师” 飞…