Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Output in TTL checks #178

Merged
merged 1 commit into from
Feb 26, 2019

Conversation

kinnalru
Copy link
Contributor

Support for passing Output field in consul TTL checks as described here: https://www.consul.io/api/agent/check.html

@kinnalru
Copy link
Contributor Author

Hi.
@pierresouchay, when you plan to update version of a gem to make "Use correct verbs for Check methods" accessible?

Copy link
Member

@pierresouchay pierresouchay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to doc, you should be using note query parameter instead of JSON payload

@pierresouchay
Copy link
Member

@kinnalru I'll produce a new version once we merge this PR, is that OK?

@kinnalru
Copy link
Contributor Author

@kinnalru I'll produce a new version once we merge this PR, is that OK?

ok

@pierresouchay
Copy link
Member

@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}}

@pierresouchay pierresouchay merged commit 9f332f5 into WeAreFarmGeek:master Feb 26, 2019
pierresouchay added a commit that referenced this pull request Feb 26, 2019
 - Fix incorrect verbs for checks Fix #173
 - Use json_pure to avoid the need for installing a compiler. Fix #177
 - Allow updating Output with TTL checks #178
@kinnalru
Copy link
Contributor Author

@kinnalru Actually, it seems to work with critical as well...

It's good. So just consul UI not show "critical" output.

@pierresouchay
Copy link
Member

@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 )

robmbrooks pushed a commit to robmbrooks/diplomat that referenced this pull request Mar 1, 2019
 - Fix incorrect verbs for checks Fix WeAreFarmGeek#173
 - Use json_pure to avoid the need for installing a compiler. Fix WeAreFarmGeek#177
 - Allow updating Output with TTL checks WeAreFarmGeek#178
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants