splunk-pickaxe 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +63 -7
- data/lib/splunk/pickaxe.rb +2 -2
- data/lib/splunk/pickaxe/cli.rb +4 -3
- data/lib/splunk/pickaxe/config.rb +21 -11
- data/lib/splunk/pickaxe/objects/alerts.rb +1 -1
- data/lib/splunk/pickaxe/objects/reports.rb +1 -1
- data/lib/splunk/pickaxe/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62373e733e325efa667b008d470ab7328a54d0b2
|
4
|
+
data.tar.gz: a550e3b13ef3c880242d007235ee5938f8a38b4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0c54ba54629fd768b88b648ce7a6dc696cacdb78e3080287a8a06b483c9bb40d411c4161d75bb4f549024f183b0689bd14aaa97172e471ef9223ceaaa12c903
|
7
|
+
data.tar.gz: 7f53828e1077ffca6f0b3f197a216d43f028c7d9dffc1f2efddb415409d4776942b204fbd09db1a87e212dabd5bd58347c6a41f54cd80ddee7c1088cdd71ea56
|
data/README.md
CHANGED
@@ -43,7 +43,7 @@ Add some Splunk objects; see [example repo](example-repo) or below for manually
|
|
43
43
|
defining Splunk objects. Alternatively, to retrieve _all_ Splunk objects from
|
44
44
|
an environment, run:
|
45
45
|
|
46
|
-
pickaxe
|
46
|
+
pickaxe save ENVIRONMENT_NAME
|
47
47
|
|
48
48
|
Where `ENVIRONMENT_NAME` is the name of one of the environments configured in
|
49
49
|
your `.pickaxe.yml`. These map to different Splunk instances.
|
@@ -204,13 +204,69 @@ environments.
|
|
204
204
|
Config
|
205
205
|
------
|
206
206
|
|
207
|
-
The `.pickaxe.yml` file contains the config for your Splunk resources
|
207
|
+
The `.pickaxe.yml` file contains the config for your Splunk resources and should
|
208
|
+
look like this,
|
209
|
+
|
210
|
+
```yaml
|
211
|
+
namespace:
|
212
|
+
# The application name to create the splunk dashboards, alerts, reports, tags, etc...
|
213
|
+
app: my_splunk_app
|
214
|
+
|
215
|
+
environments:
|
216
|
+
dev:
|
217
|
+
url: https://logs-api.dev.my-splunk.com
|
218
|
+
staging:
|
219
|
+
url: https://logs-api.staging.my-splunk.com
|
220
|
+
prod:
|
221
|
+
url: https://logs-api.prod.my-splunk.com
|
222
|
+
# Optional and will default to the root emails config
|
223
|
+
emails:
|
224
|
+
- my.email@domain.com
|
225
|
+
|
226
|
+
# Used for any environments that don't specify emails config
|
227
|
+
emails:
|
228
|
+
- my.email@domain.com
|
229
|
+
```
|
230
|
+
|
231
|
+
### Backwards Compatibility
|
232
|
+
|
233
|
+
In previous version the config used to look like this,
|
234
|
+
|
235
|
+
```yaml
|
236
|
+
namespace:
|
237
|
+
app: my_splunk_app
|
238
|
+
|
239
|
+
environments:
|
240
|
+
dev: https://logs-api.dev.my-splunk.com
|
241
|
+
staging: https://logs-api.staging.my-splunk.com
|
242
|
+
prod: https://logs-api.prod.my-splunk.com
|
243
|
+
|
244
|
+
emails:
|
245
|
+
- my.email@domain.com
|
246
|
+
```
|
247
|
+
|
248
|
+
Specifically the value for each environment was a String that was the URL for
|
249
|
+
the Splunk API. The new config format has the environment value as a Hash like
|
250
|
+
this,
|
251
|
+
|
252
|
+
```yaml
|
253
|
+
namespace:
|
254
|
+
app: my_splunk_app
|
255
|
+
|
256
|
+
environments:
|
257
|
+
dev:
|
258
|
+
url: https://logs-api.dev.my-splunk.com
|
259
|
+
staging:
|
260
|
+
url: https://logs-api.staging.my-splunk.com
|
261
|
+
prod:
|
262
|
+
url: https://logs-api.prod.my-splunk.com
|
263
|
+
|
264
|
+
emails:
|
265
|
+
- my.email@domain.com
|
266
|
+
```
|
208
267
|
|
209
|
-
|
210
|
-
|
211
|
-
* `app`: The name of your Splunk application to deploy objects to
|
212
|
-
* `sharing`: The sharing settings for the Splunk resources (default=`app`)
|
213
|
-
* `emails`: An array of emails used for all reports and alerts (default=`[]`)
|
268
|
+
The previous format is still supported but deprecated and will be removed in the
|
269
|
+
future.
|
214
270
|
|
215
271
|
Contributing
|
216
272
|
------------
|
data/lib/splunk/pickaxe.rb
CHANGED
@@ -9,11 +9,11 @@ require 'splunk/pickaxe/cookie_proxy'
|
|
9
9
|
module Splunk
|
10
10
|
module Pickaxe
|
11
11
|
def self.configure(environment, username, password, args)
|
12
|
-
config = Config.load(args.fetch(:repo_path, Dir.getwd))
|
12
|
+
config = Config.load(environment, args.fetch(:repo_path, Dir.getwd))
|
13
13
|
|
14
14
|
raise "Unknown environment [#{environment}]. Expected #{config.environments.keys}" unless config.environments.key?(environment)
|
15
15
|
|
16
|
-
uri = URI(config.
|
16
|
+
uri = URI(config.url)
|
17
17
|
|
18
18
|
puts "Connecting to splunk [#{uri}]"
|
19
19
|
service = Splunk.connect(
|
data/lib/splunk/pickaxe/cli.rb
CHANGED
@@ -34,9 +34,10 @@ module Splunk
|
|
34
34
|
f.puts 'namespace:'
|
35
35
|
f.puts ' app: TODO'
|
36
36
|
f.puts 'environments:'
|
37
|
-
f.puts ' MY_ENV:
|
38
|
-
f.puts '
|
39
|
-
f.puts '
|
37
|
+
f.puts ' MY_ENV:'
|
38
|
+
f.puts ' url: SPLUNK_API_URL'
|
39
|
+
f.puts ' emails:'
|
40
|
+
f.puts ' - my.email@domain.com'
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
@@ -16,27 +16,37 @@ module Splunk
|
|
16
16
|
'emails' => [],
|
17
17
|
}.freeze
|
18
18
|
|
19
|
-
def self.load(execution_path)
|
19
|
+
def self.load(environment, execution_path)
|
20
20
|
config_path = File.join(execution_path, CONFIG_FILE)
|
21
21
|
raise "Unable to load config file [#{config_path}]" unless File.exist? config_path
|
22
22
|
|
23
23
|
# Merges DEFAULTS with yaml config
|
24
|
-
Config.new deep_merge(DEFAULTS, YAML.load_file(config_path)), execution_path
|
24
|
+
Config.new deep_merge(DEFAULTS, YAML.load_file(config_path)), environment, execution_path
|
25
25
|
end
|
26
26
|
|
27
|
-
attr_reader :
|
27
|
+
attr_reader :namespace, :environment, :execution_path, :emails, :url
|
28
28
|
|
29
|
-
def initialize(config, execution_path)
|
30
|
-
unless config['namespace'].key?
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
raise "Must have at least one environment" unless config['environments'].size > 0
|
29
|
+
def initialize(config, environment, execution_path)
|
30
|
+
raise "Config must have a 'namespace / app' config" unless config['namespace'].key?('app')
|
31
|
+
raise "Environment [#{environment}] is not configured" unless config['environments'].has_key?(environment)
|
35
32
|
|
36
|
-
@config = config
|
37
33
|
@execution_path = execution_path
|
34
|
+
@environment = environment
|
38
35
|
|
39
|
-
|
36
|
+
env_config = config['environments'][environment]
|
37
|
+
|
38
|
+
if env_config.is_a?(String)
|
39
|
+
# Support this for now to be passive but we will remove it later
|
40
|
+
puts "Your .pickaxe.yml is using a deprecated config format. Check https://github.com/cerner/splunk-pickaxe#backwards-compatibility for details"
|
41
|
+
@emails = config['emails']
|
42
|
+
@url = env_config
|
43
|
+
elsif env_config.is_a?(Hash)
|
44
|
+
raise "url config is required for environment [#{environment}]" unless env_config.has_key?('url')
|
45
|
+
@url = env_config['url']
|
46
|
+
@emails = env_config.has_key?('emails') ? env_config['emails'] : config['emails']
|
47
|
+
else
|
48
|
+
raise "Unexepcted value for environment [#{environment}] config. Expected String or Hash, saw #{config['environments'][environment]}"
|
49
|
+
end
|
40
50
|
|
41
51
|
# Convert namespace config hash to hash with symbols for keys
|
42
52
|
namespace_config = config['namespace'].each_with_object({}) { |(k, v), memo| memo[k.to_sym] = v; }
|
@@ -42,7 +42,7 @@ module Splunk
|
|
42
42
|
def alert_defaults
|
43
43
|
{
|
44
44
|
# Who to email
|
45
|
-
'action.email.to' => pickaxe_config.
|
45
|
+
'action.email.to' => pickaxe_config.emails.join(','),
|
46
46
|
|
47
47
|
# How often to run alert (every hour)
|
48
48
|
'cron_schedule' => '0 * * * *',
|
@@ -41,7 +41,7 @@ module Splunk
|
|
41
41
|
def report_defaults
|
42
42
|
{
|
43
43
|
# Who to email
|
44
|
-
'action.email.to' => pickaxe_config.
|
44
|
+
'action.email.to' => pickaxe_config.emails.join(','),
|
45
45
|
|
46
46
|
# How often to run alert (every hour)
|
47
47
|
'cron_schedule' => '0 * * * *',
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: splunk-pickaxe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Baugher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: splunk-sdk-ruby
|