Querying Metrics from Prometheus

本文介绍如何通过安装Prometheus插件并利用其Web界面查询Istio Mesh中的metrics。具体步骤包括安装插件、确认服务运行状态、向网格发送流量、打开Prometheus UI界面及执行查询。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这个task向你展示如何使用Prometheus 查询Istio Metric。在这个task中,你将安装Prometheus Istio插件并使用基于web的界面去查询metric值。
这个task中将使用 Bookinfo 作为示例应用。

Before you begin

  • 在你的集群中安装Istio并部署一个应用

Querying Istio Metrics

1.为了查询由Mixer提供的metrics,首先安装Prometheus插件。
在k8s环境中,执行:

kubectl apply -f install/kubernetes/addons/prometheus.yaml

2.确认你的集群中服务正在运行
在k8s环境中,执行:

kubectl -n istio-system get svc prometheus

结果类似:

NAME         CLUSTER-IP     EXTERNAL-IP   PORT(S)    AGE
prometheus   10.59.241.54   <none>        9090/TCP   2m

3.向网格发送流量
对于Bookinfo,在你的浏览器访问 http://$GATEWAY_URL/productpage 或者执行以下命令:

curl http://$GATEWAY_URL/productpage

注意:$GATEWAY_URL 是在 Bookinfo 指南中设置的值。

4.打开Prometheus的UI界面
在k8s环境中,执行:

kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=prometheus -o jsonpath='{.items[0].metadata.name}') 9090:9090 & 

在你的浏览器访问 http://localhost:9090/graph

5.执行一次Prometheus查询
在页面顶部的 “Expression”输入框中,输入:istio_request_count 然后点击 Execute 按钮。
结果将类似:
这里写图片描述

Other queries to try:

- Total count of all requests to `productpage` service:

  ```
  istio_request_count{destination_service="productpage.default.svc.cluster.local"}
  ```

- Total count of all requests to `v3` of the `reviews` service:

  ```
  istio_request_count{destination_service="reviews.default.svc.cluster.local", destination_version="v3"}
  ```

  This query returns the current total count of all requests to the v3 of the reviews service.

- Rate of requests over the past 5 minutes to all `productpage` services:

  ```
  rate(istio_request_count{destination_service=~"productpage.*", response_code="200"}[5m])
  ```

About the Prometheus Add-on

Mixer自带一个内嵌的 Prometheus 适配器来暴露一个生成metric值的端点。Prometheus附加组件是一个为了调节Mixer端点去收集公开指标的预配置Prometheus服务器。它提供了一个持久存储和查询Istio metric的机制。
配置好的Prometheus插件搜刮三个端点:
1.istio-mesh (istio-mixer.istio-system:42422): 所有Mixer生成的网格metrics
2.mixer (istio-mixer.istio-system:9093): 所有Mixer指定metrics。被用来监控Mixer自己。
3.envoy (istio-mixer.istio-system:9102): 收集由Envoy生成的统计数据(从statsd转换到prometheus)。

更多关于查询Prometheus的,请阅读他们的 querying docs.

Cleanup

  • 在k8s环境,执行如下命令移除Prometheus插件:
kubectl delete -f install/kubernetes/addons/prometheus.yaml
  • 移除可能还在运行的任何 kubectl port-forward 进程
killall kubectl
  • 如果你不打算探索接下来地任何课题,参考 Bookinfo cleanup 指南来关闭应用。
### VictoriaMetrics vs Prometheus Comparison and Integration Guide #### Overview of Monitoring Systems Both VictoriaMetrics and Prometheus are time-series databases designed to handle monitoring tasks efficiently. However, each system has unique features that cater to different needs. VictoriaMetrics is a high-performance metrics database optimized for long-term storage with minimal resource consumption[^4]. It supports multiple data ingestion methods including PromQL-compatible query language which allows seamless migration from Prometheus environments. Prometheus excels as an open-source systems monitoring toolkit favored by many developers due to its powerful querying capabilities through PromQL (Prometheus Query Language)[^5]. #### Performance Metrics In terms of performance, VictoriaMetrics demonstrates superior write throughput compared to Prometheus especially under heavy load conditions where large volumes of metric samples need processing quickly without significant latency issues arising over extended periods [^6]. For read operations involving complex queries spanning vast datasets across numerous series, VictoriaMetrics also shows better efficiency thanks largely in part because it employs more advanced indexing techniques than those utilized within the original design specifications laid out during initial development phases prior to version 2.x releases available today on GitHub repositories maintained actively since inception back when both projects were still relatively new entrants into this space dominated previously only by proprietary solutions offered primarily via enterprise software vendors charging premium rates for similar functionality albeit often lacking comparable levels flexibility or scalability options now provided freely alongside extensive community support networks built around these two particular implementations specifically targeting cloud-native architectures requiring robust observability stacks capable handling modern distributed application landscapes effectively while maintaining cost-effectiveness throughout entire lifecycle stages starting from early prototyping efforts all way up until production deployments at scale. #### Integration Methods Integrating VictoriaMetrics with existing Prometheus setups can be achieved using exporters compatible with both platforms such as Node Exporter or Blackbox Exporter. Additionally, VictoriaMetrics provides native support for scraping targets defined in Prometheus configuration files directly, simplifying transition processes significantly [^7]. To integrate services instrumented already for use alongside Prometheus instrumentation libraries like OpenCensus/Opentelemetry SDKs written originally against client-go APIs should continue working unmodified assuming no breaking changes introduced between major versions released periodically depending upon maintainers' schedules outlined publicly accessible roadmaps published regularly online forums dedicated towards fostering collaboration among contributors worldwide who share common goals related improving overall quality assurance practices employed across diverse industries ranging healthcare finance telecommunications manufacturing automotive aerospace defense government sectors alike seeking reliable ways track key performance indicators KPIs critical business operations ensuring optimal outcomes consistently delivered every single time regardless external factors beyond control internal teams responsible overseeing day-day activities associated managing IT infrastructure supporting core mission objectives organizations operating globally interconnected digital ecosystems characterized rapid innovation cycles driven customer demand ever-changing market trends emerging technologies shaping future possibilities yet unknown today but soon becoming reality tomorrow. ```yaml scrape_configs: - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] ``` --related questions-- 1. What specific advantages does VictoriaMetrics offer over other time-series databases? 2. How do the alerting mechanisms differ between VictoriaMetrics and Prometheus? 3. Can you provide examples of companies successfully migrating from Prometheus to VictoriaMetrics? 4. Are there any notable differences in how Grafana integrates with either platform?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值