Module: InfluxDB::Query::Core
- Included in:
- Client
- Defined in:
- lib/influxdb/query/core.rb
Overview
rubocop:disable Metrics/AbcSize
Instance Method Summary collapse
- #ping ⇒ Object
-
#query(query, opts = {}) ⇒ Object
rubocop:disable Metrics/MethodLength.
- #write(data, precision) ⇒ Object
-
#write_point(series, data, precision = nil) ⇒ Object
Example: write_point(‘cpu’, tags: ‘us’, values: 60).
-
#write_points(data, precision = nil) ⇒ Object
Example: write_points([ { series: ‘cpu’, tags: { host: ‘server_nl’, regios: ‘us’ }, values: 5, external: 6, timestamp: 1422568543702900257 }, { series: ‘gpu’, values: 0.9999, } ]).
Instance Method Details
#ping ⇒ Object
5 6 7 |
# File 'lib/influxdb/query/core.rb', line 5 def ping get "/ping" end |
#query(query, opts = {}) ⇒ Object
rubocop:disable Metrics/MethodLength
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/influxdb/query/core.rb', line 10 def query(query, opts = {}) precision = opts.fetch(:precision, config.time_precision) denormalize = opts.fetch(:denormalize, config.denormalize) url = full_url("/query", q: query, db: config.database, precision: precision) series = fetch_series(get(url, parse: true)) if block_given? series.each do |s| yield s['name'], s['tags'], denormalize ? denormalize_series(s) : raw_values(s) end else denormalize ? denormalized_series_list(series) : series end end |
#write(data, precision) ⇒ Object
53 54 55 56 57 |
# File 'lib/influxdb/query/core.rb', line 53 def write(data, precision) precision ||= config.time_precision url = full_url("/write", db: config.database, precision: precision) post(url, data) end |
#write_point(series, data, precision = nil) ⇒ Object
Example: write_point(‘cpu’, tags: ‘us’, values: 60)
48 49 50 51 |
# File 'lib/influxdb/query/core.rb', line 48 def write_point(series, data, precision = nil) data.merge!(series: series) write_points(data, precision) end |
#write_points(data, precision = nil) ⇒ Object
Example: write_points([
{
series: 'cpu',
tags: { host: 'server_nl', regios: 'us' },
values: {internal: 5, external: 6},
timestamp: 1422568543702900257
},
{
series: 'gpu',
values: {value: 0.9999},
}
])
40 41 42 43 44 |
# File 'lib/influxdb/query/core.rb', line 40 def write_points(data, precision = nil) data = data.is_a?(Array) ? data : [data] payload = generate_payload(data) writer.write(payload, precision) end |