第 13 章 Red Hat Quay 下的 Prometheus 和 Grafana 指标

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

13.1. 公开 Prometheus 端点

13.1.1. Standalone 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.8.15

现在,指标将可用:

$ curl quay.example.com:9091/metrics

如需了解配置 Prometheus 和 Grafana 的详细信息,请参阅 使用 Prometheus 和 Grafana 监控 Quay 存储库计数。

13.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
...

13.1.3. 将 Prometheus 设置为消耗指标

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

13.1.4. Kubernetes 下的 DNS 配置

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

13.1.5. 手动集群的 DNS 配置

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