Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

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.

Select Badges

Select Supported Platforms

Select Status

RSS

grafana (110) Versions 2.1.2

Installs/Configures Grafana Server

Policyfile
Berkshelf
Knife
cookbook 'grafana', '= 2.1.2', :supermarket
cookbook 'grafana', '= 2.1.2'
knife supermarket install grafana
knife supermarket download grafana
README
Dependencies
Changelog
Quality 100%

Grafana Cookbook Build Status

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.

Requirements

  • apt
  • yum
  • nginx

Attributes

As with most cookbooks, this one is hopefully flexible enough to be wrapped by allowing you to override as much as possible. Please let us know if you find a value that is not configurable.

grafana::default

Attribute Default Description
node['grafana']['install_type'] 'file' The type of install: file, package or source. Note: source is not currently supported.
node['grafana']['version'] '2.1.2' The version to install. For the most recent versions use 'latest'.
node['grafana']['file']['url'] 'https://grafanarel.s3.amazonaws.com/builds/grafana' The file URL for Grafana builds
node['grafana']['file']['checksum']['deb'] '57f52cc8e510f395f7f15caac841dc31e67527072fcbf5cc2d8351404989b298' The SHA256 checksum of Grafana .deb file
node['grafana']['file']['checksum']['rpm'] '618f5361e594b101a4832a67a9d82f1179c35ff158ef4288dc1f8b6e8de67bb8' The SHA256 checksum of Grafana .rpm file
node['grafana']['package']['repo'] 'https://packagecloud.io/grafana/stable/' The grafana package repo
node['grafana']['package']['key'] 'https://packagecloud.io/gpg.key' The package repo GPG key
node['grafana']['package']['components'] ['main'] The package repo components
node['grafana']['user'] 'grafana' The grafana user
node['grafana']['group'] 'grafana' The grafana group
node['grafana']['home'] '/usr/share/grafana' The value set to GRAFANA_HOME
node['grafana']['data_dir'] '/var/lib/grafana' The path grafana can use to store temp files, sessions, and the sqlite3 db
node['grafana']['log_dir'] '/var/log/grafana' Grafana's log directory
node['grafana']['env_dir'] '/etc/default' or '/etc/sysconfig' The location for environment variables - autoconfigured for rhel and debian systems
node['grafana']['conf_dir'] '/etc/grafana' The location to store the grafana.ini file
node['grafana']['webserver'] 'nginx' Which webserver to use: 'nginx' or ''
node['grafana']['webserver_hostname'] node.name The server_name used in the webserver config
node['grafana']['webserver_aliases'] [node['ipaddress']] Array of any secondary hostnames that are valid vhosts
node['grafana']['webserver_listen'] node['ipaddress'] The ip address the web server will listen on
node['grafana']['webserver_port'] 80 The port the webserver will listen on
grafana.ini

For the ini configuration file, parameters can be specified as this: node['grafana']['ini'][SECTION_NAME][KEY] = [VALUE]. Here's an example:

default['grafana']['ini']['server']['protocol'] = 'http'

It is also possible to specify a comment that will precede the parameter and to comment the parameter as well.

default['grafana']['ini']['database']['ssl_mode'] = {
  comment: 'For "postgres" only, either "disable", "require" or "verify-full"',
  disable: true,
  value: 'disable'
}

See attributes/default.rb file for more details and examples.

grafana::nginx

Attribute Default Description
node['grafana']['nginx']['template'] 'grafana-nginx.conf.erb' The template file to use for the nginx site configuration
node['grafana']['nginx']['template_cookbook'] 'grafana' The cookbook containing said template

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

Resources

It's important to note that Grafana must be running for these resources to be used because they utilitze 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 potental 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.

Attributes

Attribute Type Default Value Description
host String 'localhost' The host grafana is running on
port Integer 3000 The port grafana is running on
user String 'admin' A grafana user with admin privileges
password String 'admin' The grafana user's password
source_name String The Data Source name as it will appear in Grafana. Defaults to the name unsed in the resource invocation.
source Hash {} A Hash of the values to create the datasource. Examples below.
action String create Valid actions are create, create_if_missing, and delete. Create will update the datasource if it already exists.

Examples

You can create a data source for Graphite as follows:

grafana_datasource 'graphite-test' do
  source(
    type: 'graphite',
    url: 'http://10.0.0.15:8080',
    access: 'direct'
  )
end

You can create a data source for InfluxDB 0.8.x and make it the default dashboard as follows:

grafana_datasource 'influxdb-test' do
  source(
    type: 'influxdb_08',
    url: 'http://10.0.0.10:8086',
    access: 'proxy',
    database: 'metrics',
    user: 'dashboard',
    password: 'dashpass',
    isdefault: true
  )
  action :create_if_missing
end

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.

Attributes

Attribute Type Default Value Description
host String 'localhost' The host grafana is running on
port Integer 3000 The port grafana is running on
user String 'admin' A grafana user with admin privileges
password String 'admin' The grafana user's password
source_name String The extensionless name of the dashboard json file, and should match the dashboard title in the json (lower-cased and with hyphens for spaces) if source is not provided. Defaults to the name used in the resource invocation.
source String nil If you would like to override the name of the json file, use this attribute.
cookbook String nil The cookbook name to pull the file from if not this one
path String nil Overrides cookbook and source. The absolute path to the json file on disk.
overwrite boolean true Whether you want to overwrite existing dashboard with newer version or with same dashboard title
action String create_if_missing Valid actions are create, create_if_missing, and delete. Create will update the dashboard, so be careful!

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":

grafana_dashboard 'test-dash' do
  source 'my-dashboard'
  overwrite false
end

If the dashboard you would like to import is already on disk with the title "title": "On Disk Dash":

grafana_dashboard 'on-disk-dash' do
  path '/opt/grafana/dashboards/local-dash.json'
end

grafana_organization

This resource will allow you to create organizations within Grafana. This resource is minimally viable and only supports the addition of a new organization by name. It does check to see if an organization of the same name already exists, but it does not currently support adding address or city information.

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

Attributes

Attribute Type Default Value Description
host String 'localhost' The host grafana is running on
port Integer 3000 The port grafana is running on
user String 'admin' A grafana user with admin privileges
password String 'admin' The grafana user's password
name String The name of the organization you would like to add. Defaults to the name used in the resource invocation.
action String create_if_missing Valid actions are create_if_missing. Delete and create are not currently supported.

Examples

Assuming you would like to create a new organization called Second Org.:

grafana_organization 'Second Org.'

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 funcationality would be appreciated.

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

Attributes

Attribute Type Default Value Description
host String 'localhost' The host grafana is running on
port Integer 3000 The port grafana is running on
user String 'admin' A grafana user with admin privileges
password String 'admin' The grafana user's password
global boolean true Whether you want the user to be a global user. Currently only global true is supported.
admin boolean false Whether or not the user should be a global admin. Currently only admin false is supported.
login String The login for this user. Defaults to the name used in the resource invocation.
full_name String The common, human-readable name used for the user
email String The email address for this user
passwd String The password to use for this user
action String create_if_missing Valid actions are create_if_missing. Delete and create are not currently supported.

Examples

Assuming you would like to create a new user...

grafana_user 'person2' do
  full_name 'John Smith'
  email 'test@example.com'
  passwd 'test123'
end

Testing

Foodcritic & Rubocop

$ bundle exec foodcritic -X spec -f any ./
$ bundle exec rubocop

ChefSpec

$ bundle exec rspec

kitchen-test

Requires Vagrant >= 1.7.

$ bundle install
$ bundle exec kitchen test

Contributing

  • Fork the repository on Github
  • Create a named feature branch (like add_component_x)
  • Write your change
  • Write tests for your change (if applicable)
  • Run the tests, ensuring they all pass -- bundle exec strainer test
  • Submit a Pull Request using Github

License and Authors

Primary authors:

Contributors:

  • Grégoire Seux (@kamaradclimber)
  • Anatoliy D. (@anatolijd)
  • Greg Fitzgerald (@gregf)
  • Fred Hatfull (@fhats)
  • Tim Smith (@tas50)
  • Jonathon W. Marshall (@jwmarshall)
  • Andrew Goktepe (@andrewgoktepe)
  • Miguel Landaeta (@nomadium)
  • Bernhard Köhler (@drywheat)
  • Olivier Bazoud (@obazoud)
  • @osigida
  • @BackSlasher
  • Helio Campos Mello de Andrade (@HelioCampos)
  • Arif Akram Khan (@arifcse019)

Based on chef-kibana cookbook by:

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.

CHANGELOG for grafana

This file is used to list changes made in each version of grafana.

2.1.1 (2015-08-20):

  • Update Grafana default version to 2.1.2
  • Ensure we're displaying better messages in some edge cases with HTTP requests #76

2.1.0 (2015-08-17):

  • Update Grafana default version to 2.1.1
  • Make sure upgrading via deb file don't fail on configuration conflict #74
  • Ensure installing a new version trigger a server restart
  • Add packages checksum to ensure expected file and prevent unecessary re-download (see warnings section below)
  • Installation package file only if present and/or modified (@arifcse019) #73
  • Fix start service making it just be restarted at the end of the configuration (@HelioCampos) #71
  • Improve error messages during dashboard creation #64
  • Update ServerSpec test to check :stderr for curl output

warning

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'

2.0.0 (2015-06-28):

  • Major overhaul of the cookbook to support Grafana 2.x

1.x dev:

  • Ensure setting node['grafana']['listen_address'] to nil render a valid nginx config file (@lanyonm) #39

1.5.5 (2015-03-29):

  • Update elasticsearch git url in Berksfile for elasticsearch to elastic rename (@lanyonm) #38
  • Allow nginx to listen on all interface when node['grafana']['webserver_listen'] is nil or false (@BackSlasher) #37
  • Fix base64 encoding appending a newline in nginx config for basic auth (@BackSlasher) #36

1.5.4 (2015-02-22):

  • Update Grafana to 1.9.1 (@osigida) #32
  • Interpolate "version" and "type" attributes to build grafana file url (Bernhard Köhler) #31 and (Olivier Bazoud) #29
  • Add support for lambdas in datasources. This change makes it possible to evaluate derived attributes correctly. (Bernhard Köhler) #30 and #25

1.5.3 (2014-11-15):

  • Add support for Centos#28

1.5.2 (2014-11-04):

  • Allow configuration of default_route via attributes (Miguel Landaeta) #26
  • Add support for grafana admin password option (Andrew Goktepe) #23

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.

1.4.0 (2014-09-12):

  • Update Grafana to 1.8.0-rc1
  • Add default['grafana']['window_title_prefix'] and default['grafana']['search_max_results'] config attributes.

warnings

  • Grafana 1.8.0-rc1 upgraded to JQuery to 2.1.1 and thus dropped support for Internet Explorer 7 and 8

1.3.4 (2014-08-19):

  • Update attributes in README for better Supermarket display
  • Update foodcritic and rubocop (Tim Smith) #21
  • Remove mention of zipfile in README and attributes (Thanks to Gref Fitzgerald)
  • Fix default['grafana']['install_type'] documentation to have the correct possible values: git and file (Fred Hatfull) #20
  • Fix default['grafana']['webserver'] documentation not to include apache as possible value. (osigida) #19

1.3.2 (2014-08-12):

  • Update default Grafana to 1.7.0. (Greg Fitzgerald) #18.

1.3.1 (2014-08-07):

  • Update Grafana to 1.7.1-rc1. It fixes a regression introduced when merging #16. Thanks to Greg Fitzgerald for reporting it.

1.3.0 (2014-07-31):

  • Allow attribute configuration for datasources (Grégoire Seux) #16

1.2.0 (2014-07-11):

breaking changes

  • Update ark dependency to >= 0.7.2 and deprecation warning by using strip_component (Grégoire Seux) #15

minor changes

  • Support newer nginx cookbook by specifying template: false when enabling the grafana site (Grégoire Seux) #15

1.1.1 (2014-07-10):

  • Update default attributes to install Grafana 1.6.1 (Greg Fitzgerald) #14

1.1.0 (2014-06-20):

breaking changes

  • config.js data for graphite and elasticsearch changed back to use:

    • window.location.protocol+"//"+window.location.hostname+":"+window.location.port+"/_graphite"
    • window.location.protocol+"//"+window.location.hostname+":"+window.location.port

The idea is to allow external access without CORS problems or credential leaks in config.js.

  • Value for default['grafana']['install_path'] changed from /opt to /srv/apps (Greg Fitzgerald) #13
  • Default installation uses zip file instead of git (Greg Fitzgerald) #13

minor changes

  • Major cleanup and additional tests (Greg Fitzgerald) #13

1.0.6 (2014-06-17):

1.0.5 (2014-06-17):

breaking changes

  • config.js was unintentionally changed to use node info to configure graphite and elasticsearch index.
  • Value for default['grafana']['grafana_index'] changed from grafana-dash to grafana-index (Greg Fitzgerald) #11
  • Update grafana to 1.6.0 (Greg Fitzgerald) #11

1.0.4 (2014-05-18):

  • Update config.js based on the one in 1.5.4
  • Update to grafana 1.5.4
  • Update to new download URL

1.0.3 (2014-04-12):

  • Add some basic specs, foodcritic, knife test and enable TravisCI

  • Fix error with undefined grafana_user variable Thanks to @klamontagne

  • Fix timezone value quoting in config.js (Anatoliy D.) #9

  • Update grafana to 1.5.2 (Grégoire Seux) #7

  • Don't set normal attribute node['nginx']['default_site_enabled'] (Grégoire Seux) #5

  • Remove "use strict"; from config.js as it seems to not be present in
    grafana releases, thanks to @iiro for proposing it in #1

  • Don't search when node['grafana']['es_server'] or node['grafana']['graphite_server']
    is set and don't use normal attributes (Grégoire Seux) #3

  • Refactor and separate install in two recipes: install_git and install_file
    (Grégoire Seux) #2

1.0.2 (2014-03-23):

  • Update file release to 1.5.1

1.0.1 (2014-03-10):

  • Update file release to 1.5.0

1.0.0 (2014-03-01):

  • Initial release of grafana

Foodcritic Metric
            

2.1.2 passed this metric