在 Istio1.4 及以上版本中,可观测性指标的创建、交换和抓取的方式已经发生改变。

以下内容讲述了我如何配置 Prometheus Operator 资源以从 Istio1.6 中抓取指标和安装最新版的 Grafana 仪表盘。

ServiceMonitor

Prometheus Operator 比默认的 Prometheus 安装更加动态。它增加了一些 CRD 以动态和透明地重新配置 Prometheus 集群。

ServiceMonitor 资源对象用于描述需要抓取哪些 Service 中的 Pod。

在 Istio1.6 + 版本中,我们需要监控两种类型的资源:Istio 控制平面资源和 Istio 代理的数据平面资源。

为此,我们创建了 2 个不同的 ServiceMonitor:

控制平面

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:name: prometheus-oper-istio-controlplanelabels:release: prometheus
spec:jobLabel: istioselector:matchExpressions:- {key: istio, operator: In, values: [mixer,pilot,galley,citadel,sidecar-injector]}namespaceSelector:any: trueendpoints:- port: http-monitoringinterval: 15s- port: http-policy-monitoringinterval: 15s

如果你懂一点 Prometheus,很容易看出该控制平面做的事:

  1. 使用标签 istio 寻找其对应值是 mixer、pilot 等的服务。
  2. 每隔 15 秒抓取名为 http-monitoring 和 http-policy-monitoring 的端口。

需要注意开头处的 labels 标签,它们是必须与 Prometheus 安装的 serviceMonitor Selector 相匹配的选择器。如果此处设置不正确,Prometheus 就不会抓取该资源。

你可以通过查看 prometheus 资源来检查 serviceMonitor 的 mathchLabels 配置:

kubectl get prometheus  -o yaml | grep -A4 serviceMonitorSelector
serviceMonitorSelector:matchLabels:release: prometheus

在我的案例中,它是 release: prometheus。

数据平面

数据平面资源和之前的控制平面差不多,但它针对所有的 Istio 代理的容器并且添加了一些标签重写处理。

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:name: prometheus-oper-istio-dataplanelabels:monitoring: istio-dataplanerelease: prometheus
spec:selector:matchExpressions:- {key: istio-prometheus-ignore, operator: DoesNotExist}namespaceSelector:any: truejobLabel: envoy-statsendpoints:- path: /stats/prometheustargetPort: http-envoy-prominterval: 15srelabelings:- sourceLabels: [__meta_kubernetes_pod_container_port_name]action: keepregex: '.*-envoy-prom'- action: labelmapregex: "__meta_kubernetes_pod_label_(.+)"- sourceLabels: [__meta_kubernetes_namespace]action: replacetargetLabel: namespace- sourceLabels: [__meta_kubernetes_pod_name]action: replacetargetLabel: pod_name

请确保你写的标签正确以使 Operator 关注到该资源。

如果你不希望 Prometheus 抓取到某一代理的指标,在你的部署中添加 istio-prometheus-ignore=”true” 标签。

结果

等待几秒钟让一切运行完,你就可以通过在 9090 端口进行端口转发连接到你的 Prometheus 前端。也可以通过以 SDS 方式使用 SSL 证书配置的 Istio 入口网关连接前端。

Grafana 仪表盘

既然已经将 Istio Telementry V2 纳入了你的 Prometheus 集群,你也许想用 Grafana 看看图表。

很高兴你能读到这里。我知道这篇博客缺少一些配图,但谁在乎呢?我们是工程师,对吧? Istio Dashboards for Grafana 的源码存储在许多地方。你可以在 Istio Github repo 中找到最新的版本,但最好的解决方案是从 istio 的 zip 或 tar 安装压缩包中 (获取 istioctl 的地方) 获取与你安装的 Istio 相匹配的版本!从 Istio 文档中得知可以通过以下命令下载最新版本的 Istio:

curl -L https://istio.io/downloadIstio | sh -

该命令会创建一个带有所有 Istio 组件的文件夹。请注意插件(如 Grafana、Kiali、Prometheus 等)很快将不会被 istioctl 管理。你可以在这个文件夹里找到所有的部署脚本。

仪表盘也位于这个文件夹中(本文撰写时使用 istio1.6.7),在 manifests/charts/istio-telemetry/grafana/dashboards/ 目录下。

对想要在 Grafana(被 PrometheusOperator 安装的那个)中被展示的指标,你需要将它们拷贝到 secret 中。以下是我使用的脚本(使用它前先 cd 到你的 istio 文件夹下):

#!/bin/bash# go into the dashboards folder
pushd manifests/charts/istio-telemetry/grafana/dashboards# create the basic command to create the configmap
ISTIO_DASHBOARD_SECRET="kubectl -n monitoring create cm prometheus-oper-istio-dashboards"# append each file to the secret
for i in *.json ; doecho $iISTIO_DASHBOARD_SECRET="${ISTIO_DASHBOARD_SECRET} --from-file=${i}=${i}"
done# run the secret creation command
eval $ISTIO_DASHBOARD_SECRET# label the configmap so it is used by Grafana
kubectl label -n monitoring --overwrite cm prometheus-oper-istio-dashboards grafana_dashboard=1popd

重启 Grafana 的 pod,你将在 Grafana 中看到以下的仪表盘。

作者:Sebastien Thomas,Tetrate 的工程师和基础设施 Macgyver,专长 Istio 设置和支持。

ashx在web.config中如何配置_如何在 Istio 1.6 中配置 Prometheus-Operator 和抓取指标相关推荐

  1. 符号在excel中的引用_如何在Excel工作表中添加表情符号

    &符号在excel中的引用 In the old days, we typed emoticons in our messages, to show a grin, or wink, etc. ...

  2. r中汇率市场_如何在Word 2013表中汇总行和列

    r中汇率市场 If you're working in Word and you need to total values in a table, you can do so without havi ...

  3. python中options设置_如何在AngularJS的ng-options中设置value属性?

    小编典典 ngOptions(可选) – { comprehension_expression=} –以下形式之一: 对于数组数据源 : label for value in array select ...

  4. mysql查询中使用别名_如何在MySQL选择查询中使用别名?

    要在MySQL中设置别名或替代名称,您需要使用AS关键字.让我们首先创建一个表-mysql> create table DemoTable ( Name varchar(100) ); 使用插入 ...

  5. java表格中添加按钮_如何在JavaFX表视图中添加按钮

    我已经在谷歌和Stackoverflow上搜索了这个,我只是没有得到给定的例子 . 有人可以向我解释一下 . 我想在表视图的最后一列添加一个按钮,当它被单击时,它应该触发一个监听器并传递按钮行的对象 ...

  6. r语言中调用c 程序,如何在R程序包中调用C函数

    程序包名称为pareto.这是.c文件中src目录:如何在R程序包中调用C函数 #include #include #include "Rinternals.h" #include ...

  7. ASP.NET杂谈-一切都从web.config说起(2)(ConfigSections详解-中)

    我们就接着上一篇继续说,上一篇中介绍了ConfigSection的结构和两个简单的DEMO,本篇就说一下SectionGroup.ConfigurationElementCollection和key/ ...

  8. yii2 跨域请求配置_如何在SpringBoot应用中实现跨域访问资源和消息通信?

    允许跨域访问 CORS ( Cross Origin Resource Sharing,跨域资源共享)机制允许Web应用服务器进行跨域访问控制,从而使跨域数据传输得以安全进行.浏览器支持在API容器中 ...

  9. centos ip配置_在虚拟机(Vmware)中配置centos7系统静态ip,就是如此简单

    1 背景 使用vmware或virtualbox安装了centos操作系统后,下一步要做的要做的就是设置网络.通常linux系统是用来做服务器的,也很少使用(安装)桌面版的系统.服务器通常是放在服务运 ...

最新文章

  1. 海思osd+freetype+SDL+SDL_ttf编译成功后,Makefile的编写
  2. Java中实现图像的卷积效果
  3. 转vc++ 类自己消失
  4. nginx could not build the server_names_hash 解决方法
  5. 问卷星作答能不能检测到屏幕共享_云端检测,别样精彩——大厂回族自治县王必屯中心小学线上期末检测纪实...
  6. numpy ndarray.tostring()(在数组中构造包含原始数据字节的Python字节)(tobytes()函数的兼容性别名)
  7. 如何做一个流畅的UI 组内分享记录
  8. c#正则匹配取出文本内容 循环输出
  9. 去掉xcode中警告的一些经验
  10. 深度神经网络课程总结_了解深度神经网络如何工作(完整课程)
  11. Java学习四步曲,助你成长!
  12. 通过少儿英语入门孩子的自信更多
  13. node.js 异步_Node.js v14中的异步本地存储是什么?
  14. 【265天】跃迁之路——程序员高效学习方法论探索系列(实验阶段23-2017.10.28)...
  15. TensorFlow学习笔记--第三节张量(tensor)及其定义方法
  16. MYSQL limit 分页
  17. ISE如何生成msc文件,并写入flash中
  18. Markdown常用特殊符号
  19. dyndns免费动态域名
  20. IOS点击事件延迟300ms踩坑

热门文章

  1. sonarqube代码检核工具安装
  2. 沈阳大学计算机考研,计算机专业考研成功经验谈:掌握方法,以不变应万变
  3. mysql cst_一次 JDBC 与 MySQL 因 “CST” 时区协商误解导致时间差了 14 或 13 小时的排错经历...
  4. bootstrap-table 列属性_bootstrap中table如何隐藏列?
  5. c# 多线程实现ping 多线程控制控件
  6. 1247 排排站 USACO(查分+hash)
  7. unset是不能清除保存在本地电脑上的cookie的,用于session就可以(弄了半天原来是这样)...
  8. 从CMO到龙泉寺弟子:佛法改变人生
  9. 联邦知识蒸馏概述与思考(续)
  10. 【新书推荐】机器学习算法竞赛实战,Kaggle Grandmaster倾力打造,涵盖Kaggle、天池等赛题...