Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce custom Grafana for openshift prometheus. #17037

Merged
merged 1 commit into from
Dec 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions examples/grafana/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# grafana-ocp

This template creates a custom Grafana instance preconfigured to gather Prometheus openshift metrics.
It is uses OAuth token to login openshift Prometheus.


## To deploy grafana
Note: make sure to have openshift prometheus deployed.
(https://github.com/openshift/origin/tree/master/examples/prometheus)

1. ```oc create namespace grafana```
2. ```oc new-app -f grafana-ocp.yaml```
3. grab the grafana url ``` oc get route |awk 'NR==2 {print $2}' ```
4. grab the ocp token, from openshift master run: ```oc sa get-token prometheus -n kube-system```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smarterclayton hi, do you have preference on how to get a token for the Prometheus auth proxy ?

Here we assume the namespace is kube-system, but if we install Prometheus using openshift-ansible [1] the namespace will be prometheus.

[1] https://github.com/openshift/openshift-ansible/blob/master/roles/openshift_prometheus/defaults/main.yaml#L5

cc @zgalor @cben @joelddiaz

Copy link
Author

@mrsiano mrsiano Oct 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yaacov
I've started to work on another patch, to automate the deployment process.

I use this command,
oc get route --all-namespaces |grep -i prometheus |awk '{print $3}'

let's merge this patch for initial stage, then lets work on other things like https, automation and so.
@smarterclayton

5. browse to grafana datasource's and add new prometheus datasource.
6. grab the prometheus url via ```oc get route -n kube-system prometheus |awk 'NR==2 {print $2}'``` and paste the prometheus url e.g https://prometheus-kube-system.apps.example.com
7. paste the token string at the token field.
8. checkout the TLS checkbox.
9. save & test and make sure all green.

### Pull standalone docker grafana instance
to build standalone docker instance see
https://github.com/mrsiano/grafana-ocp

#### Resources
- example video https://youtu.be/srCApR_J3Os
- deploy openshift prometheus https://github.com/openshift/origin/tree/master/examples/prometheus
76 changes: 76 additions & 0 deletions examples/grafana/grafana-ocp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
kind: Template
apiVersion: v1
metadata:
name: grafana-ocp
annotations:
"openshift.io/display-name": Grafana ocp
description: |
Grafana server with patched Prometheus datasource.
iconClass: icon-cogs
tags: "metrics,monitoring,grafana,prometheus"
parameters:
- description: External URL for the grafana route
name: ROUTE_URL
value: ""
- description: The namespace to instantiate heapster under. Defaults to 'grafana'.
name: NAMESPACE
value: grafana
objects:
- apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: grafana-ocp
namespace: "${NAMESPACE}"
spec:
host: "${ROUTE_URL}"
to:
name: grafana-ocp
- apiVersion: v1
kind: Service
metadata:
name: grafana-ocp
namespace: "${NAMESPACE}"
labels:
metrics-infra: grafana-ocp
name: grafana-ocp
spec:
selector:
name: grafana-ocp
ports:
- port: 8082
protocol: TCP
targetPort: grafana-http
- apiVersion: v1
kind: ReplicationController
metadata:
name: grafana-ocp
namespace: "${NAMESPACE}"
labels:
metrics-infra: grafana-ocp
name: grafana-ocp
spec:
selector:
name: grafana-ocp
replicas: 1
template:
version: v1
metadata:
labels:
metrics-infra: grafana-ocp
name: grafana-ocp
spec:
volumes:
- name: data
emptyDir: {}
containers:
- image: "mrsiano/grafana-ocp:latest"
name: grafana-ocp
ports:
- name: grafana-http
containerPort: 3000
volumeMounts:
- name: data
mountPath: "/root/go/src/github.com/grafana/grafana/data"
command:
- "./bin/grafana-server"