File README.md of Package grafana-container
# What's inside
This container provide grafana toolstack inside a container.
* '''Dockerfile''' with the definition of the grafana container
* It installs grafana wget and some additional tools
* Use the '''entrypoint.sh''' as ENTRYPOINT for the container (will be use at start of the container)
* '''graphana-container.conf''' file for which contains all VAR
* '''graphana-functions''' functions to check configuration
* '''grafana-container-manage.sh''' script to manage the container using podman
* it uses network host to be able to access VM network
# Usage of the the manage script
```./grafana-container-manage.sh
Found local version of grafana-functions
using /root/home:aginies:containers/graphana/grafana-container.conf as configuration file
First ARG is mandatory:
./grafana-container-manage.sh [create|start|stop|rm|rmcache|run|bash|logs|install|uninstall]
CONTAINER_NAME: 'grafana'
DEPLOYMENT:
create
Pull the image and create the container automatically
install
install needed files on the host to manage 'grafana' container
(in /usr/local/bin and /etc)
start
Start the container 'grafana'
REMOVAL:
uninstall
uninstall all needed files on the host to manage 'grafana' container
stop
stop the container 'grafana'
rm
delete the container 'grafana'
rmcache
remove the container image in cache
DEBUG:
run
podman run container 'grafana'
bash
go with bash command inside 'grafana'
logs
see log of container 'grafana'
```
# How to get a working grafana container
## Prepare your host system
To be able to use grafana, just use the '''runlabel install''' on the container image available on the registry.
```
# podman container runlabel install registry.opensuse.org/suse/alp/workloads/tumbleweed_containerfiles/suse/alp/workloads/grafana:latest
Trying to pull registry.opensuse.org/suse/alp/workloads/tumbleweed_containerfiles/suse/alp/workloads/grafana:latest...
Getting image source signatures
Copying blob 516d2ff9c231 done
Copying blob 01d99e9cadaf done
Copying config 2698f55e87 done
Writing manifest to image destination
Storing signatures
LABEL INSTALL
copy /container/grafana-container-manage.sh in /host/usr/local/bin/
'/container/grafana-container-manage.sh' -> '/host/usr/local/bin/grafana-container-manage.sh'
copy /container/grafana-container.conf in /host/etc/
'/container/grafana-container.conf' -> '/host/etc/grafana-container.conf'
copy /container/grafana-functions in /host/etc/
'/container/grafana-functions' -> '/host/etc/grafana-functions'
```
## Create the container
```grafana-container-manage.sh create
Found local version of grafana-functions
using /etc/grafana-container.conf as configuration file
+ case $1 in
+ create_container
+ podman create --name grafana --tls-verify=false --network host registry.opensuse.org/suse/alp/workloads/tumbleweed_containerfiles/suse/alp/workloads/grafana:latest
```
## Start the container with grafana-server
```
grafana-container-manage start
using /etc/grafana-container.conf as configuration file
+ case $1 in
+ podman start grafana
grafana
+ podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b0580df381b0 registry.suse.de/home/aginies/containers/containers153/grafana/grafana-container:latest 3 seconds ago Up Less than a second ago grafana
```
The grafana server is started and ready, now we need a client to get some data.
## Inside client
Go inside the client (bare metal or VM) and install golang-github-prometheus-node_exporter golang-github-prometheus-prometheus.
if you are using containerized virtualization stack you must use --network option while creating the pod (--publish doesn't work in this scenario). To get the IP on the VM on the host server just do a:
```
virsh net-dhcp-leases default```
```
zypper in golang-github-prometheus-node_exporter golang-github-prometheus-prometheus
# start the service inside the VM:
```
systemctl restart prometheus-node_exporter.service
systemctl restart prometheus
```
## Grafana webpage
Follow this step by step, as this is not possible to automate this part.
* go to firefox http://localhost:3000
* login with admin / admin
* Add Prometheus:
** On the left panel, select the gear icon and click Data Sources.
** Click Add data source.
** Find Prometheus and click Select.
** In the URL field, enter http://IP_OF_THE_VM:9090
## Workload
* In the Import via the grafana page, click on the "+", then import, enter the dashboard ID 405, then click Load.
* Select a Prometheus data source drop-down box
* Save, go back to dashboard to see the graphs
# Uninstall needed files to manage the container
To remove management files from the host:
```
# grafana-container-manage uninstall
Found local version of grafana-functions
using /root/home:aginies:branches:SUSE:ALP:Workloads/grafana-container/grafana-container.conf as configuration file
+ case $1 in
+ podman run --env IMAGE=registry.opensuse.org/suse/alp/workloads/tumbleweed_containerfiles/suse/alp/workloads/grafana:latest --rm --privileged -v /:/host registry.opensuse.org/suse/alp/workloads/tumbleweed_containerfiles/suse/alp/workloads/grafana:latest /bin/bash /container/label-uninstall
LABEL UNINSTALL: Removing all files
removed '/host/etc/grafana-container.conf'
removed '/host/etc/grafana-container-functions'
removed '/host/usr/local/bin/grafana-container-manage.sh'
```