wavefront-client 1.1.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NWEzZDdlMjEzZTdhZjI0MGUzZTE0NDNhOWM2ZmUwMGViNmZjMWVhNQ==
4
+ ZmVmOGZlMjkwODkxMTk3YjBiN2QwZDZiNmEyZTlkYjgyZTY1ZjQ1NQ==
5
5
  data.tar.gz: !binary |-
6
- OTI3NDgzODVhZTUzNDBiNGEwNDgyNDZhZDY4MWRkZmIzNWNiYWJkMw==
6
+ ZTYzNTFiZTNiOWFiMmZmYjA5ZDM0NGE5Y2EzNGNhZTkxNmE2Yjg5ZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YTY2YTMyODdkYjE3MWM3NDc1ODUyZjY0OTdjNWUwZGQ1YzQ2MDYxNWViMDJm
10
- OWE0ZjAzZGY4YzZkNzQ3Y2QzNDBiZTA2MmQ0ZjA5NWY3NzM0NWE1Y2UzYzMz
11
- MDJmYTM2ZjQ2NzI0OTM0Y2E2MDNjZGJkMDRjZjIyZDE3YjYwNDE=
9
+ NzJhZmUzN2IyYmVjZjNjNmQ1ZjU1MWJlMzE5ZGRmY2RmOTY4MGZiNTA1NjBl
10
+ Y2Y2MzMwMTkxOWVjMTExNWJmZjQ0NTIxYzEwOWE0ZTY1N2RjZTViZDA2NTc2
11
+ MjBhOGQ5YzBhZTNhOTA0ZWU2ZDg3MTUzYmIxNGE5MDM3MjZmMjM=
12
12
  data.tar.gz: !binary |-
13
- ODM5ZmZkNzFjNzgzMzQ5NWZjMzhkZWJkYmIxMzQ2OGQxMGExNDc1MDUwZDZh
14
- ZWZiZGQwYmE4M2YyNzUzMWMxM2FiYTRiNTM0MjU5OTFjZTNkOTZkZTBjMzBi
15
- MjQ2MjllYmU1ZWVmYjM0YWU1YzNhOTk2MjExM2U5MmRjMjg5MTQ=
13
+ YzFkNzhkYjFiYTZlZDlkNjc2ZWU5OTcwNTNkYzY5YzJiMjcxY2NjMjcyZjlh
14
+ YjY4MjNlYzJjY2I0MjgwN2NjZGQ3ZGExODk3YzI4NDBiNDQ0NTgwMjUzNGFi
15
+ ZGNiMGZjMWNkY2M3ZjBiZjI5MDYxNjg3NDI5OTkzMmM3YjA5OTk=
data/bin/wavefront-client CHANGED
@@ -20,8 +20,11 @@ require 'json'
20
20
 
21
21
  @opts = Slop.parse(strict: true) do
22
22
  banner 'Usage: wavefront-client QUERY (OPTIONS)'
23
+ on 'd', 'days', 'Query granularity of days'
24
+ on 'D', 'debug', 'Enable debug mode'
23
25
  on 'm', 'minutes', 'Query granularity of minutes'
24
- on 'h', 'hours', 'Query granularity of hours'
26
+ on 'H', 'hours', 'Query granularity of hours'
27
+ on 'E', 'endpoint=', 'Connect to alternative cluster endpoint', default: Wavefront::Client::DEFAULT_HOST.to_s
25
28
  on 'S', 'seconds', 'Query granularity of seconds'
26
29
  on 's', 'start=', 'Time in UNIX epoch seconds to begin the query from'
27
30
  on 't', 'token=', 'Wavefront authentication token'
@@ -43,8 +46,10 @@ elsif @opts.hours?
43
46
  granularity = 'h'
44
47
  elsif @opts.seconds?
45
48
  granularity = 's'
49
+ elsif @opts.days?
50
+ granularity = 'd'
46
51
  else
47
- puts "You must specify a granularity of either --seconds, --minutes or --hours. See --help for more information."
52
+ puts "You must specify a granularity of either --seconds, --minutes --hours or --days. See --help for more information."
48
53
  exit 1
49
54
  end
50
55
 
@@ -65,7 +70,7 @@ if @opts[:end]
65
70
  options[:end_time] = Time.at(@opts[:end].to_i)
66
71
  end
67
72
 
68
- wave = Wavefront::Client.new(@opts[:token])
73
+ wave = Wavefront::Client.new(@opts[:token], @opts[:endpoint], @opts[:debug])
69
74
  case options[:response_format]
70
75
  when :raw
71
76
  puts wave.query(query, granularity, options)
@@ -16,13 +16,14 @@ See the License for the specific language governing permissions and
16
16
 
17
17
  require "wavefront/client/version"
18
18
  require "wavefront/exception"
19
+ require "wavefront/constants"
19
20
  require 'rest_client'
20
21
  require 'uri'
21
22
  require 'logger'
22
23
 
23
24
  module Wavefront
24
25
  class Alerting
25
- DEFAULT_HOST = 'metrics.wavefront.com'
26
+ include Wavefront::Constants
26
27
  DEFAULT_PATH = '/api/alert/'
27
28
 
28
29
  attr_reader :token
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
15
15
  =end
16
16
 
17
17
  require "wavefront/client/version"
18
- require "wavefront/client/constants"
18
+ require "wavefront/constants"
19
19
  require "wavefront/exception"
20
20
  require "wavefront/response"
21
21
  require 'rest_client'
@@ -24,13 +24,9 @@ require 'logger'
24
24
 
25
25
  module Wavefront
26
26
  class Client
27
- DEFAULT_PERIOD_SECONDS = 600
27
+
28
+ include Wavefront::Constants
28
29
  DEFAULT_PATH = '/chart/api'
29
- DEFAULT_FORMAT = :raw
30
- DEFAULT_PREFIX_LENGTH = 1
31
- DEFAULT_STRICT = true
32
- FORMATS = [ :raw, :ruby, :graphite, :highcharts ]
33
- GRANULARITIES = %w( s m h d )
34
30
 
35
31
  attr_reader :headers, :base_uri
36
32
 
@@ -16,6 +16,6 @@ See the License for the specific language governing permissions and
16
16
 
17
17
  module Wavefront
18
18
  class Client
19
- VERSION = "1.1.1"
19
+ VERSION = "2.0.0"
20
20
  end
21
21
  end
@@ -14,4 +14,14 @@ See the License for the specific language governing permissions and
14
14
 
15
15
  =end
16
16
 
17
- DEFAULT_HOST = 'metrics.wavefront.com'
17
+ module Wavefront
18
+ module Constants
19
+ DEFAULT_HOST = 'metrics.wavefront.com'
20
+ DEFAULT_PERIOD_SECONDS = 600
21
+ DEFAULT_FORMAT = :raw
22
+ DEFAULT_PREFIX_LENGTH = 1
23
+ DEFAULT_STRICT = true
24
+ FORMATS = [ :raw, :ruby, :graphite, :highcharts ]
25
+ GRANULARITIES = %w( s m h d )
26
+ end
27
+ end
@@ -3,6 +3,7 @@ require_relative 'exception'
3
3
  require 'rest_client'
4
4
  require 'uri'
5
5
  require 'logger'
6
+ require 'wavefront/constants'
6
7
  #
7
8
  # Add basic support to cover Wavefront's events API. I have followed
8
9
  # the standards and conventions established in the files already in
@@ -17,7 +18,7 @@ module Wavefront
17
18
  # the event', 's' as 'start time for the event' and so-on.
18
19
  #
19
20
  class Events
20
- DEFAULT_HOST = 'metrics.wavefront.com'
21
+ include Wavefront::Constants
21
22
  DEFAULT_PATH = '/api/events/'
22
23
 
23
24
  attr_reader :token
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
15
15
  =end
16
16
 
17
17
  require "wavefront/client/version"
18
- require "wavefront/client/constants"
18
+ require "wavefront/constants"
19
19
  require "wavefront/exception"
20
20
  require 'rest_client'
21
21
  require 'uri'
@@ -23,6 +23,7 @@ require 'logger'
23
23
 
24
24
  module Wavefront
25
25
  class Metadata
26
+ include Wavefront::Constants
26
27
  DEFAULT_PATH = '/api/manage/source/'
27
28
 
28
29
  attr_reader :headers, :base_uri
@@ -33,15 +34,21 @@ module Wavefront
33
34
  debug(debug)
34
35
  end
35
36
 
36
- def get_tags(hostname='')
37
+ def get_tags(hostname='', limit=100)
37
38
  uri = @base_uri
38
39
 
39
40
  unless hostname.empty?
40
41
  uri = URI.join(@base_uri.to_s, hostname)
41
42
  end
43
+
44
+ if limit > 10000
45
+ limit = 10000
46
+ end
47
+
48
+ args = {:params => {:limit => limit}}.merge(@headers)
42
49
 
43
50
  begin
44
- response = RestClient.get(uri.to_s, @headers)
51
+ response = RestClient.get(uri.to_s, args)
45
52
  rescue RestClient::ResourceNotFound
46
53
  # If a 404 is returned, we return an empty JSON as this is the expected behaviour for untagged hosts
47
54
  response = {}
@@ -16,11 +16,13 @@ See the License for the specific language governing permissions and
16
16
 
17
17
  require "wavefront/client/version"
18
18
  require "wavefront/exception"
19
+ require "wavefront/constants"
19
20
  require 'uri'
20
21
  require 'socket'
21
22
 
22
23
  module Wavefront
23
24
  class Writer
25
+ include Wavefront::Constants
24
26
  DEFAULT_AGENT_HOST = 'localhost'
25
27
  DEFAULT_PORT = 2878
26
28
  DEFAULT_HOSTNAME = %x{hostname -f}.chomp
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wavefront-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Pointer
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-12-07 00:00:00.000000000 Z
15
+ date: 2016-02-03 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: bundler
@@ -115,8 +115,8 @@ files:
115
115
  - bin/wavefront-client
116
116
  - lib/wavefront/alerting.rb
117
117
  - lib/wavefront/client.rb
118
- - lib/wavefront/client/constants.rb
119
118
  - lib/wavefront/client/version.rb
119
+ - lib/wavefront/constants.rb
120
120
  - lib/wavefront/events.rb
121
121
  - lib/wavefront/exception.rb
122
122
  - lib/wavefront/metadata.rb