-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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``` | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 beprometheus
.[1] https://github.com/openshift/openshift-ansible/blob/master/roles/openshift_prometheus/defaults/main.yaml#L5
cc @zgalor @cben @joelddiaz
There was a problem hiding this comment.
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