第 12 章 Red Hat Quay 中的 Prometheus 和 Grafana 指标

Red Hat Quay 会在每个实例上导出 Prometheus- 和 Grafana 兼容的端点,以便轻松监控和警报。

12.1. 公开 Prometheus 端点

12.1.1. 独立 Red Hat Quay

当使用 podman run 启动 Quay 容器时,公开指标端口 9091

$ sudo podman run -d --rm -p 80:8080 -p 443:8443  -p 9091:9091\
   --name=quay \
   -v $QUAY/config:/conf/stack:Z \
   -v $QUAY/storage:/datastorage:Z \
   registry.redhat.io/quay/quay-rhel8:v3.10.3

现在,指标将可用:

$ curl quay.example.com:9091/metrics

有关配置 Prometheus 和 Grafana 以监控 Quay 存储库计数的详情,请参阅使用 Prometheus 和 Grafana 监控 Quay。

12.1.2. Red Hat Quay Operator

确定 quay-metrics 服务的集群 IP:

$ oc get services -n quay-enterprise
NAME                                  TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                             AGE
example-registry-clair-app            ClusterIP   172.30.61.161    <none>        80/TCP,8089/TCP                     18h
example-registry-clair-postgres       ClusterIP   172.30.122.136   <none>        5432/TCP                            18h
example-registry-quay-app             ClusterIP   172.30.72.79     <none>        443/TCP,80/TCP,8081/TCP,55443/TCP   18h
example-registry-quay-config-editor   ClusterIP   172.30.185.61    <none>        80/TCP                              18h
example-registry-quay-database        ClusterIP   172.30.114.192   <none>        5432/TCP                            18h
example-registry-quay-metrics         ClusterIP   172.30.37.76     <none>        9091/TCP                            18h
example-registry-quay-redis           ClusterIP   172.30.157.248   <none>        6379/TCP                            18h

连接到集群,并使用 quay-metrics 服务的集群 IP 和端口访问指标:

$ oc debug node/master-0

sh-4.4# curl 172.30.37.76:9091/metrics

# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 4.0447e-05
go_gc_duration_seconds{quantile="0.25"} 6.2203e-05
...

12.1.3. 将 Prometheus 设置为消耗指标

Prometheus 需要一种方式来访问集群中运行的所有 Red Hat Quay 实例。在典型的设置中,这通过在名为 DNS 条目中列出所有 Red Hat Quay 实例来实现,然后提供给 Prometheus。

12.1.4. Kubernetes 下的 DNS 配置

可将简单的 Kubernetes 服务配置为 为 Prometheus 提供 DNS 条目。

12.1.5. 手动集群的 DNS 配置

SkyDNS 是不使用 Kubernetes 时管理此 DNS 记录的简单解决方案。SkyDNS 可以在 etcd 集群上运行。您可以在 etcd 存储中添加和删除集群中的每个 Red Hat Quay 实例的条目。SkyDNS 将定期从那里读取它们,并相应地更新 Quay 实例列表。