Lbrt
A tool to manage Librato. It defines the state of Librato using DSL, and updates Librato according to DSL.
Installation
Add this line to your application's Gemfile:
gem 'lbrt'
And then execute:
$ bundle
Or install it yourself as:
$ gem install lbrt
Usage
$ lbrt
Commands:
lbrt alert SUBCOMMAND
lbrt help [COMMAND]
lbrt metric SUBCOMMAND
lbrt service SUBCOMMAND
lbrt space SUBCOMMAND
Options:
[--user=USER]
[--token=TOKEN]
[--color], [--no-color]
[--debug], [--no-debug]
$ lbrt help alert
Commands:
lbrt alert apply FILE
lbrt alert export [FILE]
lbrt alert help [COMMAND]
lbrt alert list
lbrt alert peco
Options:
[--target=TARGET]
$ brt help metric
Commands:
lbrt metric help [COMMAND]
lbrt metric list
lbrt metric peco REGRXP
Options:
[--target=TARGET]
$ lbrt help service
Commands:
lbrt service apply FILE
lbrt service export [FILE]
lbrt service help [COMMAND]
lbrt service list
Options:
[--target=TARGET]
$ lbrt help space
Commands:
lbrt space apply FILE
lbrt space export [FILE]
lbrt space help [COMMAND]
lbrt space list
lbrt space peco
Options:
[--target=TARGET]
[--concurrency=N]
Export/Apply
$ lbrt space export space.rb
$ cat space.rb
space "My Space" do
chart "My Chart" do
type "line"
stream do
metric "login-delay"
type "gauge"
...
$ lbrt space apply space.rb --dry-run
$ lbrt space apply space.rb
DSL Example
Sevice
service "mail", "my email" do
settings "addresses"=>"sugawara@example.com"
end
service "slack", "my slack" do
settings "url"=>"https://hooks.slack.com/services/..."
end
Alert
alert "alert1" do
description "My Alert1"
attributes "runbook_url"=>"http://example.com"
active true
rearm_seconds 600
rearm_per_signal false
condition do
type "below"
metric_name "login-delay"
source "foo.bar.com"
threshold 1.0
summary_function "sum"
end
service "mail", "my email"
end
alert "alert2" do
description "My Alert2"
active true
rearm_seconds 600
rearm_per_signal true
condition do
type "absent"
metric_name "login-delay2"
source nil
duration 600
end
service "slack", "my slack"
end
Space
space "My Space1" do
chart "chart1" do
type "stacked"
stream do
metric "login-delay"
type "gauge"
source "*"
group_function "average"
summary_function "average"
end
end
end
space "My Space2" do
chart "chart1" do
type "line"
stream do
metric "login-delay"
type "gauge"
source "*"
group_function "breakout"
summary_function "average"
end
end
chart "chart2" do
type "line"
stream do
metric "login-delay2"
type "gauge"
source "*"
group_function "breakout"
summary_function "average"
end
end
end
Using template
template "dstat" do
chart "total_cpu_usage" do
type "stacked"
stream do
metric "dstat.#{context.space_name}.total_cpu_usage"
type "gauge"
source "*"
group_function "breakout"
summary_function "average"
end
max 100.0
end
chart "load_avg" do
type "line"
stream do
metric "dstat.#{context.space_name}.load_avg"
type "gauge"
source "*"
group_function "breakout"
summary_function "average"
end
end
end
space "my-host-001" do
include_template "dstat"
end
You can use the template in the alert
and service
.
template "my alert" do
alert context.metric_name do
description "desc"
attributes "runbook_url"=>"http://url.com"
active true
rearm_seconds 600
rearm_per_signal false
condition do
type "below"
metric_name context.metric_name
source nil
threshold 4.0
summary_function "sum"
end
service "mail", "my email"
end
end
include_template "my alert", metric_name: 'login-delay'
include_template "my alert", metric_name: 'login-delay2'
template "alert set1" do
alert "#{context.hostname}/login-delay" do
description "desc"
attributes "runbook_url"=>"http://example.com"
active true
rearm_seconds 600
rearm_per_signal false
condition do
type "below"
metric_name 'login-delay'
source nil
threshold 4.0
summary_function "sum"
end
service "mail", "my email"
end
alert "#{context.hostname}/login-delay2" do
description "desc"
attributes "runbook_url"=>"http://example.com"
active true
rearm_seconds 600
rearm_per_signal false
condition do
type "below"
metric_name 'login-delay2'
source nil
threshold 4.0
summary_function "sum"
end
service "mail", "my email"
end
end
include_template "alert set1", hostname: 'host1'
include_template "alert set1", hostname: 'host2'
Show resource by peco
lbrt alert peco
lbrt metric peco
lbrt space peco