-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c6703f6
commit 56ed0d0
Showing
36 changed files
with
1,298 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
fixtures: | ||
repositories: | ||
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib" | ||
symlinks: | ||
"prometheus": "#{source_dir}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>prometheus</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>com.puppetlabs.geppetto.pp.dsl.ui.modulefileBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>com.puppetlabs.geppetto.pp.dsl.ui.puppetNature</nature> | ||
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
language: ruby | ||
bundler_args: --without development | ||
before_install: rm Gemfile.lock || true | ||
sudo: false | ||
cache: bundler | ||
rvm: | ||
- 1.9.3 | ||
- 2.0.0 | ||
- 2.1.0 | ||
script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'" | ||
env: | ||
- PUPPET_VERSION="~> 3.1.0" | ||
- PUPPET_VERSION="~> 3.3.0" | ||
- PUPPET_VERSION="~> 3.7.4" FUTURE_PARSER=yes | ||
- PUPPET_VERSION="~> 3.8.4" | ||
- PUPPET_VERSION="~> 3.8.4" FUTURE_PARSER=yes | ||
- PUPPET_VERSION="~> 4.0.0" | ||
- PUPPET_VERSION="~> 4.1.0" | ||
matrix: | ||
exclude: | ||
- rvm: 2.0.0 | ||
env: PUPPET_VERSION="~> 3.1.0" | ||
- rvm: 2.1.0 | ||
env: PUPPET_VERSION="~> 3.1.0" | ||
- rvm: 2.1.0 | ||
env: PUPPET_VERSION="~> 3.2.0" | ||
- rvm: 2.1.0 | ||
env: PUPPET_VERSION="~> 3.3.0" | ||
- rvm: 2.1.0 | ||
env: PUPPET_VERSION="~> 3.4.0" | ||
- rvm: 1.9.3 | ||
env: PUPPET_VERSION="~> 4.0.0" | ||
- rvm: 2.0.0 | ||
env: PUPPET_VERSION="~> 4.0.0" | ||
- rvm: 1.9.3 | ||
env: PUPPET_VERSION="~> 4.1.0" | ||
- rvm: 2.0.0 | ||
env: PUPPET_VERSION="~> 4.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
source ENV['GEM_SOURCE'] || "https://rubygems.org" | ||
|
||
gem 'puppet', ENV.key?('PUPPET_VERSION') ? "#{ENV['PUPPET_VERSION']}" : "3.0" | ||
gem 'rake', '~> 10' | ||
gem 'rspec-puppet', '~> 2.0' | ||
gem 'puppetlabs_spec_helper', '>= 0.8.0' | ||
gem 'puppet-lint', '>= 1' | ||
gem 'puppet-lint-unquoted_string-check' | ||
gem 'puppet-lint-empty_string-check' | ||
gem 'puppet-lint-spaceship_operator_without_tag-check' | ||
gem 'puppet-lint-absolute_classname-check' | ||
gem 'puppet-lint-undef_in_function-check' | ||
gem 'puppet-lint-leading_zero-check' | ||
gem 'puppet-lint-trailing_comma-check' | ||
gem 'puppet-lint-file_ensure-check' | ||
gem 'puppet-lint-variable_contains_upcase' | ||
gem 'simplecov' | ||
gem 'rspec-puppet-facts' | ||
gem 'metadata-json-lint' | ||
gem 'rspec', '< 3.2.0', {"platforms"=>["ruby_18"]} | ||
gem 'json', '~> 1.0', {"platforms"=>["ruby_18", "ruby_19"]} | ||
gem 'json_pure', '~> 1.0', {"platforms"=>["ruby_18", "ruby_19"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Copyright (C) 2014 R. Tyler Croy <[email protected]> | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,119 @@ | ||
# puppet-prometheus | ||
# puppet-prometheus | ||
[![Build Status](https://travis-ci.org/cristifalcas/puppet-prometheus.png?branch=master)](https://travis-ci.org/cristifalcas/puppet-prometheus) | ||
|
||
#### Table of Contents | ||
|
||
1. [Overview](#overview) | ||
2. [Usage - Configuration options and additional functionality](#usage) | ||
3. [Development - Guide for contributing to the module](#development) | ||
|
||
|
||
## Overview | ||
|
||
This module installs and configures the Prometheus monitoring tool: [Prometheus web site](https://prometheus.io/docs/introduction/overview/) | ||
|
||
In order to print the yaml config files for prometheus and alertmanager, it | ||
uses some files from [puppet-elasticsearch](https://github.com/elastic/puppet-elasticsearch) module | ||
|
||
|
||
## Usage | ||
|
||
Install the prometheus server: | ||
|
||
```puppet | ||
$scrape_prometheus = { | ||
'job_name' => 'prometheus', | ||
'static_configs' => [{ | ||
'targets' => ['localhost:9090',], | ||
'labels' => { | ||
'alias' => 'Prometheus', | ||
} | ||
, | ||
} | ||
,], | ||
} | ||
$scrape_nerve = { | ||
'job_name' => 'nerve', | ||
'nerve_sd_configs' => [{ | ||
'servers' => ['localhost:2181',], | ||
'paths' => ['/monitoring/os',], | ||
} | ||
,], | ||
} | ||
class { '::prometheus': | ||
package_ensure => 'latest', | ||
purge_config_dir => true, | ||
alertmanager_url => 'http://localhost:9093', | ||
log_format => 'logger:syslog?appname=prometheus&local=7', | ||
storage_local_path => '/var/lib/prometheus/data', | ||
web_console_libraries => '/usr/share/prometheus/console_libraries', | ||
web_console_templates => '/usr/share/prometheus/consoles', | ||
web_listen_address => ':9090', | ||
config => { | ||
global => { | ||
'scrape_interval' => '30s', | ||
'scrape_timeout' => '10s', | ||
'evaluation_interval' => '30s', | ||
} | ||
, | ||
scrape_configs => [$scrape_prometheus, $scrape_nerve,], | ||
} | ||
, | ||
} | ||
``` | ||
|
||
or: | ||
```puppet | ||
include ::prometheus | ||
``` | ||
|
||
Install node exporter: | ||
|
||
```puppet | ||
$node_collectors = [ | ||
'conntrack', | ||
'diskstats', | ||
'entropy', | ||
'filefd', | ||
'filesystem', | ||
'interrupts', | ||
'ksmd', | ||
'loadavg', | ||
'logind', | ||
'mdadm', | ||
'meminfo', | ||
'meminfo_numa', | ||
'netdev', | ||
'netstat', | ||
'sockstat', | ||
'stat', | ||
'systemd', | ||
'tcpstat', | ||
'textfile', | ||
'time', | ||
'uname', | ||
'vmstat', | ||
] | ||
class { '::prometheus::node_exporter': | ||
package_name => 'node_exporter', | ||
collectors_enabled => $node_collectors, | ||
log_format => 'logger:syslog?appname=node_exporter&local=7', | ||
web_listen_address => ':9100', | ||
} | ||
``` | ||
|
||
or: | ||
|
||
```puppet | ||
include ::prometheus::node_exporter | ||
``` | ||
|
||
## Development | ||
|
||
* Fork the project | ||
* Commit and push until you are happy with your contribution | ||
* Send a pull request with a description of your changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'bundler' | ||
Bundler.require(:rake) | ||
require 'rake/clean' | ||
|
||
CLEAN.include('spec/fixtures/', 'doc', 'pkg') | ||
CLEAN.include('lib/puppet_x/elastic/', '*') | ||
CLOBBER.include('.tmp', '.librarian') | ||
|
||
require 'puppetlabs_spec_helper/rake_tasks' | ||
|
||
task :default => [:clean, :spec] | ||
|
||
PuppetLint.configuration.fail_on_warnings = true | ||
PuppetLint.configuration.send('relative') | ||
PuppetLint.configuration.send('disable_80chars') | ||
PuppetLint.configuration.send('disable_class_inherits_from_params_class') | ||
PuppetLint.configuration.send('disable_class_parameter_defaults') | ||
PuppetLint.configuration.send('disable_documentation') | ||
PuppetLint.configuration.send('disable_single_quote_string_with_variables') | ||
PuppetLint.configuration.send('disable_empty_string_assignment') | ||
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] | ||
PuppetSyntax.future_parser = true | ||
PuppetSyntax.exclude_paths = ["templates/*.erb"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Puppet_X | ||
module Elastic | ||
# This ugly hack is required due to the fact Puppet passes in the | ||
# puppet-native hash with stringified numerics, which causes the | ||
# decoded JSON from the Elasticsearch API to be seen as out-of-sync | ||
# when the parsed template hash is compared against the puppet hash. | ||
def self.deep_to_i obj | ||
if obj.is_a? String and obj =~ /^[0-9]+$/ | ||
obj.to_i | ||
elsif obj.is_a? Array | ||
obj.map { |element| deep_to_i(element) } | ||
elsif obj.is_a? Hash | ||
obj.merge(obj) { |key, val| deep_to_i(val) } | ||
else | ||
obj | ||
end | ||
end | ||
end # of Elastic | ||
end # of Puppet_X |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
module Puppet_X | ||
module Elastic | ||
module SortedHash | ||
|
||
# Upon extension, modify the hash appropriately to render | ||
# sorted yaml dependent upon whichever way is supported for | ||
# this version of Puppet/Ruby's yaml implementation. | ||
def self.extended(base) | ||
|
||
if RUBY_VERSION >= '1.9' | ||
# We can sort the hash in Ruby >= 1.9 by recursively | ||
# re-inserting key/values in sorted order. Native to_yaml will | ||
# call .each and get sorted pairs back. | ||
tmp = base.to_a.sort | ||
base.clear | ||
tmp.each do |key, val| | ||
if val.is_a? base.class | ||
val.extend Puppet_X::Elastic::SortedHash | ||
elsif val.is_a? Array | ||
val.map do |elem| | ||
if elem.is_a? base.class | ||
elem.extend(Puppet_X::Elastic::SortedHash) | ||
else | ||
elem | ||
end | ||
end | ||
end | ||
base[key] = val | ||
end | ||
else | ||
# Otherwise, recurse into the hash to extend all nested | ||
# hashes with the sorted each_pair method. | ||
# | ||
# Ruby < 1.9 doesn't support any notion of sorted hashes, | ||
# so we have to expressly monkey patch each_pair, which is | ||
# called by ZAML (the yaml library used in Puppet < 4; Puppet | ||
# >= 4 deprecates Ruby 1.8) | ||
# | ||
# Note that respond_to? is used here as there were weird | ||
# problems with .class/.is_a? | ||
base.merge! base do |_, ov, nv| | ||
if ov.respond_to? :each_pair | ||
ov.extend Puppet_X::Elastic::SortedHash | ||
elsif ov.is_a? Array | ||
ov.map do |elem| | ||
if elem.respond_to? :each_pair | ||
elem.extend Puppet_X::Elastic::SortedHash | ||
else | ||
elem | ||
end | ||
end | ||
else | ||
ov | ||
end | ||
end | ||
end | ||
end | ||
|
||
# Override each_pair with a method that yields key/values in | ||
# sorted order. | ||
def each_pair | ||
keys.sort.each do |key| | ||
yield key, self[key] | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.