wavefront-cli 3.1.3 → 3.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +4 -0
- data/lib/wavefront-cli/alert.rb +13 -10
- data/lib/wavefront-cli/base.rb +3 -1
- data/lib/wavefront-cli/controller.rb +1 -1
- data/lib/wavefront-cli/version.rb +1 -1
- data/spec/spec_helper.rb +16 -0
- data/spec/wavefront-cli/alert_spec.rb +11 -0
- data/spec/wavefront-cli/dashboard_spec.rb +12 -0
- data/spec/wavefront-cli/derivedmetric_spec.rb +10 -0
- data/spec/wavefront-cli/maintenancewindow_spec.rb +11 -0
- data/spec/wavefront-cli/notificant_spec.rb +45 -0
- data/spec/wavefront-cli/resources/imports/alert.json +14 -0
- data/spec/wavefront-cli/resources/imports/dashboard.json +1 -0
- data/spec/wavefront-cli/resources/imports/derivedmetric.json +1 -0
- data/spec/wavefront-cli/resources/imports/notificant.json +1 -0
- data/spec/wavefront-cli/resources/imports/window.json +1 -0
- metadata +14 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a1d06ffcd9e35ee8533ad1f02a13de47b8e9cd8a68f77382da1b3fb672c7b15
|
4
|
+
data.tar.gz: 6a20be8bb474cb3b981c641f9c0667a5e7fd4a0b3bc4e3c7a80872fb6019e40f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ce5c22835ae09b59dcaf3153d54540f9b9548a213344934bedebf030ae80e3a5eb2be35684de13509558b0889570217f162b396304ae92aeaa043bdc261cbbc
|
7
|
+
data.tar.gz: d28b8c665f5d911090acef88922e4157766deb5f90554c7d4f5a19bf0a81c1d5f9f754e5e866e5382b127becf0ef2ea48fb233435b01c030711a028ff411f52e
|
data/HISTORY.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 3.1.4 (02/05/2019)
|
4
|
+
* Fix `alert import` missing tags bug.
|
5
|
+
* Add import and notificants.
|
6
|
+
|
3
7
|
## 3.1.3 (24/04/2019)
|
4
8
|
* Fix `write distribution` bug. Points would be sent, but results
|
5
9
|
could not be displayed, causing a crash unless you used `-q`.
|
data/lib/wavefront-cli/alert.rb
CHANGED
@@ -5,6 +5,11 @@ module WavefrontCli
|
|
5
5
|
# CLI coverage for the v2 'alert' API.
|
6
6
|
#
|
7
7
|
class Alert < WavefrontCli::Base
|
8
|
+
def import_fields
|
9
|
+
%w[name condition minutes target severity displayExpression
|
10
|
+
tags additionalInformation]
|
11
|
+
end
|
12
|
+
|
8
13
|
def do_describe
|
9
14
|
wf.describe(options[:'<id>'], options[:version])
|
10
15
|
end
|
@@ -118,19 +123,17 @@ module WavefrontCli
|
|
118
123
|
# @param raw [Hash] Ruby hash of imported data
|
119
124
|
#
|
120
125
|
def import_to_create(raw)
|
121
|
-
|
122
|
-
|
123
|
-
aggr[k.to_sym] = raw[k]
|
124
|
-
end
|
126
|
+
import_fields.each_with_object({}) { |k, a| a[k.to_sym] = raw[k] }
|
127
|
+
.tap do |ret|
|
125
128
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
+
if raw.key?('resolveAfterMinutes')
|
130
|
+
ret[:resolveMinutes] = raw['resolveAfterMinutes']
|
131
|
+
end
|
129
132
|
|
130
|
-
|
131
|
-
|
133
|
+
if raw.key?('customerTagsWithCounts')
|
134
|
+
ret[:sharedTags] = raw['customerTagsWithCounts'].keys
|
135
|
+
end
|
132
136
|
end
|
133
|
-
ret
|
134
137
|
end
|
135
138
|
end
|
136
139
|
end
|
data/lib/wavefront-cli/base.rb
CHANGED
@@ -464,7 +464,9 @@ module WavefrontCli
|
|
464
464
|
# the ID.
|
465
465
|
#
|
466
466
|
def import_to_create(raw)
|
467
|
-
raw.
|
467
|
+
raw.each_with_object({}) do |(k, v), a|
|
468
|
+
a[k.to_sym] = v unless k == 'id'
|
469
|
+
end
|
468
470
|
end
|
469
471
|
|
470
472
|
# Return a detailed description of one item, if an ID has been
|
@@ -1 +1 @@
|
|
1
|
-
WF_CLI_VERSION = '3.1.
|
1
|
+
WF_CLI_VERSION = '3.1.4'.freeze
|
data/spec/spec_helper.rb
CHANGED
@@ -315,6 +315,22 @@ def tag_tests(cmd, id, bad_id, pth = nil, klass = nil)
|
|
315
315
|
"tag delete #{id} #{BAD_TAG}"])
|
316
316
|
end
|
317
317
|
|
318
|
+
class CliMethodTest < MiniTest::Test
|
319
|
+
attr_reader :wf
|
320
|
+
|
321
|
+
def setup
|
322
|
+
@wf = CliClass.new({})
|
323
|
+
end
|
324
|
+
|
325
|
+
def import_tester(word, have_fields, do_not_have_fields = [])
|
326
|
+
input = JSON.parse(IO.read(RES_DIR + 'imports' + "#{word}.json"))
|
327
|
+
x = wf.import_to_create(input)
|
328
|
+
assert_instance_of(Hash, x)
|
329
|
+
have_fields.each { |f| assert_includes(x.keys, f) }
|
330
|
+
do_not_have_fields.each { |f| refute_includes(x.keys, f) }
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
318
334
|
# Load in a canned query response
|
319
335
|
#
|
320
336
|
def load_query_response
|
@@ -91,3 +91,14 @@ describe "#{word} command" do
|
|
91
91
|
noop_tests(word, id, true)
|
92
92
|
test_list_output(word)
|
93
93
|
end
|
94
|
+
|
95
|
+
CliClass = WavefrontCli::Alert
|
96
|
+
|
97
|
+
class TestAlertMethods < CliMethodTest
|
98
|
+
def test_import_method
|
99
|
+
import_tester(:window,
|
100
|
+
%i[startTimeInSeconds endTimeInSeconds
|
101
|
+
relevantCustomerTags title relevantHostTags],
|
102
|
+
%i[id])
|
103
|
+
end
|
104
|
+
end
|
@@ -93,3 +93,15 @@ describe "#{word} command" do
|
|
93
93
|
tag_tests(word, id, bad_id)
|
94
94
|
test_list_output(word)
|
95
95
|
end
|
96
|
+
|
97
|
+
CliClass = WavefrontCli::Dashboard
|
98
|
+
|
99
|
+
class TestAlertMethods < CliMethodTest
|
100
|
+
def test_import_method
|
101
|
+
import_tester(:dashboard,
|
102
|
+
%i[description name parameters tags url creatorId
|
103
|
+
sections parameterDetails displayDescription
|
104
|
+
acl numCharts],
|
105
|
+
%i[id])
|
106
|
+
end
|
107
|
+
end
|
@@ -79,3 +79,13 @@ describe "#{word} command" do
|
|
79
79
|
headers: JSON_POST_HEADERS }, k)
|
80
80
|
test_list_output(word, k)
|
81
81
|
end
|
82
|
+
|
83
|
+
CliClass = WavefrontCli::DerivedMetric
|
84
|
+
|
85
|
+
class TestDerivedMetricMethods < CliMethodTest
|
86
|
+
def test_import_method
|
87
|
+
import_tester(:derivedmetric,
|
88
|
+
%i[tags minutes name query metricsUsed hostsUsed],
|
89
|
+
%i[id])
|
90
|
+
end
|
91
|
+
end
|
@@ -36,3 +36,14 @@ describe "#{word} command" do
|
|
36
36
|
WavefrontCli::MaintenanceWindow)
|
37
37
|
test_list_output(word, k)
|
38
38
|
end
|
39
|
+
|
40
|
+
CliClass = WavefrontCli::MaintenanceWindow
|
41
|
+
|
42
|
+
class TestMaintenanceWindowMethods < CliMethodTest
|
43
|
+
def test_import_method
|
44
|
+
import_tester(:window,
|
45
|
+
%i[startTimeInSeconds endTimeInSeconds
|
46
|
+
relevantCustomerTags title relevantHostTags],
|
47
|
+
%i[id])
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
id = '9wltLtYXsP8Je2kI'
|
4
|
+
bad_id = '__bad_id__'
|
5
|
+
word = 'notificant'
|
6
|
+
|
7
|
+
require_relative '../spec_helper'
|
8
|
+
require_relative "../../lib/wavefront-cli/#{word}"
|
9
|
+
|
10
|
+
describe "#{word} command" do
|
11
|
+
missing_creds(word, ['list',
|
12
|
+
"describe #{id}",
|
13
|
+
'import file',
|
14
|
+
"delete #{id}",
|
15
|
+
"test #{id}",
|
16
|
+
'search name=pattern'])
|
17
|
+
invalid_ids(word, ["describe #{bad_id}",
|
18
|
+
"delete #{bad_id}",
|
19
|
+
"test #{bad_id}",
|
20
|
+
"update #{bad_id} key=value"])
|
21
|
+
list_tests(word)
|
22
|
+
cmd_to_call(word, "describe #{id}", path: "/api/v2/#{word}/#{id}")
|
23
|
+
|
24
|
+
cmd_to_call(word, "search id=#{id}",
|
25
|
+
method: :post, path: "/api/v2/search/#{word}",
|
26
|
+
body: { limit: 10,
|
27
|
+
offset: 0,
|
28
|
+
query: [{ key: 'id',
|
29
|
+
value: id,
|
30
|
+
matchingMethod: 'EXACT' }],
|
31
|
+
sort: { field: 'id', ascending: true } },
|
32
|
+
headers: JSON_POST_HEADERS)
|
33
|
+
noop_tests(word, id)
|
34
|
+
test_list_output(word)
|
35
|
+
end
|
36
|
+
|
37
|
+
CliClass = WavefrontCli::Notificant
|
38
|
+
|
39
|
+
class TestNotificantMethods < CliMethodTest
|
40
|
+
def test_import_method
|
41
|
+
import_tester(:notificant,
|
42
|
+
%i[method title creatorId triggers template],
|
43
|
+
%i[id])
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"name": "PKS - too many containers not running",
|
3
|
+
"target": "target:9wltLtYXsP8Je2kI",
|
4
|
+
"tags": {
|
5
|
+
"customerTags": [
|
6
|
+
"pks"
|
7
|
+
]
|
8
|
+
},
|
9
|
+
"condition": "sum(ts(pks.kube.pod.container.status.running.gauge)) / (sum(ts(pks.kube.pod.container.status.running.gauge)) + sum(ts(pks.kube.pod.container.status.waiting.gauge)) + sum(ts(pks.kube.pod.container.status.terminated.gauge))) < 0.8",
|
10
|
+
"displayExpression": "sum(ts(pks.kube.pod.container.status.running.gauge)) / (sum(ts(pks.kube.pod.container.status.running.gauge)) + sum(ts(pks.kube.pod.container.status.waiting.gauge)) + sum(ts(pks.kube.pod.container.status.terminated.gauge)))",
|
11
|
+
"minutes": 5,
|
12
|
+
"resolveAfterMinutes": 5,
|
13
|
+
"severity": "SEVERE"
|
14
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"canUserModify":true,"description":"very simple dashboard for CLI tests","hidden":false,"name":"test dashboard","id":"test_dashboard","parameters":{},"tags":{"customerTags":["test.dashboard"]},"customer":"sysdef","url":"test_dashboard","systemOwned":false,"creatorId":"rob@sysdef.xyz","updaterId":"rob@sysdef.xyz","eventFilterType":"BYCHART","sections":[{"name":"Proxy Section","rows":[{"charts":[{"base":0,"units":"Units","name":"New Chart","sources":[{"name":"New Query","query":"ts(\"~proxy.points.2878.*\")","secondaryAxis":false,"scatterPlotSource":"Y","querybuilderEnabled":false,"sourceDescription":""}],"includeObsoleteMetrics":false,"noDefaultEvents":false,"chartAttributes":null,"chartSettings":{"type":"line","autoColumnTags":false},"interpolatePoints":false}],"heightFactor":100}]}],"parameterDetails":{},"displayDescription":false,"displaySectionTableOfContents":true,"displayQueryParameters":false,"chartTitleScalar":0,"eventQuery":"","defaultTimeWindow":"2h","viewsLastDay":0,"viewsLastWeek":0,"viewsLastMonth":0,"acl":{"canView":[],"canModify":["a7d2e651-cec1-4154-a5e8-1946f57ef5b3"]},"createdEpochMillis":1556807658025,"updatedEpochMillis":1556807741557,"deleted":false,"numFavorites":0,"favorite":false,"numCharts":1,"orphan":false}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"created":1551211178661,"name":"example derived metric","id":"1551211178661","query":"aliasMetric(ts(\"gem.downloads.wavefront-cli\"), \"downloads.cli\")","minutes":5,"tags":{"customerTags":["cli","test"]},"status":["ACTIVE"],"updated":1551211178661,"includeObsoleteMetrics":false,"processRateMinutes":1,"lastProcessedMillis":1556810917164,"updateUserId":"rob@sysdef.xyz","additionalInformation":"example derived metric for CLI testing","inTrash":false,"queryFailing":false,"createUserId":"rob@sysdef.xyz","pointsScannedAtLastQuery":1,"metricsUsed":["gem.downloads.wavefront-cli"],"hostsUsed":["cube-cron"],"creatorId":"rob@sysdef.xyz","updaterId":"rob@sysdef.xyz","createdEpochMillis":1551211178661,"updatedEpochMillis":1551211178661,"queryQBEnabled":false,"deleted":false}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"contentType":"","description":"testing CLI","method":"EMAIL","id":"9wltLtYXsP8Je2kI","title":"test target","customerId":"sysdef","creatorId":"rob@sysdef.xyz","updaterId":"rob@sysdef.xyz","createdEpochMillis":1556801433941,"updatedEpochMillis":1556810420754,"template":"just testing","triggers":["ALERT_OPENED","ALERT_RESOLVED"],"recipient":"ops@example.com","customHttpHeaders":{},"emailSubject":"[{{#severity}}{{{severity}}}{{/severity}}] {{{name}}} ({{{notificationId}}})","isHtmlContent":true}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"reason":"CLI testing","customerId":"sysdef","startTimeInSeconds":1538848800,"endTimeInSeconds":1538849400,"relevantCustomerTags":[],"title":"test_1","relevantHostTags":["physical"],"id":"1538845614480","creatorId":"rob@sysdef.xyz","updaterId":"rob@sysdef.xyz","createdEpochMillis":1538845614480,"updatedEpochMillis":1538845614480,"eventName":"Maintenance Window: test_1","runningState":"ENDED","sortAttr":1000000}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wavefront-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Fisher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docopt
|
@@ -293,6 +293,7 @@ files:
|
|
293
293
|
- spec/wavefront-cli/maintenancewindow_spec.rb
|
294
294
|
- spec/wavefront-cli/message_spec.rb
|
295
295
|
- spec/wavefront-cli/metric_spec.rb
|
296
|
+
- spec/wavefront-cli/notificant_spec.rb
|
296
297
|
- spec/wavefront-cli/opt_handler_spec.rb
|
297
298
|
- spec/wavefront-cli/output/csv/query_spec.rb
|
298
299
|
- spec/wavefront-cli/output/csv_spec.rb
|
@@ -311,6 +312,11 @@ files:
|
|
311
312
|
- spec/wavefront-cli/resources/display/user-human-long
|
312
313
|
- spec/wavefront-cli/resources/display/user-human-long-no_sep
|
313
314
|
- spec/wavefront-cli/resources/display/user-input.json
|
315
|
+
- spec/wavefront-cli/resources/imports/alert.json
|
316
|
+
- spec/wavefront-cli/resources/imports/dashboard.json
|
317
|
+
- spec/wavefront-cli/resources/imports/derivedmetric.json
|
318
|
+
- spec/wavefront-cli/resources/imports/notificant.json
|
319
|
+
- spec/wavefront-cli/resources/imports/window.json
|
314
320
|
- spec/wavefront-cli/resources/malformed.conf
|
315
321
|
- spec/wavefront-cli/resources/responses/README.md
|
316
322
|
- spec/wavefront-cli/resources/responses/alert-list.json
|
@@ -401,6 +407,7 @@ test_files:
|
|
401
407
|
- spec/wavefront-cli/maintenancewindow_spec.rb
|
402
408
|
- spec/wavefront-cli/message_spec.rb
|
403
409
|
- spec/wavefront-cli/metric_spec.rb
|
410
|
+
- spec/wavefront-cli/notificant_spec.rb
|
404
411
|
- spec/wavefront-cli/opt_handler_spec.rb
|
405
412
|
- spec/wavefront-cli/output/csv/query_spec.rb
|
406
413
|
- spec/wavefront-cli/output/csv_spec.rb
|
@@ -419,6 +426,11 @@ test_files:
|
|
419
426
|
- spec/wavefront-cli/resources/display/user-human-long
|
420
427
|
- spec/wavefront-cli/resources/display/user-human-long-no_sep
|
421
428
|
- spec/wavefront-cli/resources/display/user-input.json
|
429
|
+
- spec/wavefront-cli/resources/imports/alert.json
|
430
|
+
- spec/wavefront-cli/resources/imports/dashboard.json
|
431
|
+
- spec/wavefront-cli/resources/imports/derivedmetric.json
|
432
|
+
- spec/wavefront-cli/resources/imports/notificant.json
|
433
|
+
- spec/wavefront-cli/resources/imports/window.json
|
422
434
|
- spec/wavefront-cli/resources/malformed.conf
|
423
435
|
- spec/wavefront-cli/resources/responses/README.md
|
424
436
|
- spec/wavefront-cli/resources/responses/alert-list.json
|