Skip to content

Commit

Permalink
Issue #52 grafana for prometheus
Browse files Browse the repository at this point in the history
grafana for prometheus based on https://github.com/mrsiano/grafana-ocp
  • Loading branch information
durandom committed Nov 24, 2017
1 parent 0984944 commit 7a5ee10
Show file tree
Hide file tree
Showing 5 changed files with 5,229 additions and 0 deletions.
40 changes: 40 additions & 0 deletions add-ons/grafana-prometheus/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

# Grafana Add-on

This addon installs grafana for metrics visualization from prometheus

## Prerequisites

The prometheus addon is required

```
minishift addon install prometheus-3.7
minishift addon apply prometheus-3.7 --addon-env namespace=kube-system
```

## Deploy grafana

To deploy grafana do:

```
minishift addon apply grafana --addon-env namespace=grafana
~/.minishift/addons/grafana-prometheus/setup-grafana.sh grafana
```

_NOTE_: namespace is a required environment variable for the add-on to run. Refer [addon-dynamic-variables](https://docs.openshift.org/latest/minishift/using/addons.html#addon-dynamic-variables) documentation.

## Use grafana
grafana will be available at:

```
minishift openshift service grafana-ocp -n grafana
```

After connecting to grafana, you should log as user: admin, password: admin

## Delete grafana
Delete grafana with:

```
oc delete project -n grafana --as=system:admin
```
76 changes: 76 additions & 0 deletions add-ons/grafana-prometheus/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"
16 changes: 16 additions & 0 deletions add-ons/grafana-prometheus/grafana-prometheus.addon
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Name: grafana-prometheus
# Description: This template adds grafana for displaying Openshift Metrics in its own namespace. If requires metrics and management-infra addon, to connect to hawkular-metrics on openshift.
# Url: https://github.com/mrsiano/grafana-ocp
# OpenShift-Version: >=3.7.0
# Required-Vars: grafana_namespace

# TODO: Once conditional commands are there, create the namespace if it does not exist
oc adm new-project #{grafana_namespace}
oc new-app -f grafana-ocp.yaml -n #{grafana_namespace}

echo You have installed #{addon-name}
echo To finish install run:
echo ~/.minishift/addons/grafana-prometheus/setup-grafana.sh #{grafana_namespace}
echo
echo To delete:
echo oc delete project -n #{grafana_namespace} --as=system:admin
Loading

0 comments on commit 7a5ee10

Please sign in to comment.