Module: InfluxDB

Defined in:
lib/influxdb/errors.rb,
lib/influxdb/client.rb,
lib/influxdb/config.rb,
lib/influxdb/logging.rb,
lib/influxdb/version.rb,
lib/influxdb/max_queue.rb,
lib/influxdb/query/core.rb,
lib/influxdb/query/user.rb,
lib/influxdb/writer/udp.rb,
lib/influxdb/client/http.rb,
lib/influxdb/point_value.rb,
lib/influxdb/query/batch.rb,
lib/influxdb/query/series.rb,
lib/influxdb/writer/async.rb,
lib/influxdb/query/builder.rb,
lib/influxdb/query/cluster.rb,
lib/influxdb/query/database.rb,
lib/influxdb/query/measurement.rb,
lib/influxdb/timestamp_conversion.rb,
lib/influxdb/query/continuous_query.rb,
lib/influxdb/query/retention_policy.rb

Overview

:nodoc:

Defined Under Namespace

Modules: HTTP, Logging, Query, Writer Classes: Client, Config, MaxQueue, PointValue

Constant Summary collapse

DEFAULT_CONFIG_OPTIONS =

DEFAULT_CONFIG_OPTIONS maps (most) of the configuration options to their default value. Each option (except for “async” and “udp”) can be changed at runtime throug the InfluxDB::Client instance.

If you need to change the writer to be asynchronuous or use UDP, you need to get a new InfluxDB::Client instance.

{
  # HTTP connection options
  port:                 8086,
  prefix:               "".freeze,
  username:             "root".freeze,
  password:             "root".freeze,
  open_timeout:         5,
  read_timeout:         300,
  auth_method:          nil,

  # SSL options
  use_ssl:              false,
  verify_ssl:           true,
  ssl_ca_cert:          false,

  # Database options
  database:             nil,
  time_precision:       "s".freeze,
  epoch:                false,

  # Writer options
  async:                false,
  udp:                  false,
  discard_write_errors: false,

  # Retry options
  retry:                -1,
  max_delay:            30,
  initial_delay:        0.01,

  # Query options
  chunk_size:           nil,
  denormalize:          true,
}.freeze
Error =
Class.new StandardError
AuthenticationError =
Class.new Error
ConnectionError =
Class.new Error
SeriesNotFound =
Class.new Error
JSONParserError =
Class.new Error
QueryError =
Class.new Error
RECOVERABLE_EXCEPTIONS =

When executing queries via HTTP, some errors can more or less safely be ignored and we can retry the query again. This following exception classes shall be deemed as “safe”.

Taken from: github.com/lostisland/faraday/blob/master/lib/faraday/adapter/net_http.rb

[
  Errno::ECONNABORTED,
  Errno::ECONNREFUSED,
  Errno::ECONNRESET,
  Errno::EHOSTUNREACH,
  Errno::EINVAL,
  Errno::ENETUNREACH,
  Net::HTTPBadResponse,
  Net::HTTPHeaderSyntaxError,
  Net::ProtocolError,
  SocketError,
  (OpenSSL::SSL::SSLError if defined?(OpenSSL)),
].compact.freeze
NON_RECOVERABLE_EXCEPTIONS =

Exception classes which hint to a larger problem on the server side, like insuffient resources. If we encouter on of the following, wo _don’t_ retry a query but escalate it upwards.

[
  EOFError,
  Zlib::Error,
].freeze
NON_RECOVERABLE_MESSAGE =
"The server has sent incomplete data" \
" (insufficient resources are a possible cause).".freeze
VERSION =
"0.6.2".freeze

Class Method Summary collapse

Class Method Details

.convert_timestamp(time, time_precision) ⇒ Object

Converts a Time to a timestamp with the given precision.

‘convert_timestamp(Time.now, “ms”)` might return `1543533308243`.



16
17
18
19
20
21
22
# File 'lib/influxdb/timestamp_conversion.rb', line 16

def self.convert_timestamp(time, time_precision)
  factor = TIMESTAMP_CONVERSIONS.fetch(time_precision) do
    raise "Invalid time precision: #{time_precision}"
  end

  (time.to_r * factor).to_i
end