Module: Legion::Extensions::Influxdb::Runners::Database
- Defined in:
- lib/legion/extensions/influxdb/runners/database.rb
Class Method Summary collapse
- .create(name:, host: 'localhost', port: 8086, **payload) ⇒ Object
- .delete(name:, host: 'localhost', port: 8086, **payload) ⇒ Object
- .field_keys(database: 'telegraf', host: 'localhost', port: 8086, **payload) ⇒ Object
- .list(host: 'localhost', port: 8086, **payload) ⇒ Object
Class Method Details
.create(name:, host: 'localhost', port: 8086, **payload) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/legion/extensions/influxdb/runners/database.rb', line 4 def self.create(name:, host: 'localhost', port: 8086, **payload) # client = InfluxDB::Client.new(host: host, port: port) require 'influxdb' client = InfluxDB::Client.new Legion::Logging.unknown({ name: name, host: host, port: port, **payload }) Legion::Logging.fatal client.create_database(name) { name: name, host: host, port: port, **payload } rescue StandardError => e Legion::Logging.error e. Legion::Logging.error e.backtrace end |
.delete(name:, host: 'localhost', port: 8086, **payload) ⇒ Object
16 17 18 19 |
# File 'lib/legion/extensions/influxdb/runners/database.rb', line 16 def self.delete(name:, host: 'localhost', port: 8086, **payload) client = InfluxDB::Client.new(host: payload[:host]) client.delete_database(payload[:name]) end |
.field_keys(database: 'telegraf', host: 'localhost', port: 8086, **payload) ⇒ Object
25 26 27 28 |
# File 'lib/legion/extensions/influxdb/runners/database.rb', line 25 def self.field_keys(database: 'telegraf', host: 'localhost', port: 8086, **payload) client = InfluxDB::Client.new(host: payload[:host], port: port, database: database) { results: client.show_field_keys, count: client.show_field_keys.count } end |
.list(host: 'localhost', port: 8086, **payload) ⇒ Object
21 22 23 |
# File 'lib/legion/extensions/influxdb/runners/database.rb', line 21 def self.list(host: 'localhost', port: 8086, **payload) InfluxDB::Client.new(host: payload[:host]).list_databases end |