Clone the Grafana Operator
git clone https://github.com/integr8ly/grafana-operator.gitCreate namespace and apply some manifest
oc create namespace grafana
oc project grafana
cd grafana-operator
oc create -f deploy/crds
oc create -f deploy/roles
oc create -f deploy/cluster_roles
oc create -f deploy/operator.yaml
Create Service Account to allow Grafana get metrics from prometheus
oc create sa prometheus-reader
oc adm policy add-cluster-role-to-user view -z prometheus-readerGet prometheus-reader Service Account's Token
oc serviceaccounts get-token prometheus-readerCreate manifest for example datasource.yaml
apiVersion: integreatly.org/v1alpha1
kind: GrafanaDataSource
metadata:
name: grafanadatasource-prometheus
namespace: grafana
spec:
name: grafanadatasource-prometheus.yaml
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: "https://prometheus-k8s-openshift-monitoring.apps.openshift.podX.io"
basicAuth: false
withCredentials: false
isDefault: true
version: 1
editable: true
jsonData:
tlsSkipVerify: true
timeInterval: "5s"
httpHeaderName1: "Authorization"
secureJsonData:
httpHeaderValue1: "Bearer ${TOKEN}"Create object from the manifest
oc create -f datasource.yamlCreate manifest grafana for example grafana-deploy.yaml
apiVersion: integreatly.org/v1alpha1
kind: Grafana
metadata:
name: grafana
namespace: grafana
spec:
ingress:
enabled: True
config:
log:
mode: "console"
level: "debug"
security:
admin_user: "root"
admin_password: "secret"
auth:
disable_login_form: False
disable_signout_menu: True
auth.anonymous:
enabled: False
dashboardLabelSelector:
- matchExpressions:
- {key: app, operator: In, values: [grafana]}Create object from the manifest
oc create -f grafana-deploy.yamlWait the deployment to finish
oc get pods -wGet the route
oc get route- Grafana > Configuration > Datasource > Add "data source"
HTTP > URL > fill with URL HOST/PORT from oc -n openshift-monitoring get route the thanos-querier one.
Auth > Activate "Skip TLS Verify"
Custom HTTP Headers > + Add header
Header: Authorization
Value: Bearer ${TOKEN}
- Save & Exit