echo_cli 0.6.29 → 0.6.31

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26bf693fbc018a0624ee60571d06ce3c33bfa07d
4
- data.tar.gz: 95192e063314016954d2061a219e86584d3f9de5
3
+ metadata.gz: b439b9468fe852290283224be9c6fe0532ed8a5f
4
+ data.tar.gz: 91ab851d7dc0a1df8d3bf00727a9bcf6e6534932
5
5
  SHA512:
6
- metadata.gz: a92e5e51809a070142ae9a4f7e2066b86c8d7470eab7dfd1f22de3ace02709fc1b141bd585e39fad72601dee5551e172e715eb135df4e09e2aa7b4ca43495915
7
- data.tar.gz: 92e19d071b2a66ce36b2594d126410b9d9f34f797b908f3904c9c3e7ebc54ed1b9eb6c7fd39c4fb6ebde73b1f92845396133a1af51d0168176761f1b47600c84
6
+ metadata.gz: 29ffc04dc9219323aac4f00e4ea509932890272bb8d08300b0e6f69a95468e084d5e6ff8e3ab3bd8855d1dfd9fddf3b8fa18a3c0317423beb4356bb968799371
7
+ data.tar.gz: dce30d422c33bc587e5716ea593e7b8e5f3de433c0fc481a9e3044a62dbf440488265fa935bc16df1acd37f1dda0b86a0bf30cd86b87ce673e1afff5e9199892
data/README.md CHANGED
@@ -1,7 +1,33 @@
1
1
  # Echo_cli
2
2
 
3
+ #### Table of Contents
4
+ * [Installation](https://github.allstate.com/CompoZedPlatform/echo_cli#installation)
5
+ * [Quick Start](https://github.allstate.com/CompoZedPlatform/echo_cli#quick-start)
6
+ * [Long Start](https://github.allstate.com/CompoZedPlatform/echo_cli#long-start)
7
+ * [Metrics Explained](https://github.allstate.com/CompoZedPlatform/echo_cli#metrics-explained)
8
+ * [Posting Data to Echo](https://github.allstate.com/CompoZedPlatform/echo_cli#posting-data-to-echo)
9
+ * [Usage](https://github.allstate.com/CompoZedPlatform/echo_cli#usage)
10
+ * [Commands](https://github.allstate.com/CompoZedPlatform/echo_cli#commands)
11
+ * [Development](https://github.allstate.com/CompoZedPlatform/echo_cli#development)
12
+ * [Testing](https://github.allstate.com/CompoZedPlatform/echo_cli#testing)
13
+ * [Contributing](https://github.allstate.com/CompoZedPlatform/echo_cli#contributing)
14
+ * [License](https://github.allstate.com/CompoZedPlatform/echo_cli#license)
15
+
3
16
  ## Installation
4
17
 
18
+ ### Quick Start
19
+ ***NOTE: requires rbenv and git already installed***
20
+
21
+ ```bash
22
+ $ export ECHO_CLI_HOST = {ECHO_IP}
23
+ $ sudo gem install echo_cli
24
+ $ echo_cli
25
+ ```
26
+
27
+ Replace {ECHO_IP} with Echo's instance IP address (e.g. 10.100.100.100)
28
+
29
+ ### Long Start
30
+
5
31
  Ensure git and rbenv (or rvm, NOT both) are installed on your machine:
6
32
 
7
33
  Verify the 'rbenv' and 'git' commands are found
@@ -56,19 +82,19 @@ Finally, export the environment variable "ECHO_CLI_HOST", and set this value to
56
82
  The Echo server receives data in text format with the following syntax:
57
83
 
58
84
  ```
59
- <Application_name>.<tag1>.<tag2>…<tag(n)>:<value>|<metric type>
85
+ <Application_name>.<tag1>.<tag2>…<tag(n)>:<value>|<metric_type>
60
86
  ```
61
87
 
62
- ### Application name
88
+ #### Application name
63
89
  This is the name of the application that you are sending the data from. It is what you are measuring. It must be a text string.
64
90
 
65
- ### Tag1 – tag(n)
91
+ #### Tag1 – tag(n)
66
92
  The database works off of tags to identify metrics. What ever tags you use will be what identifies your measurement in the database and in the front end. We recommend that you use two to three tags for each measurement type.
67
93
 
68
- ### Value
94
+ #### Value
69
95
  This is a numeric value that is representative of the metric being tracked. It must be a number in text format.
70
96
 
71
- ### Metric type
97
+ #### Metric type
72
98
  A special flag that tells the Echo server what type of data you are recording. The server will perform different calculations depending on this value. There are three types of flags that are currently supported by Echo:
73
99
  * **c**: (Count) – Tells the Echo server that the values represent a count.
74
100
  * **ms**: (Time Duration) – Tells the server that values represent a duration of time. The number is recorded in milliseconds and is to be transmitted as a number, not a time stamp. Note: in practice, ms does not have to represent time. It can represent any number. The system does not care, it only records.
@@ -152,7 +178,7 @@ The previous example would post the application name 'sample' with tags 'post' a
152
178
 
153
179
  #### query
154
180
  ```bash
155
- $ echo_cli query '<metric>' <time_start> <time_end>
181
+ $ echo_cli query '<metric>' {time_start} {time_end} {-n}
156
182
  ```
157
183
  Parameters:
158
184
 
@@ -162,6 +188,8 @@ Parameters:
162
188
 
163
189
  `{time_end}`: (optional) the end of the range you are attempting to query in seconds from January 1, 1970 (epoch time)
164
190
 
191
+ `{-n}`: (optional) return all datapoints upon a successful query, including null datapoints
192
+
165
193
  See: https://graphite-api.readthedocs.io/en/latest/api.html#from-until for possible time_start and time_end formats.
166
194
 
167
195
  The default timestamp query range begins 15 minutes prior to the current time, to now.
@@ -172,7 +200,7 @@ $ echo_cli query 'sample.query.here:1|c' 1492464745 1492465045
172
200
  ```
173
201
  The previous example will query Graphite with the application name 'sample' and tags 'query' and 'here' between the times of '1492464745' and '1492465045'.
174
202
 
175
- ## Development
203
+ ## Development (Echo Devs Only)
176
204
 
177
205
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
178
206
 
@@ -196,7 +224,7 @@ $ rake release
196
224
  $ gem install echo_cli
197
225
  ```
198
226
 
199
- #### Testing
227
+ ### Testing
200
228
  ```bash
201
229
  $ gem install webmock
202
230
  $ ruby test/echo_cli_test.rb
data/lib/echo_cli/cli.rb CHANGED
@@ -72,10 +72,12 @@ module Echo_cli
72
72
  helper.unset_envs()
73
73
  end
74
74
 
75
- desc "query", "Query metrics on Echo. Use \"echo_cli query '<metric>' {time_start} {time_end}\""
75
+ desc "query", "Query metrics on Echo. Use \"echo_cli query '<metric>' {time_start} {time_end} {-n}\""
76
+
77
+ option :n
76
78
 
77
79
  long_desc <<-LONGDESC
78
- Query metrics on Echo. Use \"echo_cli query '<metric>' {time_start} {time_end}\"
80
+ Query metrics on Echo. Use \"echo_cli query '<metric>' {time_start} {time_end} {-n}\"
79
81
 
80
82
  `echo_cli query` will query a metric directly from Echo's Graphite server instance.
81
83
 
@@ -89,6 +91,10 @@ module Echo_cli
89
91
 
90
92
  Ensure the environment variable 'ECHO_CLI_HOST' is set to the correct IP.
91
93
 
94
+ By default, the CLI removes any null datapoints from the returned query, so an empty dataset returned upon a successful query would suggest that either not datapoints were found in the query range, or that the metric was spelled incorrectly.
95
+
96
+ The -n option can be used to print all of the datapoints - including null datapoints - resulting from a query.
97
+
92
98
  > $ echo_cli query 'example.query:1|c' {1492186212} {-5min}
93
99
  LONGDESC
94
100
 
@@ -108,7 +114,11 @@ module Echo_cli
108
114
  puts "\nResponse Body:\n".red
109
115
  puts response.body
110
116
  else
111
- puts "\nSuccessful Query:\n\n".green + JSON.parse(response.body).to_s.green
117
+ res = JSON.parse(response.body)
118
+ if(!options[:n])
119
+ res.each_with_index{|target, index| res[index]["datapoints"].delete_if{|value| value[0] == nil}}
120
+ end
121
+ puts "\nSuccessful Query:\n\n".green + JSON.pretty_generate(res).to_s.green
112
122
  end
113
123
  helper.unset_envs()
114
124
  end
@@ -200,11 +210,11 @@ module Echo_cli
200
210
  type = metric[metric.index('|') + 1 .. metric.length]
201
211
  case type
202
212
  when 'c'
203
- return "stats.counters." + metric[0..metric.index(':')-1] + ".count"
213
+ return "stats.counters." + metric[0..metric.index(':')-1] + ".*"
204
214
  when 'ms'
205
- return "stats.timers." + metric[0..metric.index(':')-1]
215
+ return "stats.timers." + metric[0..metric.index(':')-1] + ".*"
206
216
  when 's'
207
- return "stats.sets." + metric[0..metric.index(':')-1]
217
+ return "stats.sets." + metric[0..metric.index(':')-1] + ".*"
208
218
  when 'g'
209
219
  return "stats.gauges." + metric[0..metric.index(':')-1]
210
220
  end
@@ -212,7 +222,7 @@ module Echo_cli
212
222
 
213
223
  def check_metric_format(metric)
214
224
  if /.*(:\d*\.?\d*)\|(ms|c|g|s)/.match(metric).to_s != metric
215
- puts "\nThe posted metric was not of the correct form.\nMetrics must be of the form <metric>.<tag1>.<tag2>...<tagN>:<value>|<type>".red
225
+ puts "\nThe posted metric was not of the correct form.\nMetrics must be of the form ".red + "<Application_name>.<tag1>.<tag2>...<tag(n)>:<value>|<metric_type>".yellow
216
226
  puts "Where <value> is a number, and <type> is any of the following: 'ms', 'c', 's', 'g'.".red
217
227
  return false
218
228
  end
@@ -1,3 +1,3 @@
1
1
  module Echo_cli
2
- VERSION = "0.6.29"
2
+ VERSION = "0.6.31"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: echo_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.29
4
+ version: 0.6.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Raphael
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-14 00:00:00.000000000 Z
11
+ date: 2017-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor