echo_cli 0.6.21 → 0.6.22

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: 455a70f05530bd541185638a1c07ed7005bba915
4
- data.tar.gz: d298d2bd257fd85935a71c0e9a123a1efde0c34f
3
+ metadata.gz: 0d6b85ab3089231acf50fb16fa379c145fe269dc
4
+ data.tar.gz: 479af41f845d3ef69a59cd5e148017d1b6071d18
5
5
  SHA512:
6
- metadata.gz: aee1848d8b950130cbd33ecc95bf2d9a4134551f481b50cef43105003d6906fe63c05be04b18559826c5dfcc30a84aad51b48410d7f3c46942c6ff76351be519
7
- data.tar.gz: fd88e47ba8f795825c6cd69854d1fdf54b0fc4531500b02e4e1b3004098583ea52c040bae12f621a560e4c3526e578f7979efdaaff4d042fbc43b166b4989bcf
6
+ metadata.gz: 4131237a0635701a8d5f76c32b93c30d62e584b62d009cc252685e5c1b48bb0a4c714c2bd3e6b1d842c27a656b07bf6ba960030a4af0bc191f88e38b9b3478ae
7
+ data.tar.gz: e0cc7373b95d1a4334b11f68fd3dc1c37f6f53b605cf24ec6d5aa51c38045c674d8c5dcb970553267ba97fa6fd92ae28329eb23a94950716b649ed540d573db6
data/README.md CHANGED
@@ -48,6 +48,8 @@ Test the installation to ensure it is working properly (no errors should occur i
48
48
  $ echo_cli
49
49
  ```
50
50
 
51
+ Finally, export the environment variable "ECHO_CLI_HOST", and set this value to be the IP of the Echo instance you would like to use (e.g. export ECHO_CLI_HOST=10.111.111.111). This environment variable can be set inside your .bashrc file to ensure ease of use of the Echo CLI every time you create a new bash environment.
52
+
51
53
  ## Metrics Explained
52
54
 
53
55
  ### Posting data to Echo
@@ -110,12 +112,10 @@ This example will convert from a human-readable timestamp to an epoch timestamp.
110
112
 
111
113
  #### cpost
112
114
  ```bash
113
- $ echo_cli cpost <URL> '<metric>' {frequency} {-v} {-z}
115
+ $ echo_cli cpost '<metric>' {frequency} {-v} {-z}
114
116
  ```
115
117
  Parameters:
116
118
 
117
- `<URL>`: (required) specifies the StatsD endpoint you are attempting to post a metric to
118
-
119
119
  `'<metric>'`: (required) the application name, as well as any tags, and data value and data type to be posted to StatsD
120
120
 
121
121
  `{frequency}`: (optional) the rate at which the metric will be continuously posted to Echo's server. If left unspecified, this value will default to 10 seconds.
@@ -126,9 +126,9 @@ Parameters:
126
126
 
127
127
  Example:
128
128
  ```bash
129
- $ echo_cli cpost https://localhost:8125/metrix 'example.post:1|c' 5 -z
129
+ $ echo_cli cpost 'example.post:1|c' 5 -z
130
130
  ```
131
- The previous example will post the metric 'example' with tag 'post' to Echo's StatsD server instance at 'https://localhost:8125/metrix' once every 5 seconds. The specified '-z' option will spawn the process in the background, and return the newly spawned process ID in the command line.
131
+ The previous example will post the metric 'example' with tag 'post' to Echo's StatsD server instance once every 5 seconds. The specified '-z' option will spawn the process in the background, and return the newly spawned process ID in the command line.
132
132
 
133
133
  #### help
134
134
  ```bash
@@ -143,33 +143,28 @@ $ echo_cli help post
143
143
 
144
144
  #### post
145
145
  ```bash
146
- $ echo_cli post <URL> '<metric>' {number} {-q}
146
+ $ echo_cli post '<metric>' {number} {-q}
147
147
  ```
148
148
  Parameters:
149
149
 
150
- `<URL>`: (required) specifies the StatsD endpoint you are attempting to post a metric to
151
-
152
150
  `'<metric>'`: (required) the application name, as well as any tags, and data value and data type to be posted to StatsD
153
151
 
154
152
  `{number}`: (optional) the number of posts to occur, e.g. a number value of '10' would post the metric 10 times to the StatsD server
155
153
 
156
-
157
154
  `{-q}`: (optional) does an automatic query of OpenTSDB immediately following the successful post of the metric to ensure the data transfer between StatsD and OpenTSDB. This option requires approx. 15 seconds to complete, as data flush and HA require ~15 seconds to occur
158
155
 
159
156
  Example:
160
157
  ```bash
161
- $ echo_cli https://localhost:8125/metrix 'sample.post.here:1|c' 10 -q
158
+ $ echo_cli 'sample.post.here:1|c' 10 -q
162
159
  ```
163
- The previous example would post the application name 'sample' with tags 'post' and 'here' with data value '1' and with data type 'c' (for count). This information would be posted to the instance of StatsD located at 'https://localhost:8125/metrix', and it would be posted 10 times. Additionally, because of the '-q' specified option, OpenTSDB will be queried immediately after the post to StatsD, to verify it has been received by Echo's instance of OpenTSDB.
160
+ The previous example would post the application name 'sample' with tags 'post' and 'here' with data value '1' and with data type 'c' (for count). This information would be posted to the instance of StatsD, and it would be posted 10 times. Additionally, because of the '-q' specified option, OpenTSDB will be queried immediately after the post to StatsD, to verify it has been received by Echo's instance of OpenTSDB.
164
161
 
165
162
  #### query
166
163
  ```bash
167
- $ echo_cli query <URL> '<metric>' <time_start> <time_end> {-v} {-e} {-s}
164
+ $ echo_cli query '<metric>' <time_start> <time_end> {-v} {-e} {-s}
168
165
  ```
169
166
  Parameters:
170
167
 
171
- `<URL>`: (required) specifies the OpenTSDB endpoint you are attempting to query
172
-
173
168
  `'<metric>'`: (required) the application name, including any tags, with which the query for OpenTSDB will be constructed
174
169
 
175
170
  `<time_start>`: (required) the start of the range you are attempting to query in seconds from January 1, 1970 (epoch time)
@@ -184,18 +179,16 @@ Parameters:
184
179
 
185
180
  Example:
186
181
  ```bash
187
- $ echo_cli https://localhost:4242/api/query 'sample.query.here' 1492464745 1492465045 -v
182
+ $ echo_cli query 'sample.query.here' 1492464745 1492465045 -v
188
183
  ```
189
184
  The previous example will query OpenTSDB with the application name 'sample' and tags 'query' and 'here' between the times of '1492464745' and '1492465045'. Additionally, the '-v' specified option will also return the response code and response body upon completion.
190
185
 
191
- #### quick_query
186
+ #### fquery
192
187
  ```bash
193
- $ echo_cli quick_query <URL> '<metric>' <range> {-e} {-s}
188
+ $ echo_cli fquery '<metric>' <range> {-e} {-s}
194
189
  ```
195
190
  Parameters:
196
191
 
197
- `<URL>`: (required) specifies the OpenTSDB endpoint you are attempting to query
198
-
199
192
  `'<metric>'`: (required) the application name, including any tags, with which the query for OpenTSDB will be constructed
200
193
 
201
194
  `<range>`: (required) the time, in seconds, from the current time (epoch time) that you would like to query, e.g. a 'range' value of 300 would query OpenTSDB for the specified metric in the last 5 minutes of time-series data
@@ -206,9 +199,9 @@ Parameters:
206
199
 
207
200
  Example:
208
201
  ```bash
209
- $ echo_cli https://localhost:4242/api/query 'sample.query.here' 300 -s
202
+ $ echo_cli fquery 'sample.query.here' 300 -s
210
203
  ```
211
- The previous example will query OpenTSDB located on 'https://localhost:4242/api/query' with the application name 'sample' and tags 'query' and 'here', within the time range spanning from the current time to '300' seconds before the current time. The '-s' option will return the data as SQL statements for later insertion into a SQL database.
204
+ The previous example will query OpenTSDB with the application name 'sample' and tags 'query' and 'here', within the time range spanning from the current time to '300' seconds before the current time. The '-s' option will return the data as SQL statements for later insertion into a SQL database.
212
205
 
213
206
  ## Development
214
207
 
data/lib/echo_cli/cli.rb CHANGED
@@ -9,7 +9,7 @@ require 'openssl'
9
9
 
10
10
  module Echo_cli
11
11
  class Echo < Thor
12
- desc "post", "Post metrics to Echo. Use \"echo_cli post <URL> '<metric>' {number} {-q}\""
12
+ desc "post", "Post metrics to Echo. Use \"echo_cli post '<metric>' {number} {-q}\""
13
13
 
14
14
  option :q
15
15
 
@@ -22,10 +22,11 @@ module Echo_cli
22
22
 
23
23
  With -q (query-verify) option, post will perform a query of previously posted metric in Echo's instance of OpenTSDB, and provide a message verifying the datapoint exists.
24
24
 
25
- > $ echo_cli post https://localhost:8125/metrix 'example.post:1|c' {10} {-q}
25
+ > $ echo_cli post 'example.post:1|c' {10} {-q}
26
26
  LONGDESC
27
27
 
28
- def post(statsd_uri, metric, num = 0)
28
+ def post(metric, num = 0)
29
+ statsd_uri = "https://" + ENV["ECHO_CLI_HOST"] + ":8125/metrix"
29
30
 
30
31
  Helper.new.set_envs()
31
32
 
@@ -100,7 +101,7 @@ module Echo_cli
100
101
  Helper.new.unset_envs()
101
102
  end
102
103
 
103
- desc "cpost", "Continuously post metrics to Echo. Use \"echo_cli cpost <URL> '<metric>' {frequency} {-v} {-z}\""
104
+ desc "cpost", "Continuously post metrics to Echo. Use \"echo_cli cpost '<metric>' {frequency} {-v} {-z}\""
104
105
 
105
106
  option :z
106
107
  option :v
@@ -116,10 +117,11 @@ module Echo_cli
116
117
 
117
118
  With -z (zombie) option, cpost will continuously send posts to Echo in the background, and return its PID for future removal. Use "$ kill -9 <PID>" to kill the zombie process. Specifying this option will override the '-v' option.
118
119
 
119
- > $ echo_cli cpost https://localhost:8125/metrix 'example.post:1|c' {1} {-v} {-z}
120
+ > $ echo_cli cpost 'example.post:1|c' {1} {-v} {-z}
120
121
  LONGDESC
121
122
 
122
- def cpost(statsd_uri, metric, num = 0)
123
+ def cpost(metric, num = 0)
124
+ statsd_uri = "https://" + ENV["ECHO_CLI_HOST"] + ":8125/metrix"
123
125
 
124
126
  Helper.new.set_envs()
125
127
 
@@ -172,7 +174,7 @@ module Echo_cli
172
174
 
173
175
  end
174
176
 
175
- desc "query", "Query metrics on Echo. Use \"echo_cli query <URL> '<metric>' <time_start> <time_end> {-v} {-e} {-s}\""
177
+ desc "query", "Query metrics on Echo. Use \"echo_cli query '<metric>' <time_start> <time_end> {-v} {-e} {-s}\""
176
178
 
177
179
  option :v
178
180
  option :e
@@ -195,10 +197,12 @@ module Echo_cli
195
197
 
196
198
  With -s (sql) option, echo_cli will format the response data, with the verbose ('-v') option selected, to be usable within a sql database.
197
199
 
198
- > $ echo_cli query https://localhost:4242/api/query 'example.post' 1492186212 1492186214 {-v}
200
+ > $ echo_cli query 'example.post' 1492186212 1492186214 {-v}
199
201
  LONGDESC
200
202
 
201
- def query(opentsdb_uri, metric, time_start, time_end)
203
+ def query(metric, time_start, time_end)
204
+ opentsdb_uri = "https://" + ENV["ECHO_CLI_HOST"] + ":4242/api/query"
205
+
202
206
  metric = Helper.new.get_metric(metric)
203
207
  metric_name = Helper.new.get_metric_name(metric)
204
208
  tags = Helper.new.check_get_tags(metric)
@@ -265,17 +269,17 @@ module Echo_cli
265
269
  return res.code
266
270
  end
267
271
 
268
- desc "quick_query", "Query metrics on Echo from the current time. Use \"echo_cli quick_query <URL> '<metric>' <range> {-e} {-s}\""
272
+ desc "fquery", "Query metrics on Echo from the current time. Use \"echo_cli fquery '<metric>' <range> {-e} {-s}\""
269
273
 
270
274
  option :e
271
275
  option :s
272
276
 
273
277
  long_desc <<-LONGDESC
274
- `echo_cli quick_query` will query a metric directly from Echo's OpenTSDB server instance for a given time range beginning in the present.
278
+ `echo_cli fquery` (fast query) will query a metric directly from Echo's OpenTSDB server instance for a given time range beginning in the present.
275
279
 
276
280
  Ensure single-quotes surround the metric.
277
281
 
278
- Unlike the echo_cli post command, quick_query does not require the data value nor the data type (e.g. remove ':1|c' from 'example.post:1|c' and your query will still work).
282
+ Unlike the echo_cli post command, fquery does not require the data value nor the data type (e.g. remove ':1|c' from 'example.post:1|c' and your query will still work).
279
283
 
280
284
  The <range> parameter is defined in seconds, and is used to query the metric from the current time.
281
285
 
@@ -283,12 +287,14 @@ module Echo_cli
283
287
 
284
288
  With -s (sql) option, echo_cli will format the response data to be usable within a sql database.
285
289
 
286
- > $ echo_cli quick_query https://localhost:4242/api/query 'example' 30
290
+ > $ echo_cli fquery 'example' 30
287
291
 
288
292
  The previous example would find all data points with metric name 'example' on Echo's OpenTSDB instance at 'localhost' in the last 30 seconds.
289
293
  LONGDESC
290
294
 
291
- def quick_query(opentsdb_uri, metric, range)
295
+ def fquery(metric, range)
296
+ opentsdb_uri = "https://" + ENV["ECHO_CLI_HOST"] + ":4242/api/query"
297
+
292
298
  time_end = Time.new.to_i
293
299
  time_start = time_end - range.to_i
294
300
  time_start = time_start.to_s
@@ -1,3 +1,3 @@
1
1
  module Echo_cli
2
- VERSION = "0.6.21"
2
+ VERSION = "0.6.22"
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.21
4
+ version: 0.6.22
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-05-17 00:00:00.000000000 Z
11
+ date: 2017-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor