k8s中使用prometheus operator监控外部服务器部署的windows exporter

0、文档说明

(1)Prometheus Operator是一个流行的k8s集群监控套件,项目地址:https://github.com/prometheus-operator/kube-prometheus,在参考文档部署前,请先确保在k8s环境中已经部署成功Prometheus Operator组件

(2)本文档通过 ServiceMonitor 方式部署监控信息,至于其他方式的部署,这里不做说明

(3)在k8s中监控外部资源,并不仅限于windows exporter,可以是k8s外部任意类型的服务对应的exporter,例如Node、Mysql、Redis、etcd等。本文档中部署的10.1.121.157为非集群节点

(4)Windows Exporter 由 Prometheus Community 维护的一个采集 Windows 机器指标的采集器,支持 Windows Server 2008R2 以上版本或者 Windows 7 以上版本,官方地址是:https://github.com/prometheus-community/windows_exporter,当前版本是 v0.20.0。

(5)在参考本文档之前,请先确保外部服务器已经安装成功 windows exporter,关于windows exporter的安装,这里不再说明,windows exporter的下载地址如下:https://github.com/prometheus-community/windows_exporter/releases

(6)版本说明

资源名称 版本信息 说明
Kubernetes v1.23.7 k8s服务器
Kuboard v3.5.2.0 k8s连接管理工具
windows exporter v0.20.0 windows exporter版本
prometheus operator v0.43.2 prometheus operator版本
Grafana v9.0.2 Grafana版本

1、部署操作步骤

1.1、外部服务器安装windows exporter

(1)Windows Exporter 在发布的时候提供了两种格式的文件,即 *.exe 和 *.msi 。MSI (Microsoft Installers)是 Windows 的包管理器,类似于 Linux 的 rpm。Windows Exporter 每个版本都提供一个 .msi 安装程序。安装程序将 windows_exporter 设置为 Windows 服务,并在 Windows 防火墙中创建一个异常。我们在使用的时候可以选择任意一种格式来进行安装。下载地址如下:https://github.com/prometheus-community/windows_exporter/releases

(2)关于windows exporter的安装,这里不再对此说明,可以参考如下安装:https://help.aliyun.com/document_detail/463494.html

1.2、在k8s中创建Service

在k8s容器中需要为外部服务器上安装的windows exporter定义一个不需要Pod的Service,从而将k8s与外界服务器建立联系。外部服务器的服务定义与k8s中普通服务定义非常相似,对应的yml文件如下:

---
apiVersion: v1
kind: Service
metadata:
name: windows-exporter-157
namespace: prometheus-exporter
labels:
app: windows-exporter-157
app.kubernetes.io/name: windows-exporter-157
spec:
clusterIP: None
ports:
- name: metrics
port: 9182
protocol: TCP
targetPort: 9182

说明:

(1)windows_exporter默认端口是9182,这里配置的端口号和外部服务器安装的windows exporter保持一致

(2)这里部署的Service下没有关联pod,仅是一个单独的service,需要建立endpoints将其外部服务与service建立关联

1.3、为创建的Service建立endpoints

---
apiVersion: v1
kind: Endpoints
metadata:
name: windows-exporter-157
namespace: prometheus-exporter
labels:
app: windows-exporter-157
app.kubernetes.io/name: windows-exporter-157
subsets:
- addresses:
# 这里是外部资源列表
- ip: 10.1.121.157
ports:
- name: metrics
port: 9182

说明:

(1)Service名称必须和Endpoints名称一致才能使Service指向对应的资源

(2)通过采用IP指定的方式,将endpoints与外部资源关联起来

1.4、在k8s中创建ServiceMonitor

---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: windows-exporter-157
namespace: prometheus-exporter
labels:
app: windows-exporter-157
release: prometheus
spec:
selector:
matchLabels:
app: windows-exporter-157
namespaceSelector:
matchNames:
- prometheus-exporter
endpoints:
- port: metrics
interval: 1m
path: /metrics
scheme: http

说明:

(1)服务创建完成需要配置一个ServiceMonitor来监控服务监控采集地址,默认情况下监控采集地址为 /metrics

(2)Service Monitor中endpoints配置部分的port名称与之前部署的endpoints保持一致

1.5、在k8s中查看监控数据

1.5.1、Prometheus Targets

1.5.2、Grafana dashboard

Grafana dashboard中导入的看板ID为:10467,grafana模板地址如下:https://grafana.com/grafana/dashboards/,windows exporter对应的监控指标以官方文档为准,因为在导入模板进行数据展示的时候,发现有些监控指标已经更改了名称,当然监控指标也可以在上述内容部署成功之后,通过prometheus的可视化界面查询得到当前监控的指标数据(官方文档地址:https://github.com/prometheus-community/windows_exporter/blob/master/docs/README.md),所以针对监控指标表示的意思这里不再进行说明,感兴趣的小伙伴可以参考官方说明。

k8s中使用prometheus operator监控外部服务器部署的windows exporter的更多相关文章

  1. k8s Helm安装Prometheus Operator

    Ubuntu 18 Kubernetes集群的安装和部署 以及Helm的安装完成了k8s的集群和helm的安装,今天我们来看看Prometheus的监控怎么搞.Prometheus Operator ...

  2. Prometheus Operator 监控Kubernetes

    Prometheus Operator 监控Kubernetes 1. Prometheus的基本架构 ​ Prometheus是一个开源的完整监控解决方案,涵盖数据采集.查询.告警.展示整个监控流程 ...

  3. kubernetes(k8s) Prometheus+grafana监控告警安装部署

    主机数据收集 主机数据的采集是集群监控的基础:外部模块收集各个主机采集到的数据分析就能对整个集群完成监控和告警等功能.一般主机数据采集和对外提供数据使用cAdvisor 和node-exporter等 ...

  4. 使用Prometheus Operator 监控Kubernetes(15)

    一.Prometheus概述: Prometheus是一个开源系统监测和警报工具箱. Prometheus Operator 是 CoreOS 开发的基于 Prometheus 的 Kubernete ...

  5. c#.net调用pdf2swf.exe将pdf文件转换为swf,vs中运行正常,布署IIS服务器部署转换后文字部分为空白

    这个是权限问题, 需要在应用程序池中高级设置,将标识改为LocalSystem

  6. Prometheus + Grafana 监控系统搭

    本文主要介绍基于Prometheus + Grafana 监控Linux服务器. 一.Prometheus 概述(略) 与其他监控系统对比 1 Prometheus vs. Zabbix Zabbix ...

  7. prometheus-添加监控linux服务器

    1. prometheus-添加监控linux服务器 prometheus添加监控linux服务器 node_exporter:用于监控Linux系统的指标采集器. 常用指标: CPU 内存 硬盘 网 ...

  8. 在 K8S 中快速部署 Redis Cluster & Redisinsight

    Redis Cluster 部署 使用 Bitnami helm chart 在 K8S redis 命名空间中一键部署 Redis cluster . helm repo add bitnami h ...

  9. k8s中prometheus监控k8s外mysql

    k8s外安装mysql https://www.cnblogs.com/uncleyong/p/10739530.html 配置MySQL Exporter采集MySQL监控数据 创建yaml文件:v ...

  10. Kubernetes 监控方案之 Prometheus Operator(十九)

    目录 一.Prometheus 介绍 1.1.Prometheus 架构 1.2.Prometheus Operator 架构 二.Helm 安装部署 2.1.Helm 客户端安装 2.2.Tille ...

随机推荐

  1. elasticsearch 聚合之 date_histogram 聚合

    目录 1.背景 2.bucket_key如何计算 3.前置知识 4.日历和固定时间间隔 4.1 Calendar intervals 日历间隔 4.2 Fixed intervals 固定间隔 5.数 ...

  2. Forest + IDEA = 双倍快乐!ForestX 隆重登场

    Forest + IDEA = 双倍快乐!ForestX 隆重登场 Forest 是一款声明式的 Java 开源 HTTP 框架,相比它的前辈 Httpclient 和 OkHttp 更简明易懂.也更 ...

  3. Springboot自动装配源码及启动原理理解

    Springboot自动装配源码及启动原理理解 springboot版本:2.2.2 传统的Spring框架实现一个Web服务,需要导入各种依赖JAR包,然后编写对应的XML配置文件 等,相较而言,S ...

  4. 18V降压3.3V,15V降压3.3V的降压IC和LDO芯片方案

    在 18V 和 15V 输入中,我们需要给其他电源电路提高供电,有的电路的供电电压在 5V,或者是 3.3V 时, 我们就需要使用降压芯片来组建一个降压电路来给后面的的电路,提供稳定的,持续的 3.3 ...

  5. 盘点JAVA中基于CAS实现的原子类, 你知道哪些?

    前言 JDK中提供了一系列的基于CAS实现的原子类,CAS 的全称是Compare-And-Swap,底层是lock cmpxchg指令,可以在单核和多核 CPU 下都能够保证比较交换的原子性.所以说 ...

  6. pycharm 小技巧

    ctrl键 + B 查看定义源代码 alt键 + enter键 查看帮助 ctrl键 + shift键 + -号 所有代码隐藏 ctrl键 + shift键 + +号 所有代码展示 ctrl键 + D ...

  7. uniapp 微信小程序 引入 环信聊天

    最近项目需要实现一个聊天的功能,群聊或者单聊,用到环信,根据官网实现一下相关的配置吧 第一:下载环信demo  地址:https://github.com/easemob/webim-uniapp-d ...

  8. 【深入浅出 Yarn 架构与实现】4-2 RM 管理 Application Master

    上一篇文章对 ResourceManager 整体架构和功能进行了讲述.本篇将对 RM 中管理 Application Master 的部分进行深入的讲解. 下面将会介绍 RM 与 AM 整体通信执行 ...

  9. vulnhub靶场之HACKABLE: III

    准备: 攻击机:虚拟机kali.本机win10. 靶机:Hackable: III,下载地址:https://download.vulnhub.com/hackable/hackable3.ova,下 ...

  10. 快速体验,学习lua(一种可嵌入c++,c#,android,object-c等并进行互调支持热更新的脚本)的入门调试系列(3)

    --这里是注释 --[[ 功能备注:lua快速体验,学习,了解语法(调试,类似try-catch) 创建时间:2020-6-27 创建人:pcw --]] print("---------- ...