Class: Splunk::Pickaxe::Reports

Inherits:
Objects
  • Object
show all
Defined in:
lib/splunk/pickaxe/objects/reports.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?, #save, #save_config, #skip?, #sync, #update

Constructor Details

This class inherits a constructor from Splunk::Pickaxe::Objects

Instance Method Details

#entity_dirObject



15
16
17
# File 'lib/splunk/pickaxe/objects/reports.rb', line 15

def entity_dir
  DIR
end

#entity_file_path(splunk_entity) ⇒ Object



19
20
21
22
23
24
# File 'lib/splunk/pickaxe/objects/reports.rb', line 19

def entity_file_path(splunk_entity)
  File.join(
    pickaxe_config.execution_path, entity_dir,
    entity_file_name(splunk_entity)
  )
end

#name(entity) ⇒ Object



26
27
28
29
# File 'lib/splunk/pickaxe/objects/reports.rb', line 26

def name(entity)
  # The report name contains the environment name
  "#{entity['name']} [#{environment.capitalize}]"
end

#report_defaultsObject



41
42
43
44
45
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
# File 'lib/splunk/pickaxe/objects/reports.rb', line 41

def report_defaults
  {
    # Who to email
    'action.email.to' => pickaxe_config.emails.join(','),

    # How often to run alert (every hour)
    'cron_schedule' => '0 * * * *',
    'is_scheduled' => '1',

    # Email subject
    'action.email.subject' => 'Splunk Report: $name$',
    'action.email.subject.alert' => 'Splunk Report: $name$',

    # Email result formatting (inline results, table format, include alert link)
    'action.email.format' => 'table',
    'action.email.inline' => '1',
    'action.email.include.view_link' => '1',

    # Send an email
    'actions' => 'email',
    'action.email.sendresults' => '1',

    # This is a report so always send it
    'alert_type' => 'always',

    # The time bounds for alert search (1 hour)
    'dispatch.earliest_time' => '-1h',
    'dispatch.latest_time' => 'now'
  }
end

#splunk_config(entity_yaml) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/splunk/pickaxe/objects/reports.rb', line 31

def splunk_config(entity_yaml)
  # Include default values
  config = report_defaults

  # Override defaults with any config provided in yaml
  config.merge! entity_yaml['config']

  config
end

#splunk_entity_keysObject



72
73
74
# File 'lib/splunk/pickaxe/objects/reports.rb', line 72

def splunk_entity_keys
  Splunk::Pickaxe::REPORT_KEYS
end

#splunk_resourceObject



11
12
13
# File 'lib/splunk/pickaxe/objects/reports.rb', line 11

def splunk_resource
  %w[saved searches]
end