Chef cookbook for Prometheus. The open source service monitoring system and time-series database.
Clone or download
Latest commit 7cf5512 Feb 28, 2018
Permalink
Failed to load latest commit information.
attributes houndci and cookstyle disagree about trailing commas in arrays Feb 26, 2018
libraries Add support for prometheus 2.x installation Nov 3, 2017
recipes Merge branch 'master' into fix_reload Nov 8, 2017
resources updated various unit/style gems to latest, fixed foodcritic complaints. Feb 26, 2018
spec cookstyle recommended fixes Feb 26, 2018
templates Merge branch 'master' into fix_reload Nov 8, 2017
test Alertmanager: spec tests and better templating Aug 11, 2017
.gitignore Update for Prometheus 0.15 Jul 31, 2015
.hound.yml Added hound.yml Mar 8, 2015
.kitchen.yml Add alertmanager recipe to the default test-kitchen build instance. May 22, 2017
.rubocop.yml telling cookstyle to ignore trailing commas in literals Feb 26, 2018
.travis.yml Update .travis.yml Aug 11, 2017
Berksfile Initial commit of empty cookbook Feb 28, 2015
CHANGELOG.md Update for Prometheus 0.15 Jul 31, 2015
CONTRIBUTING.md First pass at a working cookbook with passing test. This commit does … Feb 28, 2015
Gemfile updated various unit/style gems to latest, fixed foodcritic complaints. Feb 26, 2018
ISSUES.md First pass at a working cookbook with passing test. This commit does … Feb 28, 2015
LICENSE First pass at a working cookbook with passing test. This commit does … Feb 28, 2015
README.md add s to metrics_path attribute Jun 6, 2017
Rakefile telling cookstyle to ignore trailing commas in literals Feb 26, 2018
Thorfile Initial commit of empty cookbook Feb 28, 2015
Vagrantfile Update vagrantfile to use bento/ prefix for box rather than chef/ May 22, 2017
chefignore Initial commit of empty cookbook Feb 28, 2015
metadata.rb updated various unit/style gems to latest, fixed foodcritic complaints. Feb 26, 2018

README.md

prometheus Cookbook

Cookbook Build Status Gitter chat

This cookbook installs the Prometheus monitoring system and time-series database.

Requirements

  • Chef 12 or higher
  • Ruby 2.2 or higher

Platform

Tested on

  • Ubuntu 14.04
  • Ubuntu 12.04
  • Debian 7.7
  • Centos 6.6
  • Centos 7.0

Attributes

In order to keep the README managable and in sync with the attributes, this cookbook documents attributes inline. The usage instructions and default values for attributes can be found in the individual attribute files.

Recipes

default

The default recipe installs creates all the default Prometheus directories, config files and and users. Default also calls the configured install_method recipe and finally calls the prometheus service recipe.

source

The source recipe builds Prometheus from a Github source tag.

binary

The binary recipe retrieves and installs a pre-compiled Prometheus build from a user-defined location.

service

The service recipe configures Prometheus to run under a process supervisor. Default supervisors are chosen based on distribution. Currently supported supervisors are init, runit, systemd, upstart and bluepill.

Resource/Provider

prometheus_job

This resource adds a job definition to the Prometheus config file. Here is an example of using this resource to define the default Prometheus job:

prometheus_job 'prometheus' do
  scrape_interval   '15s'
  target            "http://localhost#{node['prometheus']['flags']['web.listen-address']}#{node['prometheus']['flags']['web.telemetry-path']}"
end

Note: This cookbook uses the accumulator pattern so you can define multiple prometheus_job’s and they will all be added to the Prometheus config.

Externally managing prometheus.conf

If you prefer to manage your prometheus.conf file externally using your own inventory or service discovery mechanism you can set default['prometheus']['allow_external_config'] to true.

Dependencies

The following cookbooks are dependencies:

Usage

prometheus::default

Include prometheus in your node's run_list to execute the standard deployment of prometheus:

{
  "run_list": [
    "recipe[prometheus::default]"
  ]
}

prometheus::use_lwrp

Used to load promethus cookbook from wrapper cookbook.

prometheus::use_lwrp doesn't do anything other than allow you to include the Prometheus cookbook into your wrapper or app cookbooks. Doing this allows you to override prometheus attributes and use the prometheus LWRP (prometheus_job) in your wrapper cookbooks.

# Load the promethues cookbook into your wrapper so you have access to the LWRP and attributes

include_recipe "prometheus::use_lwrp"

# Add a rule filename under `rule_files` in prometheus.yml.erb
node.set['prometheus']['rule_filenames'] = ["#{node['prometheus']['dir']}/alert.rules"]

# Example of using search to populate prometheus.yaml jobs using the prometheus_job LWRP
# Finds all the instances that are in the current environment and are taged with "node_exporter"
# Assumes that the service instances were tagged in their own recipes.
client_servers = search(:node, "environment:#{node.chef_environment} AND tags:node_exporter")

# Assumes service_name is an attribute of each node
client_servers.each do |server|
	prometheus_job server.service_name do
  	  scrape_interval   ‘15s’
	  target            “#{server.fqdn}#{node[‘prometheus’][‘flags’][‘web.listen-address’]}"
	  metrics_path       "#{node[‘prometheus’][‘flags’][‘web.telemetry-path’]}
	end
end

# Now run the default recipe that does all the work configuring and deploying prometheus
include_recipe "prometheus::default"

Development

Please see the Contributing and Issue Reporting Guidelines.

License & Authors

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.