如何监控容器或K8s中的OpenSearch

news/2024/5/2 20:43:19/文章来源:https://blog.csdn.net/east4ming/article/details/137605985

概述

当前 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: trueinstallList:- 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: opensearchmetrics_path: /_prometheus/metricsrelabel_configs:- replacement: '<your-instance-name>'target_label: nodestatic_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.luyixian.cn/news_show_1045989.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

红豆Cat 1开源|项目三: 从0-1设计一款HTTP版本RTU(支持GNSS)产品的软硬件全过程

HTTP版RTU&#xff08;支持GNSS&#xff09;项目概述 RTU&#xff08;Remote Terminal Unit&#xff09;&#xff0c;中文即远程终端控制系统&#xff0c;负责对现场信号、工业设备的监测和控制。RTU是构成企业综合自动化系统的核心装置&#xff0c;通常由信号输入/出模块、微…

蓝桥杯-单片机基础16——利用定时计数中断进行动态数码管的多窗口显示

综合查阅了网络上目前能找到的所有关于此技能的代码&#xff0c;最终找到了下述方式比较可靠&#xff0c;且可以自定义任意显示的数值。 传统采用延时函数的方式实现动态数码管扫描&#xff0c;在题目变复杂时效果总是会不佳&#xff0c;因此在省赛中有必要尝试采用定时计数器中…

洪水预警:如何通过数据可视化提前应对灾害

数据可视化在应对洪涝灾害问题中发挥着重要作用。洪涝灾害是一种常见而严重的自然灾害&#xff0c;给人们的生命、财产和生活带来了巨大的威胁和损失。而数据可视化技术通过将海量的数据转化为直观、易懂的图表、图像或地图等形式&#xff0c;帮助人们更好地理解洪涝灾害的发生…

微服务-2 Eureka

Eureka 启动页面&#xff1a; 同理再注册完order-service后&#xff0c;刷新启动页面&#xff1a; userservice 启动多台服务&#xff1a; [ 代码 ]&#xff1a;orderService.java&#xff08;用 RestTemplate 调其他服务&#xff0c;用 userservice 代替 localhost:8081&…

视频图像的两种表示方式YUV与RGB(4)

本篇主要讲YUV与RGB之间的转换&#xff0c;包括YUV444 颜色编码格式 转为 RGB 格式 &#xff0c;RGB颜色编码格式转为 YUV444 格式。 一、 YUV与RGB之间的转换 YUV与RGB颜色格式之间进行转换时 , 涉及一系列的数学运算 ; YUV 颜色编码格式转为RGB格式的转换公式 取决于 于 YUV …

数据结构——线性表(顺序存储结构)

语言&#xff1a;C语言软件&#xff1a;Visual Studio 2022笔记书籍&#xff1a;数据结构——用C语言描述如有错误&#xff0c;感谢指正。若有侵权请联系博主 一、线性表的逻辑结构 线性表是n个类型相同的数据元素的有限序列&#xff0c;对n>0&#xff0c;除第一元素无直接…

电能质量问题有几类?再怎样进行谐波治理

一、为什么要进行电能质量的治理 电能质量是指电力系统中电能的质量。理想的电能应该是完美对称的正弦波。一些因素会使波形偏离对称正弦&#xff0c;由此便产生了电能质量问题。一方面我们研究存在哪些影响因素会导致电能质量问题&#xff0c;一方面我们研究这些因素会导致哪…

如何用electron(vue)搜索电脑本地wifi

对于搜索本地 WiFi 网络&#xff0c;可以使用 Electron 结合 Node.js 来编写一个简单的应用程序。 以下是一个基本的示例&#xff0c;它使用 Node.js 的 wifi 模块来搜索并列出附近的 WiFi 网络&#xff1a; 首先&#xff0c;确保你已经安装了 Node.js 和 Electron。 然后&am…

linux 搭建Samba服务

Samba简介 SAMBA是⼀个实现不同操作系统之间⽂件共享和打印机共享的⼀种SMB协议的免费软件&#xff0c; SMB(Server Message block)协议是window下所使⽤的⽂件共享协议&#xff0c;我们在linux系统或 者其类unix系统当中可以通过samba服务来实现SMB功能。 &#xff08;1&…

【SpringBoot】-- mapstruct进行类型转换时Converter实现类不能自动生成代码问题解决

问题描述 我的问题如下&#xff1a; 应该在红色区域生成对应的转换细节&#xff0c;但是这里只返回了一个空对象 问题解决 加入lombok-mapstruct-binding依赖,也要注意依赖引用顺序问题 <dependency><groupId>org.projectlombok</groupId><artifactId&…

chrome google浏览器添加插件扩展失败怎么办,无法从该网站添加应用、扩展程序和用户脚本确定,

无法从该网站添加应用、扩展程序和用户脚本确定 chrome google浏览器添加插件扩展失败怎么办&#xff0c;无法从该网站添加应用、扩展程序和用户脚本确定&#xff0c; 需要打开调试模式 chrome://extensions/

NzN的数据结构--选择排序

接上文&#xff0c;本章我们来介绍选择排序。先三连后看才是好习惯~~~ 目录 一、基本思想 二、直接选择排序 三、堆排序 一、基本思想 每一次从待排序的数据元素中选出最小&#xff08;或最大&#xff09;的一个元素&#xff0c;存放在序列的起始位置&#xff0c;直到全部待…

Burp Suite Professional 2024.3.1 for macOS x64 ARM64 - 领先的 Web 渗透测试软件

Burp Suite Professional 2024.3.1 for macOS x64 & ARM64 - 领先的 Web 渗透测试软件 世界排名第一的 Web 渗透测试工具包 请访问原文链接&#xff1a;Burp Suite Professional 2024.3.1 for macOS x64 & ARM64 - 领先的 Web 渗透测试软件&#xff0c;查看最新版。原…

[机器学习Day 1~3

[机器学习]Day 1~3 数据预处理第1步&#xff1a;导入库第2步&#xff1a;导入数据集第3步&#xff1a;处理丢失数据第4步&#xff1a;解析分类数据创建虚拟变量 第5步&#xff1a;拆分数据集为训练集合和测试集合第6步&#xff1a;特征量化 简单线性回归模型第一步&#xff1a;…

Echarts-实现地图并轮播地图信息

目录 ./map-geojson/jinhua.json./CenterMap.vue./center.vue 使用地图组件效果 ./map-geojson/jinhua.json {"type":"FeatureCollection","features":[{"type":"Feature","properties":{"adcode":330…

redis过期监听机制

转自&#xff1a;https://www.cnblogs.com/wangyunhong/articles/16505079.html 1.redis配置 1.打开conf/redis.conf 文件&#xff0c;取消注释&#xff1a;notify-keyspace-events Ex 2.重启redis 3.如果设置了密码需要重置密码&#xff1a;config set requirepass **** 3…

uniapp小程序中使用video视频播放卡顿

问题:在使用uniapp小程序的video视频播放,视频已经在播放了,但是进度条没走,还是卡顿的状态(测试ios能正常使用,安卓手机会出现此问题) 在网上找了很多方法,最多的说是用:custom-cache"false",试了并没有效果,看来和我问题不一样,后来用了个简单粗暴的方法,发现是有效…

前端三剑客 —— JavaScript (第四节)

目录 内容回顾&#xff1a; 函数 *** 什么是函数 函数定义 函数调用 函数使用示例 匿名函数 无参函数 箭头函数 1、无参无返回值 2、无参有返回值 3、无参有返值&#xff0c;但函数体只有一条语句&#xff0c;则大括号可以省略&#xff0c; return 语句可以省略 4…

零售EDI:Princess Auto EDI对接

Princess Auto 是一家加拿大零售连锁店&#xff0c;专门从事农场、工业、车库、液压和剩余物品的销售。 Princess Auto 总部位于马尼托巴省温尼伯&#xff0c;截至 2024 年 1 月在 10 个省份拥有并经营 55 家商店以及三个配送中心。各种商品均以其“Powerfist”和“Pro.Point”…

【3GPP】【核心网】【5G-A】5G-A三载波聚合介绍

1. 欢迎大家订阅和关注&#xff0c;3GPP通信协议精讲&#xff08;2G/3G/4G/5G/IMS&#xff09;知识点&#xff0c;专栏会持续更新中.....敬请期待&#xff01; 目录 1. 5G-A概念 2. 什么是3CC 3. 3CC的技术看点 4. 3CC的应用场景 5. 3CC支持的终端 1. 5G-A概念 5G-A全称5G…