Skip to content

Commit

Permalink
Run rubocop -a on the monitor code examples, and updated some snipp…
Browse files Browse the repository at this point in the history
…ets.
  • Loading branch information
armcburney committed Nov 27, 2019
1 parent bf35c15 commit 7fcce5f
Show file tree
Hide file tree
Showing 24 changed files with 228 additions and 223 deletions.
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Style/FrozenStringLiteralComment:
Enabled: false

Metrics/LineLength:
Max: 80
14 changes: 10 additions & 4 deletions content/en/api/monitors/code_snippets/api-monitor-create.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'rubygems'
require 'dogapi'

api_key = '<YOUR_API_KEY>'
Expand All @@ -8,8 +7,15 @@

# Create a new monitor
options = {
'notify_no_data' => true,
'no_data_timeframe' => 20
'notify_no_data' => true,
'no_data_timeframe' => 20
}
tags = ['app:webserver', 'frontend']
dog.monitor("metric alert", "avg(last_5m):sum:system.net.bytes_rcvd{host:host0} > 100", :name => "Bytes received on host0", :message => "We may need to add web hosts if this is consistently high.", :tags => tags, :options => options)
dog.monitor(
'metric alert',
'avg(last_5m):sum:system.net.bytes_rcvd{host:host0} > 100',
name: 'Bytes received on host0',
message: 'We may need to add web hosts if this is consistently high.',
tags: tags,
options: options
)
3 changes: 1 addition & 2 deletions content/en/api/monitors/code_snippets/api-monitor-delete.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'rubygems'
require 'dogapi'

api_key = '<YOUR_API_KEY>'
Expand All @@ -7,4 +6,4 @@
dog = Dogapi::Client.new(api_key, app_key)

# Delete a monitor
dog.delete_monitor(62625)
dog.delete_monitor(62_625)
8 changes: 6 additions & 2 deletions content/en/api/monitors/code_snippets/api-monitor-edit.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'rubygems'
require 'dogapi'

api_key = '<YOUR_API_KEY>'
Expand All @@ -7,4 +6,9 @@
dog = Dogapi::Client.new(api_key, app_key)

# Edit an existing monitor
dog.update_monitor(91879, "avg(last_5m):sum:system.net.bytes_rcvd{host:host0} > 100", :message => "Bytes received on host0", :name => "We may need to add web hosts if this is consistently high.")
dog.update_monitor(
91_879,
'avg(last_5m):sum:system.net.bytes_rcvd{host:host0} > 100',
message: 'Bytes received on host0',
name: 'We may need to add web hosts if this is consistently high.'
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'rubygems'
require 'dogapi'

api_key = '<YOUR_API_KEY>'
Expand All @@ -7,4 +6,4 @@
dog = Dogapi::Client.new(api_key, app_key)

# Search monitor groups
dog.search_monitor_groups()
dog.search_monitor_groups
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'rubygems'
require 'dogapi'

api_key = '<YOUR_API_KEY>'
Expand All @@ -7,4 +6,4 @@
dog = Dogapi::Client.new(api_key, app_key)

# Mute all alerts
dog.mute_monitors()
dog.mute_monitors
3 changes: 1 addition & 2 deletions content/en/api/monitors/code_snippets/api-monitor-mute.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'rubygems'
require 'dogapi'

api_key = '<YOUR_API_KEY>'
Expand All @@ -7,4 +6,4 @@
dog = Dogapi::Client.new(api_key, app_key)

# Mute a monitor
dog.mute_monitor(62628)
dog.mute_monitor(62_628)
4 changes: 1 addition & 3 deletions content/en/api/monitors/code_snippets/api-monitor-search.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'rubygems'
require 'dogapi'

api_key = '<YOUR_API_KEY>'
Expand All @@ -7,9 +6,8 @@
dog = Dogapi::Client.new(api_key, app_key)

# Search monitors
dog.search_monitors()
dog.search_monitors

# Examples of possible query parameters:
# dog.search_monitors(query="id:7100311")
# dog.search_monitors(query="title:foo metric:system.core.idle status:Alert")

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'rubygems'
require 'dogapi'

api_key = '<YOUR_API_KEY>'
Expand All @@ -7,4 +6,4 @@
dog = Dogapi::Client.new(api_key, app_key)

# Get all monitor details
dog.get_all_monitors()
dog.get_all_monitors
3 changes: 1 addition & 2 deletions content/en/api/monitors/code_snippets/api-monitor-show.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'rubygems'
require 'dogapi'

api_key = '<YOUR_API_KEY>'
Expand All @@ -7,4 +6,4 @@
dog = Dogapi::Client.new(api_key, app_key)

# Get a monitors's details
dog.get_monitor(91879, :group_states => 'all')
dog.get_monitor(91_879, group_states: 'all')
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'rubygems'
require 'dogapi'

api_key = '<YOUR_API_KEY>'
Expand All @@ -7,4 +6,4 @@
dog = Dogapi::Client.new(api_key, app_key)

# Unmute all alerts
dog.unmute_monitors()
dog.unmute_monitors
5 changes: 2 additions & 3 deletions content/en/api/monitors/code_snippets/api-monitor-unmute.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
require 'rubygems'
require 'dogapi'

api_key = '<YOUR_API_KEY>'
app_key = '<YOUR_APP_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

# Unmute all alerts
dog.unmute_monitor(62628)
# Unmute an alert
dog.unmute_monitor(62_628)
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# This is not yet supported by the Ruby Client for Datadog API
# Consult the curl example
# Consult the curl example
38 changes: 19 additions & 19 deletions content/en/api/monitors/code_snippets/result.api-monitor-create.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
["200", {
"name" => "Bytes received on host0",
"org_id" => 1499,
"tags" => ["app:webserver", "frontend"],
"options" => {
"notify_no_data" => true,
"no_data_timeframe" => 20,
"notify_audit" => false,
"silenced" => {}
},
"state" => {},
"query" => "avg(last_1h):sum:system.net.bytes_rcvd{host:host0} > 100",
"message" => "We may need to add web hosts if this is consistently high.",
"type" => "metric alert",
"id" => 92089,
"multi" => false,
"created" => "2015-12-18T16:34:14.014039+00:00",
"modified" => "2015-12-18T16:34:14.014039+00:00"
}]
['200', {
'name' => 'Bytes received on host0',
'org_id' => 1499,
'tags' => ['app:webserver', 'frontend'],
'options' => {
'notify_no_data' => true,
'no_data_timeframe' => 20,
'notify_audit' => false,
'silenced' => {}
},
'state' => {},
'query' => 'avg(last_1h):sum:system.net.bytes_rcvd{host:host0} > 100',
'message' => 'We may need to add web hosts if this is consistently high.',
'type' => 'metric alert',
'id' => 92_089,
'multi' => false,
'created' => '2015-12-18T16:34:14.014039+00:00',
'modified' => '2015-12-18T16:34:14.014039+00:00'
}]
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
["200", {
"deleted_monitor_id" => 62625
}]
['200', {
'deleted_monitor_id' => 62_625
}]
32 changes: 16 additions & 16 deletions content/en/api/monitors/code_snippets/result.api-monitor-edit.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[
"200", {
"name" => "We may need to add web hosts if this is consistently high.",
"org_id" => 1499,
"options" => {
"notify_no_data" => false, "notify_audit" => false, "silenced" => {}
},
"state" => {},
"query" => "avg(last_1h):sum:system.net.bytes_rcvd{host:host0} > 100",
"message" => "Bytes received on host0",
"type" => "metric alert",
"id" => 91879,
"multi" => false,
"created" => "2015-12-18T16:34:14.014039+00:00",
"modified" => "2015-12-18T18:39:24.391207+00:00"
}
]
'200', {
'name' => 'We may need to add web hosts if this is consistently high.',
'org_id' => 1499,
'options' => {
'notify_no_data' => false, 'notify_audit' => false, 'silenced' => {}
},
'state' => {},
'query' => 'avg(last_1h):sum:system.net.bytes_rcvd{host:host0} > 100',
'message' => 'Bytes received on host0',
'type' => 'metric alert',
'id' => 91_879,
'multi' => false,
'created' => '2015-12-18T16:34:14.014039+00:00',
'modified' => '2015-12-18T18:39:24.391207+00:00'
}
]
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
["200",
{"counts"=>
{"status"=>[{"count"=>1, "name"=>"Alert"}],
"type"=>[{"count"=>1, "name"=>"apm"}]},
"groups"=>
[{"status"=>"Alert",
"last_triggered_ts"=>1540483133,
"group"=>"*",
"monitor_id"=>6797333,
"group_tags"=>["*"],
"last_nodata_ts"=>0,
"monitor_name"=>"Service sample has a high error rate on env:myenv"}],
"metadata"=>{"total_count"=>1, "page_count"=>1, "page"=>0, "per_page"=>30}}]
['200',
{ 'counts' =>
{ 'status' => [{ 'count' => 1, 'name' => 'Alert' }],
'type' => [{ 'count' => 1, 'name' => 'apm' }] },
'groups' =>
[{ 'status' => 'Alert',
'last_triggered_ts' => 1_540_483_133,
'group' => '*',
'monitor_id' => 6_797_333,
'group_tags' => ['*'],
'last_nodata_ts' => 0,
'monitor_name' => 'Service sample has a high error rate on env:myenv' }],
'metadata' => { 'total_count' => 1, 'page_count' => 1, 'page' => 0, 'per_page' => 30 } }]
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[
"200", {
"end" => nil,
"disabled" => false,
"start" => 1412805855,
"active" => true,
"scope" => ["*"],
"id" => 1647
}
]
'200', {
'end' => nil,
'disabled' => false,
'start' => 1_412_805_855,
'active' => true,
'scope' => ['*'],
'id' => 1647
}
]
44 changes: 22 additions & 22 deletions content/en/api/monitors/code_snippets/result.api-monitor-mute.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
[
"200", {
"name" => "avg(last_1h):sum:system.net.bytes_rcvd{host:host0} > 200",
"org_id" => 1499,
"options" => {
"notify_no_data" => false,
"notify_audit" => true,
"timeout_h" => nil,
"silenced" => {
"*" => nil
},
"is_data_sparse" => false,
"renotify_interval" => nil
},
"state" => {},
"query" => "avg(last_1h):sum:system.net.bytes_rcvd{host:host0} > 200",
"message" => "",
"type" => "metric alert",
"id" => 62628,
"created" => "2015-12-18T16:34:14.014039+00:00",
"modified" => "2015-12-18T18:39:24.391207+00:00"
}
]
'200', {
'name' => 'avg(last_1h):sum:system.net.bytes_rcvd{host:host0} > 200',
'org_id' => 1499,
'options' => {
'notify_no_data' => false,
'notify_audit' => true,
'timeout_h' => nil,
'silenced' => {
'*' => nil
},
'is_data_sparse' => false,
'renotify_interval' => nil
},
'state' => {},
'query' => 'avg(last_1h):sum:system.net.bytes_rcvd{host:host0} > 200',
'message' => '',
'type' => 'metric alert',
'id' => 62_628,
'created' => '2015-12-18T16:34:14.014039+00:00',
'modified' => '2015-12-18T18:39:24.391207+00:00'
}
]
52 changes: 26 additions & 26 deletions content/en/api/monitors/code_snippets/result.api-monitor-search.rb
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
["200",
{"counts"=>
{"status"=>[{"count"=>1, "name"=>"Alert"}],
"muted"=>[{"count"=>1, "name"=>false}],
"tag"=>
[{"count"=>1, "name"=>"env:myenv"},
{"count"=>1, "name"=>"service:sample"}],
"type"=>[{"count"=>1, "name"=>"apm"}]},
"monitors"=>
[{"status"=>"Alert",
"scopes"=>["env:myenv", "service:sample"],
"classification"=>"apm",
"creator"=>
{"handle"=>"[email protected]",
"id"=>795042,
"name"=>"Jane"},
"metrics"=>["trace.servlet.request.hits", "trace.servlet.request.errors"],
"notifications"=>
[{"handle"=>"[email protected]", "name"=>"Jane"}],
"last_triggered_ts"=>1540483133,
"id"=>6797333,
"name"=>"Service sample has a high error rate on env:myenv",
"tags"=>["env:myenv", "service:sample"],
"org_id"=>11287,
"type"=>"query alert"}],
"metadata"=>{"total_count"=>1, "page_count"=>1, "page"=>0, "per_page"=>30}}]
['200',
{ 'counts' =>
{ 'status' => [{ 'count' => 1, 'name' => 'Alert' }],
'muted' => [{ 'count' => 1, 'name' => false }],
'tag' =>
[{ 'count' => 1, 'name' => 'env:myenv' },
{ 'count' => 1, 'name' => 'service:sample' }],
'type' => [{ 'count' => 1, 'name' => 'apm' }] },
'monitors' =>
[{ 'status' => 'Alert',
'scopes' => ['env:myenv', 'service:sample'],
'classification' => 'apm',
'creator' =>
{ 'handle' => '[email protected]',
'id' => 795_042,
'name' => 'Jane' },
'metrics' => ['trace.servlet.request.hits', 'trace.servlet.request.errors'],
'notifications' =>
[{ 'handle' => '[email protected]', 'name' => 'Jane' }],
'last_triggered_ts' => 1_540_483_133,
'id' => 6_797_333,
'name' => 'Service sample has a high error rate on env:myenv',
'tags' => ['env:myenv', 'service:sample'],
'org_id' => 11_287,
'type' => 'query alert' }],
'metadata' => { 'total_count' => 1, 'page_count' => 1, 'page' => 0, 'per_page' => 30 } }]
Loading

0 comments on commit 7fcce5f

Please sign in to comment.