Class: Splunk::Pickaxe::Alerts
- Inherits:
-
Objects
- Object
- Objects
- Splunk::Pickaxe::Alerts
show all
- Defined in:
- lib/splunk/pickaxe/objects/alerts.rb
Instance Attribute Summary
Attributes inherited from Objects
#environment, #pickaxe_config, #service
Instance Method Summary
collapse
Methods inherited from Objects
#config, #create, #entity_file_extensions, #entity_file_name, #find, #initialize, #needs_update?, #remove_pickaxe_config, #save, #save_config, #skip?, #sync, #update, #write_to_file
Instance Method Details
#alert_defaults ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/splunk/pickaxe/objects/alerts.rb', line 46
def alert_defaults
{
'pickaxe.environment.in.name' => true,
'action.email.to' => pickaxe_config.emails.join(','),
'cron_schedule' => '0 * * * *',
'is_scheduled' => '1',
'action.email.subject' => 'Splunk Alert: $name$',
'action.email.subject.alert' => 'Splunk Alert: $name$',
'action.email.format' => 'table',
'action.email.inline' => '1',
'action.email.include.view_link' => '1',
'actions' => 'email',
'action.email.sendresults' => '1',
'alert.severity' => '4',
'alert_type' => 'number of events',
'alert_comparator' => 'greater than',
'alert_threshold' => '0',
'dispatch.earliest_time' => '-1h',
'dispatch.latest_time' => 'now',
'alert.track' => '1',
'alert.suppress' => '0'
}
end
|
#entity_dir ⇒ Object
16
17
18
|
# File 'lib/splunk/pickaxe/objects/alerts.rb', line 16
def entity_dir
DIR
end
|
#entity_file_path(splunk_entity) ⇒ Object
20
21
22
23
24
25
|
# File 'lib/splunk/pickaxe/objects/alerts.rb', line 20
def entity_file_path(splunk_entity)
File.join(
pickaxe_config.execution_path, entity_dir,
entity_file_name(splunk_entity)
)
end
|
#name(entity) ⇒ Object
27
28
29
30
31
32
33
34
|
# File 'lib/splunk/pickaxe/objects/alerts.rb', line 27
def name(entity)
if splunk_config(entity)['pickaxe.environment.in.name']
return "#{entity['name']} [#{environment.capitalize}]"
end
entity['name']
end
|
#splunk_config(entity_yaml) ⇒ Object
36
37
38
39
40
41
42
43
44
|
# File 'lib/splunk/pickaxe/objects/alerts.rb', line 36
def splunk_config(entity_yaml)
config = alert_defaults
config.merge! entity_yaml['config']
config
end
|
#splunk_entity_keys ⇒ Object
91
92
93
|
# File 'lib/splunk/pickaxe/objects/alerts.rb', line 91
def splunk_entity_keys
Splunk::Pickaxe::ALERT_KEYS
end
|
#splunk_resource ⇒ Object
12
13
14
|
# File 'lib/splunk/pickaxe/objects/alerts.rb', line 12
def splunk_resource
%w[saved searches]
end
|