-
Notifications
You must be signed in to change notification settings - Fork 41
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
validate changed items using datadog api #275
Comments
POC desc "Validate resources against datadog api using generated/ (atm monitor only) [PROJECT|TRACKING_ID|FILE=]"
task validate: "kennel:environment" do
files =
if (project = ENV["PROJECT"])
Dir["generated/#{project}/*.json"]
elsif (id = ENV["TRACKING_ID"])
Dir["generated/#{id.split(":").join("/")}.json"]
elsif (file = ENV["FILE"])
file
else
raise "Need PROJECT or TRACKING_ID or FILE"
end
monitors = files
.map { |f| [f, JSON.parse(File.read(f))] }
.select { |_, r| r["api_resource"] == "monitor" }
raise "No monitors in selected files" if monitors.empty?
monitors.each do |file, monitor|
begin
Kennel::Api.new.create("monitor/validate", monitor)
puts "#{file}: Valid"
rescue StandardError
puts "#{file}:"
body = $!.message.split("\n").last # parsing api output from what lib/kennel/api.rb adds
puts JSON.parse(body).fetch("errors")
end
end
end |
to make this work for dashboard we could add a fake broken widget and then see if the error coming back is that widget, if it is then we know it's valid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
see https://docs.datadoghq.com/workflows/actions_catalog/monitor_validatemonitor/
only works for monitors ... another option could be to "apply + revert" for others and then get errors from that
... or validating with a deliberate error so we get "expected failure + unknown failure" and then sort out the unknown
The text was updated successfully, but these errors were encountered: