9.3. Grafana データソースの作成

Grafana ダッシュボードで Data Grid メトリクスを視覚化できるように GrafanaDatasource CR を作成します。

前提条件

  • oc クライアントがある。
  • OpenShift Container Platform への cluster-admin アクセスがあること。
  • OpenShift Container Platform で、ユーザー定義プロジェクトのモニターリングを有効にします。
  • alpha チャネルから Grafana Operator をインストールし、Grafana CR を作成します。

手順

  1. Grafana が Prometheus から Data Grid メトリクスを読み取りできるようにする ServiceAccount を作成します。

    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: infinispan-monitoring
    1. ServiceAccount を適用します。

      $ oc apply -f service-account.yaml
    2. cluster-monitoring-view パーミッションを ServiceAccount に付与します。

      $ 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

次のステップ

Grafana ダッシュボードを Data Grid Operator 設定プロパティーで有効にします。