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 (103) Versions 3.0.0

Installs/Configures Grafana Server

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

Grafana Cookbook

Build Status Cookbook Version

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.

Requirements

Chef Client

  • Chef Client 13+

Platforms

  • Ubuntu >= 14.04
  • Debian >= 8
  • CentOS/Redhat >= 6

Cookbooks

Recipes

  • default - Wrap private recipes for Grafana setup

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']['manage_install'] true Whether or not the installation should be managed by this cookbook.
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']['plugins_dir'] '/var/lib/grafana/plugins' Grafana's plugins 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']['restart_on_upgrade'] false Whether or not to restart the service on upgrade when installing from packages
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
node['grafana']['cli_bin'] /usr/sbin/grafana-cli The path to the grafana-cli binary
node['grafana']['plugins'] empty Array of plugins to install

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
node['grafana']['nginx']['basic_auth'] false If true generated nginx config will have basic auth configured
node['grafana']['nginx']['httpasswd_file'] /etc/nginx/htpasswd.users The basic auth user/password file to use

NOTE

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

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
datasource Hash {} A Hash of the values to create the datasource. Examples below.
action String create Valid actions are create, update, and delete.

Examples

You can create a data source for Graphite as follows:

grafana_datasource 'graphite-test' do
  datasource(
    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
  datasource(
    type: 'influxdb_08',
    url: 'http://10.0.0.10:8086',
    access: 'proxy',
    database: 'metrics',
    user: 'dashboard',
    password: 'dashpass',
    isdefault: true
  )
  action :create
end

Based on you version of Grafana, value for the type key to use InfluxDB 0.9.x, need to be 'influxdb' instead of 'influxdb_08'.

You can update an existing datasource as follows:

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

And even rename it:

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

Finally, you can also delete a datasource:

grafana_datasource 'influxdb-test' do
  action :delete
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.

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

grafana_dashboard 'test-dash' do
  dashboard(
    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
  dashboard(
    path: '/opt/grafana/dashboards/local-dash.json'
  )
end

You can update a dashboard. For that, you have 2 options:

Use create action with overwrite dashboard property, like:

grafana_dashboard 'on-disk-dash' do
  dashboard(
    path: '/opt/grafana/dashboards/local-dash.json',
    overwrite: true
  )
  action :create
end

Or use update action, which will force overwrite dashboard property to true:

grafana_dashboard 'on-disk-dash' do
  dashboard(
    path: '/opt/grafana/dashboards/local-dash.json'
  )
  action :update
end

Finally, you can delete a dashboard:

grafana_dashboard 'test-dash' do
  action :delete
end

grafana_organization

This resource will allow you to create organizations within Grafana.

More information about creating Grafana organizations 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
`organization Hash {} A Hash of the values to create the organization. Examples below.
action String create_if_missing Valid actions are create, update and delete.

Examples

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

grafana_organization 'Second Org.'

You can also update an existing organization (usefull to change the name of the default organization):

grafana_organization 'Main Org.' do
  organization(
    name: 'Main Org 2.'
  )
  action :update
end

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.

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
user Hash {} A Hash of the values to create the user. Examples below.
action String create Valid actions are create, update, delete.

Examples

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

grafana_user 'j.smith' do
  user(
    name: 'John Smith',
    email: 'test@example.com',
    password: 'test123',
    isAdmin: true
  )
  action :create
end

User's login property is not mandatory. Default goes to resource name.

To update user's details, password and permissions

grafana_user 'j.smith' do
  user(
    name: 'John Smith',
    email: 'test@example.com',
    password: 'test1234',
    isAdmin: false
  )
  action :update
end

To update user's login, use current login as resource name and new login as user property, like:

grafana_user 'j.smith' do
  user(
    name: 'John Smith',
    login: 'john.smith',
    email: 'test@example.com',
    password: 'test1234',
    isAdmin: false
  )
  action :update
end

And finally to delete a user

grafana_user 'john.smith' do
  action :delete
end

grafana_plugin

This ressource will help you to manage grafana plugins.

Properties

Property Type Default Value Description
name String '' Name of the plugin.
action String install Valid actions are install, update, remove.
grafana_cli_bin String '/usr/sbin/grafana-cli' The path to the grafana-cli binary

Examples

grafana_plugin grafana-clock-panel do
  action :install
  grafana_cli_bin '/usr/sbin/grafana-cli'
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

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)
  • Jean Baptiste Favre (@jbfavre)
  • Miguel Moll (@MiguelMoll)
  • ptQa (@ptqa)
  • Danny (@kemra102)
  • Dave Steinberg (@redterror)
  • Roel Gerrits (@roelgerrits)
  • Corentin Chary (@iksaif)
  • @phoenixyz
  • Ioannis Charitopoulos (@jinxcat)
  • Joshua Zitting (@joshzitting)
  • Angelo San Ramon (@angelosanramon)
  • Dmitry (@cyberflow)
  • Nilanjan Roy (@nilroy)
  • Jon Henry (@jhenry82)
  • akadoya (@akadoya)
  • Andrei Skopenko (@scopenco)

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

CHANGELOG for grafana

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

3.0.0 (2018-04-29)

  • Require Chef 13 or later
  • Remove use_inline_resources and why_run statements from LWRPs which are no longer necessary with Chef 13+
  • Remove the dependency on apt/yum cookbooks since we can setup apt/yum repositories with Chef 13
  • Switch package installs to multi-package installs to speed up Chef runs
  • Remove the 'name' LWRP properties since Chef creates these automatically for us
  • Switch testing to InSpec / Delivery local mode
  • Add codeowners, contributing.md, and codeofconduct.md files
  • Fix failures in the ChefSpecs and simplify the specs
  • Remove ChefSpec matchers since these are autogenerated by ChefSpec now
  • Sped up ChefSpec runtimes by enabling caching
  • Drop support for Debian 7 since it goes EOL in a few weeks

2.2.1 (2018-04-03):

  • Add exception handling for JSON::ParserError #155 by @ton31337
  • new attribute node[grafana][restart_on_upgrade] #164 by InformatiQ
  • Switch to nginx cookbook to create the nginx site instead of manually templating out the file

2.2.0 (2017-10-12):

  • Switch to linter cookstyle
  • Fix serverspec tests #180
  • Upgrade grafana version
  • Fix env file

2.1.3 (2015-08-24):

  • Fix a bug in error message handling code #80

2.1.2 (2015-08-24):

  • Fix Grafana package checksums #79

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

Collaborator Number Metric
            

3.0.0 passed this metric

Contributing File Metric
            

3.0.0 passed this metric

Foodcritic Metric
            

3.0.0 passed this metric

No Binaries Metric
            

3.0.0 passed this metric

Testing File Metric
            

3.0.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file

Version Tag Metric
            

3.0.0 passed this metric