第 9 章 向 Prometheus 公开 3scale APIcast Metrics

重要

在这个 3scale 发行版本中,不支持 Prometheus 安装和配置。另外,您可以使用 Prometheus 的社区版本 视觉化 API 服务的指标和警报。

9.1. 关于 Prometheus

Prometheus 是一个开源系统监控工具包,可用于监控在红帽 OpenShift 环境中部署的 3scale APIcast 服务。

如果要使用 Prometheus 监控服务,您的服务必须公开 Prometheus 端点。此端点是一个 HTTP 接口,公开指标列表和指标的当前值。Prometheus 定期提取这些目标定义的端点,并将收集的数据写入其数据库中。

9.1.1. Prometheus 查询

在 Prometheus UI 中,您可以使用 Prometheus Query Language(PromQL)编写查询来提取指标信息。使用 PromQL,您可以实时选择和聚合时间序列数据。

例如,您可以使用以下查询为指标名称 http_requests_total 选择 Prometheus 在最后 5 分钟内记录的所有值:

http_requests_total[5m]

您可以通过为指标指定 label (键:值对)来进一步定义或过滤查询的结果。例如,您可以查询以下查询,为指标名称 http_requests_totaljob 标签设置为 integration 的所有时间序列选择 Prometheus 在最后 5 分钟内记录的所有值:

http_requests_total{job="integration"}[5m]

查询的结果可以显示为一个图形,在 Prometheus 的表达式浏览器中作为表格数据查看,或者通过使用 Prometheus HTTP API 由外部系统使用。Prometheus 提供数据的图形视图。要获得更强大的图形仪表板来查看 Prometheus 指标,Grafana 是一种常见选择。

您还可以使用 PromQL 语言在 Prometheus alertmanager 工具中配置警报。

注意

Grafana 是社区支持的功能。红帽生产服务级别协议(SLA)不支持部署 Grafana 来监控 Red Hat 3scale 产品。