Adoptable Cookbooks List

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Grafana Cookbook

Overview

A stand-alone cookbook for Grafana. The 2.x versions of this cookbook work with the 2.x versions of Grafana. There is no backward compatibility for pre-2.0 versions of Grafana in the 2.x versions of this cookbook.

If you would like to configure pre-2.0 versions of Grafana, please use the 1.x branch and 1.x versions of this cookbook in the supermarket. There is a 1.x tag for PRs or Issues related to the 1.x branch.

This cookbook does nothing to generate the basic auth user/password file, you will have to make sure this file is created and is valid.

Usage

grafana::default

The default recipe will:

install Grafana via downloaded system package

install nginx to proxy the grafana application

If you want to install a newer version using the file installation method, set the node['grafana']['version'] attribute to the desired version and also set either node['grafana']['file']['checksum']['deb'] or node['grafana']['file']['checksum']['rpm'] to the SHA256 checksum of the package file as shown on the Grafana download page.

If you want to install the Grafana package repository, update node['grafana']['install_type'] attribute to package. Additionally, the node['grafana']['version'] can be set to 'latest' so that the very latest Grafana build is used instead of the default release.

Nginx is used to proxy Grafana to run on port 80. If you don't want this cookbook to handle the webserver config simply set node['grafana']['webserver'] to '' in a role/environment/node somewhere.

NOTE There is NO security enabled by default on any of the content being served. If you would like to modify the nginx parameters, you should:

create your own cookbook i.e. my-grafana

copy the template for the webserver you wish to use to your cookbook

modify the template as you see fit (add auth, setup ssl)

use the appropriate webserver template attributes to point to your cookbook and template

grafana::plugins

This recipe will install the plugins given with the node['grafana']['plugins'] attribute

It will use the grafana_plugin LWRP described in the section below.

Resources

It's important to note that Grafana must be running for these resources to be used because they utilize Grafana's HTTP API. In your recipe, you'll simply need to make sure that you include the default recipe that starts Grafana before using these.

grafana_datasource

You can control Grafana dataSources via the grafana_datasource LWRP. Due to the varying nature of the potential data sources, the information used to create the datasource is consumed by the resource as a Hash (the source attribute). The examples should illustrate the flexibility. The full breadth of options are (or will be) documented on the Grafana website, however you can discover undocumented parameters by inspecting the HTTP requests your browser makes to the Grafana server.

grafana_dashboard

Dashboards in Grafana are always going to be incredibly specific to the application, but you may want to be able to create a new dashboard along with a newly provisioned stack. This resource assumes you have a static json file that displays the information that will be flowing from the newly created stack.

This resource currently makes an assumption that the name used in invocation matches the name of the dashboard. This will obviously have limitations, and could change in the future. More documentation on creating Grafana dashboards via the HTTP API can be found here.

Properties

Property

Type

Default Value

Description

host

String

'localhost'

The host grafana is running on

port

Integer

3000

The port grafana is running on

admin_user

String

'admin'

A grafana user with admin privileges

admin_password

String

'admin'

The grafana user's password

dashboard

String

A Hash of the values to create the dashboard. Examples below.

action

String

create

Valid actions are create, update, and delete. Create can update the dashbord, be careful (see below for details) !

Examples

Assuming you have a files/default/simple-dashboard.json:

grafana_dashboard 'simple-dashboard'

If you'd like to use a my-dashboard.json with the title "title": "Test Dash":

You will finally be able to delete an organization (WARNING: this change is NOT supported in Grafana 2.1.3):

grafana_organization 'Second Org.' do
action :delete
end

grafana_user

This resource will allow you to create global users within Grafana. This resource is minimally viable and only supports the addition of global non-admin users. Contribution to the functionality would be appreciated.

More information about creating Grafana users via the HTTP API can be found here.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jhenry82

When using the default's file installation, we've added checksum for package files if you set the grafana version to something different than the default you will also need set the checksum for the package you're expecting to use:

# Example if your Grafana version is different from the cookbook default
node['grafana']['version'] = '2.1.0'
# For debian platform family
node['grafana']['file']['checksum']['deb'] = 'b824c8358ff07f76f0d9eb35e9441f6f9e591819ad8bc70db4b0c904a8e7130e'
# For rhel platform family
node['grafana']['file']['checksum']['rpm'] = '1b436b286bd464e65eeb2a9b393da0986569fe483e1053b01c092b2e590d8399'

1.5.3 (2014-11-15):

1.5.2 (2014-11-04):

1.5.1 (2014-10-08):

Update Grafana to 1.8.1

1.5.0 (2014-09-22):

Update Grafana to 1.8.0

warning

Check for the presence of node['grafana']['es_role'] and node['grafana']['graphite_role'] instead of node['grafana']['es_server'] and node['grafana']['graphite_server'] to know if we should search and replace default['grafana']['es_server'] and default['grafana']['graphite_server'] (Jonathon W. Marshall) #22

1.4.2 (2014-09-14):

Fix attributes doc in README

1.4.1 (2014-09-12):

Do not use template resource's helpers method to bring back older Chef compatibility.