Closed kinnalru closed 5 years ago
Hi. @pierresouchay, when you plan to update version of a gem to make "Use correct verbs for Check methods" accessible?
@kinnalru I'll produce a new version once we merge this PR, is that OK?
@kinnalru I'll produce a new version once we merge this PR, is that OK?
ok
@kinnalru Actually, it seems to work with critical as well...
#!/usr/bin/env ruby
require 'diplomat'
Diplomat.configure do |config|
config.url = ENV['CONSUL_HTTP_ADDR'] || "http://localhost:8500"
end
check_id = 'check_ttl'
ttl = Diplomat::Check.register_ttl(check_id, 'check_ttl', 'ttl_check to update', '5m')
puts Diplomat::Check.checks
sleep(3)
puts "Update TTL pass"
Diplomat::Check.pass(check_id, '{"canard": "PASS This is my long output"}')
puts Diplomat::Check.checks
sleep 5
puts "Update TTL warn"
Diplomat::Check.warn(check_id, '{"canard": "WARN This is my long output"}')
puts Diplomat::Check.checks
sleep 5
puts "Update TTL critical"
Diplomat::Check.fail(check_id, '{"canard": "CRITICAL This is my long output"}')
puts Diplomat::Check.checks
sleep 5
Outputs:
{"check_ttl"=>{"Node"=>"C02X72TUJGH5", "CheckID"=>"check_ttl", "Name"=>"check_ttl", "Status"=>"warning", "Notes"=>"ttl_check to update", "Output"=>"{\"canard\": \"WARN This is my long output\"}", "ServiceID"=>"", "ServiceName"=>"", "ServiceTags"=>[], "Definition"=>{"Interval"=>"", "Timeout"=>"", "DeregisterCriticalServiceAfter"=>""}, "CreateIndex"=>0, "ModifyIndex"=>0}}
Update TTL pass
{"check_ttl"=>{"Node"=>"C02X72TUJGH5", "CheckID"=>"check_ttl", "Name"=>"check_ttl", "Status"=>"passing", "Notes"=>"ttl_check to update", "Output"=>"{\"canard\": \"PASS This is my long output\"}", "ServiceID"=>"", "ServiceName"=>"", "ServiceTags"=>[], "Definition"=>{"Interval"=>"", "Timeout"=>"", "DeregisterCriticalServiceAfter"=>""}, "CreateIndex"=>0, "ModifyIndex"=>0}}
Update TTL warn
{"check_ttl"=>{"Node"=>"C02X72TUJGH5", "CheckID"=>"check_ttl", "Name"=>"check_ttl", "Status"=>"warning", "Notes"=>"ttl_check to update", "Output"=>"{\"canard\": \"WARN This is my long output\"}", "ServiceID"=>"", "ServiceName"=>"", "ServiceTags"=>[], "Definition"=>{"Interval"=>"", "Timeout"=>"", "DeregisterCriticalServiceAfter"=>""}, "CreateIndex"=>0, "ModifyIndex"=>0}}
Update TTL critical
{"check_ttl"=>{"Node"=>"C02X72TUJGH5", "CheckID"=>"check_ttl", "Name"=>"check_ttl", "Status"=>"critical", "Notes"=>"ttl_check to update", "Output"=>"{\"canard\": \"CRITICAL This is my long output\"}", "ServiceID"=>"", "ServiceName"=>"", "ServiceTags"=>[], "Definition"=>{"Interval"=>"", "Timeout"=>"", "DeregisterCriticalServiceAfter"=>""}, "CreateIndex"=>0, "ModifyIndex"=>0}}
@kinnalru Actually, it seems to work with critical as well...
It's good. So just consul UI not show "critical" output.
@kinnalru You should try Consul-UI rich HTML UI for Consul https://github.com/criteo/consul-templaterb/ :-)
The UI source (customizable is here: https://github.com/criteo/consul-templaterb/tree/master/samples/consul-ui )
Support for passing Output field in consul TTL checks as described here: https://www.consul.io/api/agent/check.html