3.6.4. Prometheus と Grafana を使用した OpenShift Dev Spaces のモニタリング
クラスター上で実行中の Prometheus および Grafana のインスタンスを使用して、OpenShift Dev Spaces メトリクスを収集および表示できます。
3.6.4.1. Prometheus と Grafana のインストール
Prometheus と Grafana の両方のデプロイとサービスで構成される template.yaml を適用することで、Prometheus と Grafana をインストールできます。
または、Prometheus Operator と Grafana Operator を使用することもできます。
前提条件
- oc
手順
template.yaml を使用して Prometheus と Grafana をインストールするには、以下を実行します。
-
oc apply -f template.yamlを実行して、template.yamlをクラスターに適用します。
例3.30 template.yaml
---
apiVersion: v1
kind: Service
metadata:
name: grafana
labels:
app: grafana
spec:
ports:
- name: 3000-tcp
port: 3000
protocol: TCP
targetPort: 3000
selector:
app: grafana
---
apiVersion: v1
kind: Service
metadata:
name: prometheus
labels:
app: prometheus
spec:
ports:
- name: 9090-tcp
port: 9090
protocol: TCP
targetPort: 9090
selector:
app: prometheus
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: grafana
name: grafana
spec:
selector:
matchLabels:
app: grafana
template:
metadata:
labels:
app: grafana
spec:
containers:
- image: registry.redhat.io/rhel8/grafana:7
name: grafana
ports:
- containerPort: 3000
protocol: TCP
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: prometheus
name: prometheus
spec:
selector:
matchLabels:
app: prometheus
template:
metadata:
labels:
app: prometheus
spec:
containers:
- image: quay.io/prometheus/prometheus:v2.36.0
name: prometheus
ports:
- containerPort: 9090
protocol: TCP
volumeMounts:
- mountPath: /prometheus
name: volume-data
- mountPath: /etc/prometheus/prometheus.yml
name: volume-config
subPath: prometheus.yml
volumes:
- emptyDir: {}
name: volume-data
- configMap:
defaultMode: 420
name: prometheus-config
name: volume-config
---
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus-config
data:
prometheus.yml: |
---