9.3. 创建 Grafana 数据源


创建 GrafanaDatasource CR,以便在 Grafana 仪表板中视觉化数据网格指标。

先决条件

  • 有一个 oc 客户端。
  • 具有 cluster-admin 对 OpenShift Container Platform 的访问权限。
  • 在 OpenShift Container Platform 上为用户定义的项目启用监控。
  • alpha 频道安装 Grafana Operator,并创建一个 Grafana CR。

流程

  1. 创建一个 ServiceAccount,允许 Grafana 从 Prometheus 读取 Data Grid 指标。

    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: infinispan-monitoring
    1. 应用 ServiceAccount

      $ oc apply -f service-account.yaml
    2. ServiceAccount 授予 cluster-monitoring-view 权限。

      $ oc adm policy add-cluster-role-to-user cluster-monitoring-view -z infinispan-monitoring
  2. 创建 Grafana 数据源。

    1. 检索 ServiceAccount 的令牌。

      $ oc serviceaccounts get-token infinispan-monitoring
      
      eyJhbGciOiJSUzI1NiIsImtpZCI6Imc4O...
    2. spec.datasources.secureJsonData.httpHeaderValue1 字段中定义包含令牌的 GrafanaDataSource,如下例所示:

      apiVersion: integreatly.org/v1alpha1
      kind: GrafanaDataSource
      metadata:
        name: grafanadatasource
      spec:
        name: datasource.yaml
        datasources:
          - access: proxy
            editable: true
            isDefault: true
            jsonData:
              httpHeaderName1: Authorization
              timeInterval: 5s
              tlsSkipVerify: true
            name: Prometheus
            secureJsonData:
              httpHeaderValue1: >-
                Bearer
                eyJhbGciOiJSUzI1NiIsImtpZCI6Imc4O...
            type: prometheus
            url: 'https://thanos-querier.openshift-monitoring.svc.cluster.local:9091'
  3. 应用 GrafanaDataSource

    $ oc apply -f grafana-datasource.yaml

后续步骤

使用 Data Grid Operator 配置属性启用 Grafana 仪表板。

Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2026 Red Hat
返回顶部