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

grafana for prometheus #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
39 changes: 39 additions & 0 deletions add-ons/grafana-prometheus/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Grafana Add-on

This addon installs grafana for metrics visualization from prometheus

## Prerequisites

The prometheus addon is required
Copy link
Member

Choose a reason for hiding this comment

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

It is a good practice to tell how much RAM and CPU needs to be allocated to Minishift for this to run smoothly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

grafana requires very little memory and cpu. it's merely to display data from its configured backend
see here


```
minishift addon install prometheus-3.7
minishift addon apply prometheus-3.7 --addon-env namespace=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.

This command is wrong as it should be minishift addon install grafana-prometheus. We need to pass the directory name to the addon install command.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's about installing the pre-requisite prometheus - not the grafana addon

```

## Deploy grafana

To deploy grafana do:

```
minishift addon apply grafana --addon-env namespace=grafana
Copy link

Choose a reason for hiding this comment

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

Looks like not must be 'grafana_namespace' instead of 'namespace' and 'grafana-prometheus' instead of '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
Copy link

Choose a reason for hiding this comment

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

It's nice to have grafana-prometheus.addon.remove file also

```
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