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

updates for grafana 6.6.x #2

Open
wants to merge 4 commits 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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
67 changes: 67 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
ARG GRAFANA_VERSION="latest"

FROM grafana/grafana:${GRAFANA_VERSION}-ubuntu

USER root

# Set DEBIAN_FRONTEND=noninteractive in environment at build-time
ARG DEBIAN_FRONTEND=noninteractive

ARG GF_INSTALL_IMAGE_RENDERER_PLUGIN="true"

RUN if [ $GF_INSTALL_IMAGE_RENDERER_PLUGIN = "true" ]; then \
apt-get update && \
apt-get upgrade -y && \
apt-get install -y chromium-browser && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /usr/share/grafana/tools/phantomjs; \
fi

USER grafana

ENV GF_RENDERER_PLUGIN_CHROME_BIN="/usr/bin/chromium-browser"

RUN if [ $GF_INSTALL_IMAGE_RENDERER_PLUGIN = "true" ]; then \
grafana-cli \
--pluginsDir "$GF_PATHS_PLUGINS" \
--pluginUrl https://github.com/grafana/grafana-image-renderer/releases/latest/download/plugin-linux-x64-glibc-no-chromium.zip \
plugins install grafana-image-renderer; \
fi

ARG GF_INSTALL_PLUGINS="grafana-clock-panel,grafana-simple-json-datasource"

RUN if [ ! -z "${GF_INSTALL_PLUGINS}" ]; then \
OLDIFS=$IFS; \
IFS=','; \
for plugin in ${GF_INSTALL_PLUGINS}; do \
IFS=$OLDIFS; \
grafana-cli --pluginsDir "$GF_PATHS_PLUGINS" plugins install ${plugin}; \
done; \
fi


# chown database folder to the grafana user to be able to mount a named volume to it
RUN mkdir -p "/var/lib/grafana/database" && \
chown -R grafana:grafana "/var/lib/grafana/database"

USER grafana

COPY dist $GF_PATHS_PLUGINS/kairosdb-datasource

# add provisioning information
# ADD ./docker/provisioning /etc/grafana/provisioning
# ADD ./dashboards $GF_PATHS_DATA/dashboards

# override configuration with env variables
ENV GF_SECURITY_ADMIN_PASSWORD=kairosdb
#ENV GF_USERS_DEFAULT_THEME=light
ENV GF_SERVER_ENABLE_GZIP=true

# set up tls by default
#ENV GF_SERVER_PROTOCOL=https
#ENV GF_SERVER_CERT_FILE=$GF_PATHS_HOME/.tls/grafana.crt
#ENV GF_SERVER_CERT_KEY=$GF_PATHS_HOME/.tls/grafana.key

# move Grafana database to a separate path to enable specifying a persistent volume just for the db
ENV GF_DATABASE_PATH="database/grafana.db"
80 changes: 48 additions & 32 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
all: frontend backend

frontend:
grunt
npm install
./node_modules/.bin/grunt

backend:
go build -o ./dist/grafana-kairosdb-datasource_darwin_amd64 ./pkg
env GOOS=darwin GOARCH=amd64 go build -o ./dist/grafana-kairosdb-datasource_darwin_amd64 ./pkg
env GOOS=linux GOARCH=amd64 go build -o ./dist/grafana-kairosdb-datasource_linux_amd64 ./pkg

docker:
docker build -t grafana-kairosdb -f Dockerfile .

clean:
rm -r ./dist/*
61 changes: 35 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,58 @@
Starting in Grafana 3.x the KairosDB data source is no longer included out of the box.

But it is easy to install this plugin!
Starting in Grafana 3.x the KairosDB data source is no longer included out of the box and is maintained here (currently tested against Grafana v6.6.0).

## Overview
This plugin consists of two components: a frontend and a backend
This [data source](https://grafana.com/docs/grafana/latest/plugins/developing/datasources/) plugin consists of two components: a frontend and a backend.

The backend plugin provides support for [alerts](https://grafana.com/docs/alerting/rules), but is not required to use the frontend browser-based KairosDB connectivity.

The backend plugin provides support for [alerts](https://grafana.com/docs/alerting/rules), but is not required to use the frontend portion.
## Install to Grafana plugins directory

## Installation
### Install to plugins directory
Copy the plugin distribution directory (`./dist`) to the correctly named plugin directory as a child of the grafana plugins directory (eg `cp ./dist /var/lib/grafana/plugins/kairosdb-datasource`). This enables the frontend plugin and backend datasource proxy (enabled by configuring a KairosDB Datasource as "Access: Server"). The pre-compiled backend plugin supports linux-amd64 and macos (darwin-amd64). If you are running grafana on a different architecture you will need to compile the backend go project yourself.

If you only need the frontend component you may clone the project directly into your Grafana plugin directory
(defaults to /var/lib/grafana/plugins if you're installing grafana with package).
## Build
### Frontend

If building only the front end, the plugin can be cloned anywhere and built:

Then simply compile the code and restart Grafana:
```
git clone https://github.com/grafana/kairosdb-datasource
cd kairosdb-datasource
npm install
make frontend
sudo service grafana-server restart
```

### Install with Alerts
If you wish to build the backend plugin, as well, your project must be setup within a [Go workspace](https://golang.org/doc/code.html#Workspaces).
The `./dist` directory can then be copied to your Grafana plugins directory:

```
cp /dist /var/lib/grafana/plugins/kairosdb-datasource
```

The alerting functionality will not be available without deploying the backend compiled binary.

### Backend (Alerts)

If you wish to build the backend plugin for your environment, your project must be setup within a [Go workspace](https://golang.org/doc/code.html#Workspaces).

Ensure your GOPATH environment variable points to your workspace:

```
export GOPATH=$HOME/go
cd $GOPATH/src/github.com/grafana
git clone https://github.com/grafana/kairosdb-datasource
cd $GOPATH/src/github.com/kairosdb
git clone https://github.com/kairosdb/kairosdb-datasource
cd kairosdb-datasource
# vendor dependencies are managed via "dep ensure"
make backend
```

This will attempt to build both the linux and macos binaries. The `./dist` directory can then be copied to your Grafana plugins directory:

Edit your grafana.ini config file (Default location is at /etc/grafana/grafana.ini) to include the path to your clone.
Be aware that grafana-server needs read access to the project directory.

```ini
[plugin.kairosdb]
path = $GOPATH/src/github.com/grafana/kairosdb-datasource
```
cp /dist /var/lib/grafana/plugins/kairosdb-datasource
```
## Docker

Then compile the code and restart Grafana:
A custom grafana image can built which includes the kairosdb plugin. After the above build steps have been completed:
```
npm install
make
sudo service grafana-server restart
make docker
docker run -d -p 3000:3000 --name=grafana grafana-kairosdb:latest
```
The default login is admin:kairosdb. There are several build options that can be overridden. The base image was taken from [building-a-custom-grafana-image](https://grafana.com/docs/grafana/latest/installation/docker/#building-a-custom-grafana-image).
Loading