grafana-service

command module
v0.0.0-...-4e41b90 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

README

Grafana Service

GitHub release (latest by date) Go Report Card

Example of a dashboard automatically generated by the Keptn Grafana Service. example

Please note this repository has been created by using the Keptn Service Template.

The Keptn Grafana Service listens for sh.keptn.event.monitoring.configure events and automatically generates

  • Keptn dashboard with
    • RED metrics for each stage that is defined in the shipyard file of Keptn

Trigger the generation by executing e.g., keptn conifugure monitoring prometheus --project=sockshop --service=carts

Installation

The grafana-service can be installed as a part of Keptn's uniform.

Configure Grafana environment & token

Open the deploy/service.yaml file and edit the environment variables accordingly to your environment.

env:
  - name: EVENTBROKER 
    value: 'http://event-broker.keptn.svc.cluster.local/keptn' # usually NO edit needed
  - name: CONFIGURATION_SERVICE
    value: 'http://configuration-service.keptn.svc.cluster.local:8080' # usually NO edit needed
  - name: GRAFANA_URL
    value: http://yourgrafana-url # change to your grafana URL
  - name: GRAFANA_TOKEN
    value: yourtoken # add your Grafana token here
  - name: PROMETHEUS_URL
    value: http://yourprometheus-url # add your Prometheus URL here for grafana to fetch the data
Deploy in your Kubernetes cluster

To deploy the current version of the grafana-service in your Keptn Kubernetes cluster, apply the deploy/service.yaml file:

kubectl apply -f deploy/service.yaml

This should install the grafana-service together with a Keptn distributor into the keptn namespace, which you can verify using

kubectl -n keptn get deployment grafana-service -o wide
kubectl -n keptn get pods -l run=grafana-service
Up- or Downgrading

Adapt and use the following command in case you want to up- or downgrade your installed version (specified by the $VERSION placeholder):

kubectl -n keptn set image deployment/grafana-service grafana-service=keptnsandbox/grafana-service:$VERSION --record
Uninstall

To delete a deployed grafana-service, use the file deploy/*.yaml files from this repository and delete the Kubernetes resources:

kubectl delete -f deploy/service.yaml

Deploy Grafana

If you don't have Grafana up-and-running yet, you can use the manifests in the manifests/ folder that will help you deploying Grafana on your cluster in the monitoring namespace.

kubectl create namespace monitoring
kubectl apply -f manifests/.

Compatibility Matrix

Keptn Version grafana-service Docker Image
0.6.2 keptnsandbox/grafana-service:0.1.0

Development

Development can be conducted using any GoLang compatible IDE/editor (e.g., Jetbrains GoLand, VSCode with Go plugins).

It is recommended to make use of branches as follows:

  • master contains the latest potentially unstable version
  • release-* contains a stable version of the service (e.g., release-0.1.0 contains version 0.1.0)
  • create a new branch for any changes that you are working on, e.g., feature/my-cool-stuff or bug/overflow
  • once ready, create a pull request from that branch back to the master branch

When writing code, it is recommended to follow the coding style suggested by the Golang community.

You might want to port-forward you configuration service during local development to be able to directly communite with it:

kubectl port-forward svc/configuration-service -n keptn 9090:8080

Copy the file env to myenv and add your environment variables to test it locally with:

./local-build.sh && ./local-run.sh

If you happen to edit the keptn.jsonnet file you might want to give it a try locally first before you run it in the context of the Grafana Service. You can do so by executing the following. This will generate a new file in the folder gen/ called keptn.json which contains the generates dashboard template which you can inspect.

jsonnet -J ./grafonnet-lib-local/ --ext-code stages='["dev","staging"]' --ext-str service=carts --ext-str project=sockshop keptn.jsonnet > gen/keptn.json

jsonnet -J ./grafonnet-lib/ --ext-code stages="['dev']" --ext-str service="carts" --ext-str project="sockshop" keptn.jsonnet

Where to start

If you don't care about the details, your first entrypoint is eventhandlers.go. Within this file you can add implementation for pre-defined Keptn Cloud events.

To better understand Keptn CloudEvents, please look at the Keptn Spec.

If you want to get more insights, please look into main.go, deploy/service.yaml, consult the Keptn docs as well as existing Keptn Core and Keptn Contrib services.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL