Skip to content

Commit

Permalink
Update for Prometheus 0.15
Browse files Browse the repository at this point in the history
  • Loading branch information
Magrath committed Jul 31, 2015
1 parent 21141d6 commit 27d2a7b
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 70 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -18,3 +18,4 @@ bin/*

.kitchen/
.kitchen.local.yml
.idea
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,9 @@
All notable changes to this project will be documented in this file.

## [Unreleased][unreleased]
### Changed
- Updated attributes and templates for Prometheus 0.15 release.

### Added
- Added upstart init for ubuntu platform.

Expand Down
72 changes: 41 additions & 31 deletions attributes/default.rb
Expand Up @@ -37,14 +37,14 @@
default['prometheus']['log_dir'] = '/var/log/prometheus'

# Prometheus version to build
default['prometheus']['version'] = '0.12.0'
default['prometheus']['version'] = '0.15.1'

# Prometheus source repository.
default['prometheus']['source']['git_repository'] = 'https://github.com/prometheus/prometheus.git'

# Prometheus source repository git reference. Defaults to version tag. Can
# also be set to a branch or master.
default['prometheus']['source']['git_revision'] = node['prometheus']['source']['version']
default['prometheus']['source']['git_revision'] = node['prometheus']['version']

# System user to use
default['prometheus']['user'] = 'prometheus'
Expand All @@ -57,11 +57,11 @@

# Location for Prometheus pre-compiled binary.
# Default for testing purposes
default['prometheus']['binary_url'] = 'https://sourceforge.net/projects/prometheusbinary/files/prometheus-ubuntu14.tar.bz2/'
default['prometheus']['binary_url'] = 'https://github.com/prometheus/prometheus/releases/download/0.15.1/prometheus-0.15.1.linux-amd64.tar.gz'

# Checksum for pre-compiled binary
# Default for testing purposes
default['prometheus']['checksum'] = '10b24708b97847ba8bdd41f385f492a8edd460ec3c584c5b406a6c0329cc3a4e'
default['prometheus']['checksum'] = '4b283ce4bf194619d03883a9cf23bd4566a5e5c3cc483b1192a1cd3c4a756118'

# If file extension of your binary can not be determined by the URL
# then define it here. Example 'tar.bz2'
Expand All @@ -71,7 +71,7 @@
default['prometheus']['allow_external_config'] = false

# Prometheus job configuration chef template name.
default['prometheus']['job_config_template_name'] = 'prometheus.conf.erb'
default['prometheus']['job_config_template_name'] = 'prometheus.yml.erb'

# Prometheus custom configuration cookbook. Use this if you'd like to bypass the
# default prometheus cookbook job configuration template and implement your own
Expand All @@ -81,39 +81,30 @@
# FLAGS Section: Any attributes defined under the flags hash will be used to
# generate the command line flags for the Prometheus executable.

# Prometheus configuration file name.
default['prometheus']['flags']['config.file'] = "#{node['prometheus']['dir']}/prometheus.yml"

# Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal, panic].
default['prometheus']['flags']['log.level'] = 'info'

# Alert manager HTTP API timeout.
default['prometheus']['flags']['alertmanager.http-deadline'] = '10s'

# The capacity of the queue for pending alert manager notifications.
default['prometheus']['flags']['alertmanager.notification-queue-capacity'] = '100'
default['prometheus']['flags']['alertmanager.notification-queue-capacity'] = 100

# The URL of the alert manager to send notifications to.
default['prometheus']['flags']['alertmanager.url'] = ''

# log to standard error as well as files
default['prometheus']['flags']['alsologtostderr'] = false

# Prometheus configuration file name.
default['prometheus']['flags']['config.file'] = "#{node['prometheus']['dir']}/prometheus.conf"

# when logging hits line file:N, emit a stack trace
default['prometheus']['flags']['log_backtrace_at'] = ''

# If non-empty, write log files in this directory
default['prometheus']['flags']['log_dir'] = ''

# log to standard error instead of files
default['prometheus']['flags']['logtostderr'] = false
# Maximum number of queries executed concurrently.
default['prometheus']['flags']['query.max-concurrency'] = 20

# Staleness delta allowance during expression evaluations.
default['prometheus']['flags']['query.staleness-delta'] = '5m0s'

# Maximum time a query may take before being aborted.
default['prometheus']['flags']['query.timeout'] = '2m0s'

# logs at or above this threshold go to stderr
default['prometheus']['flags']['stderrthreshold'] = 0

# If approx. that many time series are in a state that would require a recovery
# operation after a crash, a checkpoint is triggered, even if the checkpoint interval
# hasn't passed yet. A recovery operation requires a disk seek. The default limit
Expand Down Expand Up @@ -149,20 +140,33 @@
# Base path for metrics storage.
default['prometheus']['flags']['storage.local.path'] = '/tmp/metrics'

# If set, a crash recovery will perform checks on each series file. This might take a very long time.
default['prometheus']['flags']['storage.local.pedantic-checks'] = false

# How long to retain samples in the local storage.
default['prometheus']['flags']['storage.local.retention'] = '360h0m0s'

# The timeout to use when sending samples to OpenTSDB.
default['prometheus']['flags']['storage.remote.timeout'] = '30s'
# When to sync series files after modification. Possible values:
# 'never', 'always', 'adaptive'. Sync'ing slows down storage performance
# but reduces the risk of data loss in case of an OS crash. With the
# 'adaptive' strategy, series files are sync'd for as long as the storage
# is not too much behind on chunk persistence.
default['prometheus']['flags']['storage.local.series-sync-strategy'] = 'adaptive'

# The URL of the remote InfluxDB server to send samples to. None, if empty.
default['prometheus']['flags']['storage.remote.influxdb-url'] = ''

# The URL of the OpenTSDB instance to send samples to.
default['prometheus']['flags']['storage.remote.url'] = ''
# The name of the database to use for storing samples in InfluxDB.
default['prometheus']['flags']['storage.remote.influxdb.database'] = 'prometheus'

# log level for V logs
default['prometheus']['flags']['v'] = 0
# The InfluxDB retention policy to use.
default['prometheus']['flags']['storage.remote.influxdb.retention-policy'] = 'default'

# comma-separated list of pattern=N settings for file-filtered logging
default['prometheus']['flags']['vmodule'] = ''
# The URL of the OpenTSDB instance to send samples to. None, if empty.
default['prometheus']['flags']['storage.remote.opentsdb-url'] = ''

# The timeout to use when sending samples to the remote storage.
default['prometheus']['flags']['storage.remote.timeout'] = '30s'

# Path to the console library directory.
default['prometheus']['flags']['web.console.libraries'] = 'console_libraries'
Expand All @@ -173,6 +177,12 @@
# Enable remote service shutdown.
default['prometheus']['flags']['web.enable-remote-shutdown'] = false

# The URL under which Prometheus is externally reachable (for
# example, if Prometheus is served via a reverse proxy). Used for
# generating relative and absolute links back to Prometheus itself. If
# omitted, relevant URL components will be derived automatically.
default['prometheus']['flags']['web.web.external-url'] = ''

# Address to listen on for the web interface, API, and telemetry.
default['prometheus']['flags']['web.listen-address'] = ':9090'

Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Expand Up @@ -5,7 +5,7 @@
license 'Apache 2.0'
description 'Installs/Configures Prometheus'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.5.1'
version '0.6.0'
# rubocop:enable Style/SingleSpaceBeforeFirstArg

%w( ubuntu debian centos redhat fedora ).each do |os|
Expand Down
3 changes: 2 additions & 1 deletion recipes/default.rb
Expand Up @@ -52,7 +52,8 @@
# monitor our server instance
prometheus_job 'prometheus' do
scrape_interval '15s'
target "http://localhost#{node['prometheus']['flags']['web.listen-address']}#{node['prometheus']['flags']['web.telemetry-path']}"
target "localhost#{node['prometheus']['flags']['web.listen-address']}"
metrics_path node['prometheus']['flags']['web.telemetry-path']
end

accumulator node['prometheus']['flags']['config.file'] do
Expand Down
6 changes: 1 addition & 5 deletions recipes/source.rb
Expand Up @@ -34,14 +34,10 @@
cwd "#{Chef::Config[:file_cache_path]}/prometheus-#{node['prometheus']['version']}"
code <<-EOH
make build &&
cp -R prometheus #{node['prometheus']['dir']} &&
mv prometheus #{node['prometheus']['dir']} &&
cp -R console_libraries #{node['prometheus']['dir']} &&
cp -R consoles #{node['prometheus']['dir']}
EOH

not_if do
File.exist?("#{node['prometheus']['dir']}/prometheus")
end

notifies :restart, 'service[prometheus]'
end
2 changes: 0 additions & 2 deletions resources/job.rb
Expand Up @@ -5,6 +5,4 @@
attribute :scrape_interval, kind_of: String
attribute :scrape_timeout, kind_of: String
attribute :target, kind_of: [Array, String]
attribute :sd_name, kind_of: String
attribute :sd_refresh_interval, kind_of: String
attribute :metrics_path, kind_of: String, default: '/metrics'
30 changes: 0 additions & 30 deletions templates/default/prometheus.conf.erb

This file was deleted.

18 changes: 18 additions & 0 deletions templates/default/prometheus.yml.erb
@@ -0,0 +1,18 @@
# Global default settings.
global:
scrape_interval: "15s" # By default, scrape targets every 15 seconds.
evaluation_interval: "15s" # By default, evaluate rules every 15 seconds.

scrape_configs:
<% for job in @jobs||[] %>
- job_name: "<%= job.name %>"
<% if job.scrape_interval %>
scrape_interval: "<%= job.scrape_interval %>"
<% end %>
<% if job.scrape_timeout %>
scrape_timeout: "<%= job.scrape_timeout %>"
<% end %>
metrics_path: "<%= job.metrics_path %>"
target_groups:
- targets: <%= [job.target] %>
<% end %>

0 comments on commit 27d2a7b

Please sign in to comment.