健康指标


Red Hat Advanced Cluster Management for Kubernetes 2.13

健康指标

摘要

了解更多有关集群和组件的指标和监控的信息。

第 1 章 健康指标

您可以使用指标来监控组件的健康状况。

请参阅以下文档:

1.1. 使用 metrics 服务

您可以使用 metrics (指标) 来监控 Red Hat Advanced Cluster Management for Kubernetes 中的组件健康状况。在 Metrics chronicle 概述中记录了许多自定义指标。

1.1.1. 访问 hub 集群指标服务

要查看收集的指标,您必须在 hub 集群上公开 metrics 服务。如果您的指标已在 Grafana 仪表板中公开,这个过程是可选的。

在 OpenShift Container Platform 控制台中查找 metrics 服务。点 Observe > Metrics

如果您没有在 Grafana 仪表板、Grafana Explorer 或 OpenShift Container Platform 控制台中看到指标,则 Prometheus 可能无法配置为提取指标。继续使用 Scrapping with Prometheus 来公开您的指标。

1.1.2. Scraping with Prometheus

您可以使用 Prometheus 来公开从产品控制台公开的指标。请参阅 hub 和受管集群指标的步骤。

1.1.2.1. 提取 hub 集群

请参阅以下流程来公开 hub 集群的指标。这些文件位于 openshift-monitoring 命名空间中:

  1. 创建用于收集服务和公开指标的 ServiceMonitor。请参阅以下 YAML 示例:

    apiVersion: monitoring.coreos.com/v1
    kind: ServiceMonitor
    metadata:
      name: hub-subscription-metrics
      namespace: openshift-monitoring
    spec:
      endpoints:
      - port: metrics
      namespaceSelector:
        matchNames:
        - open-cluster-management
      selector:
        matchLabels:
          app: hub-subscription-metrics
  2. 运行以下命令以应用该文件:

    oc apply -f
  3. 创建用于设置监控权限的角色。请参阅以下 YAML 文件:

    apiVersion: rbac.authorization.k8s.io/v1
    kind: Role
    metadata:
      name: prometheus-k8s-monitoring
      namespace: open-cluster-management
    rules:
    - apiGroups:
      - ""
      resources:
      - services
      - endpoints
      - pods
      verbs:
      - get
      - list
      - watch
    - apiGroups:
      - extensions
      resources:
      - ingresses
      verbs:
      - get
      - list
      - watch
    - apiGroups:
      - networking.k8s.io
      resources:
      - ingresses
      verbs:
      - get
      - list
      - watch
  4. 运行以下命令以应用该文件:

    oc apply -f
  5. 创建一个 RoleBinding,将角色绑定绑定到 Prometheus monitoring ServiceAccount,如下例所示:

    apiVersion: rbac.authorization.k8s.io/v1
    kind: RoleBinding
    metadata:
      name: prometheus-k8s-monitoring-binding
      namespace: open-cluster-management
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: Role
      name: prometheus-k8s-monitoring
    subjects:
    - kind: ServiceAccount
      name: prometheus-k8s
      namespace: monitoring
  6. 运行以下命令以应用该文件:

    oc apply -f
  7. 要验证,请在仪表板中运行以下查询以查找 Subscription Operator Metrics Service 报告的指标:

    {service="hub-subscription-metrics"}
1.1.2.2. 提取受管集群

请参阅以下步骤为受管集群公开指标。这些文件位于 openshift-monitoring 命名空间中:

  1. 创建 ServiceMonitor 以收集服务公开指标。请参阅以下 YAML 文件示例:

    apiVersion: monitoring.coreos.com/v1
    kind: ServiceMonitor
    metadata:
      name: mc-subscription-metrics
      namespace: openshift-monitoring
    spec:
      endpoints:
      - port: metrics
      namespaceSelector:
        matchNames:
        - open-cluster-management-agent-addon
      selector:
        matchLabels:
          app: mc-subscription-metrics
  2. 运行以下命令以应用您的文件:

    oc apply -f
  3. 创建用于设置监控权限的角色。请参阅以下 YAML 文件示例:

    apiVersion: rbac.authorization.k8s.io/v1
    kind: Role
    metadata:
      name: prometheus-k8s-monitoring
      namespace: open-cluster-management-agent-addon
    rules:
    - apiGroups:
      - ""
      resources:
      - services
      - endpoints
      - pods
      verbs:
      - get
      - list
      - watch
    - apiGroups:
      - extensions
      resources:
      - ingresses
      verbs:
      - get
      - list
      - watch
    - apiGroups:
      - networking.k8s.io
      resources:
      - ingresses
      verbs:
      - get
      - list
      - watch
  4. 运行以下命令以应用该文件:

    oc apply -f
  5. 创建一个 RoleBinding,将 Role 绑定到 Prometheus monitoring ServiceAccount

    apiVersion: rbac.authorization.k8s.io/v1
    kind: RoleBinding
    metadata:
      name: prometheus-k8s-monitoring-binding
      namespace: open-cluster-management-agent-addon
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: Role
      name: prometheus-k8s-monitoring
    subjects:
    - kind: ServiceAccount
      name: prometheus-k8s
      namespace: monitoring
  6. 运行以下命令以应用该文件:

    oc apply -f
  7. 运行以下查询来查找 Subscription Operator Metrics Service 报告的指标,在 Prometheus 仪表板中验证:

    {service="mc-subscription-metrics"}

1.1.3. 提取独立集群

  1. 创建 ServiceMonitor 以收集服务公开指标:

    apiVersion: monitoring.coreos.com/v1
    kind: ServiceMonitor
    metadata:
      name: standalone-subscription-metrics
      namespace: openshift-monitoring
    spec:
      endpoints:
      - port: metrics
      namespaceSelector:
        matchNames:
        - open-cluster-management
      selector:
        matchLabels:
          app: standalone-subscription-metrics
  2. 创建用于设置监控权限的角色:

    oc apply -f
    apiVersion: rbac.authorization.k8s.io/v1
    kind: Role
    metadata:
      name: prometheus-k8s-monitoring
      namespace: open-cluster-management
    rules:
    - apiGroups:
      - ""
      resources:
      - services
      - endpoints
      - pods
      verbs:
      - get
      - list
      - watch
    - apiGroups:
      - extensions
      resources:
      - ingresses
      verbs:
      - get
      - list
      - watch
    - apiGroups:
      - networking.k8s.io
      resources:
      - ingresses
      verbs:
      - get
      - list
      - watch
  3. 创建一个 RoleBinding,将 Role 绑定到 Prometheus monitoring ServiceAccount。请参阅以下 YAML 文件示例:

    apiVersion: rbac.authorization.k8s.io/v1
    kind: RoleBinding
    metadata:
      name: prometheus-k8s-monitoring-binding
      namespace: open-cluster-management
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: Role
      name: prometheus-k8s-monitoring
    subjects:
    - kind: ServiceAccount
      name: prometheus-k8s
      namespace: monitoring
  4. 运行以下命令以应用该文件:

    oc apply -f
  5. 运行以下查询来查找 Subscription Operator Metrics Service 报告的指标,在 Prometheus 仪表板中验证:

    {service="standalone-subscription-metrics"}

法律通告

Copyright © 2024 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.