influxdb-cli 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +21 -5
- data/bin/influxdb-cli +27 -9
- data/lib/influxdb_client/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eee6c28061fbb73ce08132bce8f324e50d84f3e4
|
4
|
+
data.tar.gz: 7aa0b0fcd32f70564339e928e1da503f23b8704d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43daad92887c4ff7d7bdbf35bfa647a9159f26edf52f792ba96c71087f097788d55384d19e08634e040823aac1afd6bc29b59a24fcc10351a705ad29251e1517
|
7
|
+
data.tar.gz: ff157af73651e607020e348e7d3d1fde35bc3818e29e8ef655465defb37d58db8bca92017449fe464debe795dd6b321b23d50f4393ca870411dc6e1ebf0ca6c2
|
data/README.md
CHANGED
@@ -30,15 +30,30 @@ Options:
|
|
30
30
|
|
31
31
|
### Usage
|
32
32
|
|
33
|
-
|
33
|
+
Connect to a database:
|
34
34
|
|
35
35
|
```shell
|
36
36
|
influxdb-cli
|
37
37
|
Connecting to {"host"=>"localhost", "port"=>8086, "username"=>"root", "password"=>"root", "database"=>"db"}
|
38
38
|
✔ ready
|
39
|
-
|
39
|
+
```
|
40
|
+
|
41
|
+
or
|
42
|
+
|
43
|
+
```shell
|
44
|
+
influxdb-cli -u user -p password -d database -h sandbox.influxdb.org --port 9061
|
45
|
+
Connecting to {"host"=>"sandbox.influxdb.org", "port"=>"9061", "username"=>"phstc", "password"=>"RggLimEQfK36or", "database"=>"spree"}
|
46
|
+
✔ ready
|
47
|
+
```
|
48
|
+
|
49
|
+
[InfluxDB Playground](http://play.influxdb.org) :metal:
|
50
|
+
|
51
|
+
Query with a [tabularized](https://github.com/visionmedia/terminal-table) output:
|
52
|
+
|
53
|
+
```shell
|
54
|
+
2.0.0 (main)> SELECT * FROM deploys
|
40
55
|
+---------------+-----------------+-----------------+--------+-----------------+-------------------+----------+
|
41
|
-
|
|
56
|
+
| deploys |
|
42
57
|
+---------------+-----------------+-----------------+--------+-----------------+-------------------+----------+
|
43
58
|
| time | sequence_number | application | branch | latest_revision | previous_revision | stage |
|
44
59
|
+---------------+-----------------+-----------------+--------+-----------------+-------------------+----------+
|
@@ -46,12 +61,12 @@ Connecting to {"host"=>"localhost", "port"=>8086, "username"=>"root", "password"
|
|
46
61
|
+---------------+-----------------+-----------------+--------+-----------------+-------------------+----------+
|
47
62
|
|
48
63
|
=> {
|
49
|
-
"
|
64
|
+
"deploys.count" => 1
|
50
65
|
}
|
51
66
|
```
|
52
67
|
|
53
68
|
|
54
|
-
Ruby Hash output ([awesome_print](https://github.com/michaeldv/awesome_print)):
|
69
|
+
Query with a Ruby Hash output ([awesome_print](https://github.com/michaeldv/awesome_print)):
|
55
70
|
|
56
71
|
```shell
|
57
72
|
2.0.0 (main)> db.query('SELECT * FROM deploys')
|
@@ -68,6 +83,7 @@ Ruby Hash output ([awesome_print](https://github.com/michaeldv/awesome_print)):
|
|
68
83
|
},
|
69
84
|
```
|
70
85
|
|
86
|
+
Other methods:
|
71
87
|
|
72
88
|
```shell
|
73
89
|
2.0.0 (main)> db.write_point(name, data)
|
data/bin/influxdb-cli
CHANGED
@@ -28,26 +28,44 @@ class InfluxDBClientTasks < Thor
|
|
28
28
|
default_task :db
|
29
29
|
end
|
30
30
|
|
31
|
+
# Returns {InfluxDB::Client} instance using given parameters.
|
32
|
+
#
|
33
|
+
# @return [InfluxDB::Client]
|
31
34
|
def db; InfluxDBClientTasks.db; end
|
32
35
|
|
36
|
+
# Queries data using {http://influxdb.org/docs/query_language/ InfluxDB Query Language}
|
37
|
+
# and prints a tabularized output.
|
38
|
+
#
|
39
|
+
# i.e. query('select value from response_times')
|
40
|
+
#
|
41
|
+
# @see InfluxDB::Client#query
|
42
|
+
#
|
43
|
+
# @return [Hash] the number of points per time series i.e. { 'response_times.count' => 10 }
|
33
44
|
def query(query)
|
34
45
|
result = db.query(query)
|
35
|
-
|
36
|
-
result.to_h.keys.each do |
|
37
|
-
headings = result[
|
38
|
-
rows = result[
|
39
|
-
table = Terminal::Table.new title:
|
46
|
+
number_of_points = {}
|
47
|
+
result.to_h.keys.each do |series|
|
48
|
+
headings = result[series].first.keys
|
49
|
+
rows = result[series].collect(&:values)
|
50
|
+
table = Terminal::Table.new title: series, headings: headings, rows: rows
|
40
51
|
puts table
|
41
|
-
# empty line
|
52
|
+
# empty line between time series output
|
42
53
|
puts
|
43
|
-
# count total per
|
44
|
-
|
54
|
+
# count total per time series
|
55
|
+
number_of_points["#{series}.count"] = result[series].size
|
45
56
|
end
|
46
|
-
|
57
|
+
number_of_points
|
58
|
+
end
|
59
|
+
|
60
|
+
# allow typing queries directly from console i.e.`select * from deploys` instead of `query('select * from deploys')`.
|
61
|
+
# matches `delete from ...` and `select ... from ...`
|
62
|
+
Pry::Commands.block_command /\A\s*((delete\s+from|select\s+.+\s+from)\s*.+)\z/i, 'Execute a query' do |cmd|
|
63
|
+
query(cmd)
|
47
64
|
end
|
48
65
|
|
49
66
|
InfluxDBClientTasks.start
|
50
67
|
|
68
|
+
# awesome_print
|
51
69
|
Pry.config.print = proc { |output, value| Pry::Helpers::BaseHelpers.stagger_output("=> #{value.ai}", output) }
|
52
70
|
|
53
71
|
pry
|