{"id":13411909,"url":"https://github.com/InfluxCommunity/influxdb-ruby","last_synced_at":"2025-03-14T17:31:16.998Z","repository":{"id":37850206,"uuid":"13937936","full_name":"InfluxCommunity/influxdb-ruby","owner":"InfluxCommunity","description":"Ruby client for InfluxDB","archived":false,"fork":false,"pushed_at":"2022-06-20T11:16:05.000Z","size":685,"stargazers_count":369,"open_issues_count":13,"forks_count":133,"subscribers_count":51,"default_branch":"master","last_synced_at":"2025-03-08T13:36:54.398Z","etag":null,"topics":["client-lib","influxdb","ruby","time-series"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/InfluxCommunity.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-28T20:40:57.000Z","updated_at":"2025-03-06T11:32:58.000Z","dependencies_parsed_at":"2022-08-19T22:11:32.794Z","dependency_job_id":null,"html_url":"https://github.com/InfluxCommunity/influxdb-ruby","commit_stats":null,"previous_names":["influxdb/influxdb-ruby","influxdata/influxdb-ruby"],"tags_count":65,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InfluxCommunity%2Finfluxdb-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InfluxCommunity%2Finfluxdb-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InfluxCommunity%2Finfluxdb-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InfluxCommunity%2Finfluxdb-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/InfluxCommunity","download_url":"https://codeload.github.com/InfluxCommunity/influxdb-ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243618690,"owners_count":20320275,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client-lib","influxdb","ruby","time-series"],"created_at":"2024-07-30T20:01:18.347Z","updated_at":"2025-03-14T17:31:13.814Z","avatar_url":"https://github.com/InfluxCommunity.png","language":"Ruby","readme":"# influxdb-ruby\n\n[![Gem Version](https://badge.fury.io/rb/influxdb.svg)](https://badge.fury.io/rb/influxdb)\n[![Build Status](https://github.com/influxdata/influxdb-ruby/workflows/Tests/badge.svg)](https://github.com/influxdata/influxdb-ruby/actions)\n\nThe official Ruby client library for [InfluxDB](https://influxdata.com/time-series-platform/influxdb/).\nMaintained by [@toddboom](https://github.com/toddboom) and [@dmke](https://github.com/dmke).\n\n#### Note: This library is for use with InfluxDB 1.x. For connecting to InfluxDB 2.x instances, please use the [influxdb-client-ruby](https://github.com/influxdata/influxdb-client-ruby) client.\n\n## Contents\n\n- [Platform support](#platform-support)\n- [Ruby support](#ruby-support)\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Creating a client](#creating-a-client)\n  - [Writing data](#writing-data)\n  - [A Note About Time Precision](#a-note-about-time-precision)\n  - [Querying](#querying)\n- [Advanced Topics](#advanced-topics)\n  - [Administrative tasks](#administrative-tasks)\n  - [Continuous queries](#continuous-queries)\n  - [Retention policies](#retention-policies)\n  - [Reading data](#reading-data)\n    - [De-normalization](#de--normalization)\n    - [Streaming response](#streaming-response)\n    - [Retry](#retry)\n- [List of configuration options](#list-of-configuration-options)\n- [Testing](#testing)\n- [Contributing](#contributing)\n\n## Platform support\n\n\u003e **Support for InfluxDB v0.8.x is now deprecated**. The final version of this\n\u003e library that will support the older InfluxDB interface is `v0.1.9`, which is\n\u003e available as a gem and tagged on this repository.\n\u003e\n\u003e If you're reading this message, then you should only expect support for\n\u003e InfluxDB v0.9.1 and higher.\n\n## Ruby support\n\nSince v0.7.0, this gem requires Ruby \u003e= 2.3.0. MRI 2.2 *should* still work,\nhowever we are unable to test this properly, since our toolchain (Bundler)\nhas dropped support for it. Support for MRI \u003c 2.2 is still available in the\nv0.3.x series, see [stable-03 branch](https://github.com/influxdata/influxdb-ruby/tree/stable-03)\nfor documentation.\n\n## Installation\n\n```\n$ [sudo] gem install influxdb\n```\n\nOr add it to your `Gemfile`, and run `bundle install`.\n\n## Usage\n\n*All examples assume you have a `require \"influxdb\"` in your code.*\n\n### Creating a client\n\nConnecting to a single host:\n\n``` ruby\ninfluxdb = InfluxDB::Client.new  # default connects to localhost:8086\n\n# or\ninfluxdb = InfluxDB::Client.new host: \"influxdb.domain.com\"\n```\n\nConnecting to multiple hosts (with built-in load balancing and failover):\n\n``` ruby\ninfluxdb = InfluxDB::Client.new hosts: [\"influxdb1.domain.com\", \"influxdb2.domain.com\"]\n```\n\n#### Using a configuration URL\n\nYou can also provide a URL to connect to your server. This is particulary\nuseful for 12-factor apps, i.e. you can put the configuration in an environment\nvariable:\n\n``` ruby\nurl = ENV[\"INFLUXDB_URL\"] || \"https://influxdb.example.com:8086/database_name?retry=3\"\ninfluxdb = InfluxDB::Client.new url: url\n```\n\nPlease note, that the config options found in the URL have a lower precedence\nthan those explicitly given in the options hash. This means, that the following\nsample will use an open-timeout of 10 seconds:\n\n``` ruby\nurl = \"https://influxdb.example.com:8086/database_name?open_timeout=3\"\ninfluxdb = InfluxDB::Client.new url: url, open_timeout: 10\n```\n\n#### Using a custom HTTP Proxy\n\nBy default, the `Net::HTTP` proxy behavior is used (see [Net::HTTP Proxy][proxy])\nYou can optionally set a proxy address and port via the `proxy_addr` and\n`proxy_port` options:\n\n``` ruby\ninfluxdb = InfluxDB::Client.new database,\n  host:       \"influxdb.domain.com\",\n  proxy_addr: \"your.proxy.addr\",\n  proxy_port: 8080\n```\n\n[proxy]: https://docs.ruby-lang.org/en/2.7.0/Net/HTTP.html#class-Net::HTTP-label-Proxies\n\n### Writing data\n\nWrite some data:\n\n``` ruby\nusername = 'foo'\npassword = 'bar'\ndatabase = 'site_development'\nname     = 'foobar'\n\ninfluxdb = InfluxDB::Client.new database, username: username, password: password\n\n# Enumerator that emits a sine wave\nValue = (0..360).to_a.map {|i| Math.send(:sin, i / 10.0) * 10 }.each\n\nloop do\n  data = {\n    values: { value: Value.next },\n    tags:   { wave: 'sine' } # tags are optional\n  }\n\n  influxdb.write_point(name, data)\n\n  sleep 1\nend\n```\n\nWrite data with time precision (precision can be set in 2 ways):\n\n``` ruby\nusername       = 'foo'\npassword       = 'bar'\ndatabase       = 'site_development'\nname           = 'foobar'\ntime_precision = 's'\n\n# either in the client initialization:\ninfluxdb = InfluxDB::Client.new database,\n  username: username,\n  password: password,\n  time_precision: time_precision\n\ndata = {\n  values: { value: 0 },\n  timestamp: Time.now.to_i # timestamp is optional, if not provided point will be saved with current time\n}\n\ninfluxdb.write_point(name, data)\n\n# or in a method call:\ninfluxdb.write_point(name, data, time_precision)\n```\n\n\u003e **Attention:** Please also read the\n\u003e [note about time precision](#a-note-about-time-precision) below.\n\nAllowed values for `time_precision` are:\n\n- `\"ns\"` or `nil` for nanosecond\n- `\"u\"` for microsecond\n- `\"ms\"` for millisecond\n- `\"s\"` for second\n- `\"m\"` for minute\n- `\"h\"` for hour\n\nWrite data with a specific retention policy:\n\n``` ruby\ndatabase  = 'site_development'\nname      = 'foobar'\nprecision = 's'\nretention = '1h.cpu'\n\ninfluxdb = InfluxDB::Client.new database,\n  username: \"foo\",\n  password: \"bar\"\n\ndata = {\n  values:    { value: 0 },\n  tags:      { foo: 'bar', bar: 'baz' },\n  timestamp: Time.now.to_i\n}\n\ninfluxdb.write_point(name, data, precision, retention)\n```\n\nWrite data while choosing the database:\n\n``` ruby\ndatabase  = 'site_development'\nname      = 'foobar'\nprecision = 's'\nretention = '1h.cpu'\n\ninfluxdb = InfluxDB::Client.new {\n  username: \"foo\",\n  password: \"bar\"\n}\n\ndata = {\n  values:    { value: 0 },\n  tags:      { foo: 'bar', bar: 'baz' },\n  timestamp: Time.now.to_i\n}\n\ninfluxdb.write_point(name, data, precision, retention, database)\n```\n\nWrite multiple points in a batch (performance boost):\n\n``` ruby\ndata = [\n  {\n    series: 'cpu',\n    tags:   { host: 'server_1', region: 'us' },\n    values: { internal: 5, external: 0.453345 }\n  },\n  {\n    series: 'gpu',\n    values: { value: 0.9999 },\n  }\n]\n\ninfluxdb.write_points(data)\n\n# you can also specify precision in method call\n\nprecision = 'm'\ninfluxdb.write_points(data, precision)\n```\n\nWrite multiple points in a batch with a specific retention policy:\n\n``` ruby\ndata = [\n  {\n    series: 'cpu',\n    tags:   { host: 'server_1', region: 'us' },\n    values: { internal: 5, external: 0.453345 }\n  },\n  {\n    series: 'gpu',\n    values: { value: 0.9999 },\n  }\n]\n\nprecision = 'm'\nretention = '1h.cpu'\ninfluxdb.write_points(data, precision, retention)\n```\n\nWrite asynchronously:\n\n``` ruby\ndatabase = 'site_development'\nname     = 'foobar'\n\ninfluxdb = InfluxDB::Client.new database,\n  username: \"foo\",\n  password: \"bar\",\n  async:    true\n\ndata = {\n  values:    { value: 0 },\n  tags:      { foo: 'bar', bar: 'baz' },\n  timestamp: Time.now.to_i\n}\n\ninfluxdb.write_point(name, data)\n```\n\n\u003ca name=\"async-options\"\u003e\u003c/a\u003e\nUsing `async: true` is a shortcut for the following:\n\n``` ruby\nasync_options = {\n  # number of points to write to the server at once\n  max_post_points:     1000,\n  # queue capacity\n  max_queue_size:      10_000,\n  # number of threads\n  num_worker_threads:  3,\n  # max. time (in seconds) a thread sleeps before\n  # checking if there are new jobs in the queue\n  sleep_interval:      5,\n  # whether client will block if queue is full\n  block_on_full_queue: false,\n  # Max time (in seconds) the main thread will wait for worker threads to stop\n  # on shutdown. Defaults to 2x sleep_interval.\n  shutdown_timeout: 10\n}\n\ninfluxdb = InfluxDB::Client.new database, async: async_options\n```\n\n\u003ca name=\"udp-options\"\u003e\u003c/a\u003e\nWrite data via UDP (note that a retention policy cannot be specified for UDP writes):\n\n``` ruby\ninfluxdb = InfluxDB::Client.new udp: { host: \"127.0.0.1\", port: 4444 }\n\nname = 'hitchhiker'\n\ndata = {\n  values: { value: 666 },\n  tags:   { foo: 'bar', bar: 'baz' }\n}\n\ninfluxdb.write_point(name, data)\n```\n\nDiscard write errors:\n\n``` ruby\ninfluxdb = InfluxDB::Client.new(\n  udp: { host: \"127.0.0.1\", port: 4444 },\n  discard_write_errors: true\n)\n\ninfluxdb.write_point('hitchhiker', { values: { value: 666 } })\n```\n\n### A Note About Time Precision\n\nThe default precision in this gem is `\"s\"` (second), as Ruby's `Time#to_i`\noperates on this resolution.\n\nIf you write data points with sub-second resolution, you _have_ to configure\nyour client instance with a more granular `time_precision` option **and** you\nneed to provide timestamp values which reflect this precision. **If you don't do\nthis, your points will be squashed!**\n\n\u003e A point is uniquely identified by the measurement name, tag set, and\n\u003e timestamp. If you submit a new point with the same measurement, tag set, and\n\u003e timestamp as an existing point, the field set becomes the union of the old\n\u003e field set and the new field set, where any ties go to the new field set. This\n\u003e is the intended behavior.\n\nSee [How does InfluxDB handle duplicate points?][docs-faq] for details.\n\nFor example, this is how to specify millisecond precision (which moves the\npitfall from the second- to the millisecond barrier):\n\n```ruby\nclient = InfluxDB::Client.new(time_precision: \"ms\")\ntime = (Time.now.to_r * 1000).to_i\nclient.write_point(\"foobar\", { values: { n: 42 }, timestamp: time })\n```\n\nFor convenience, InfluxDB provides a few helper methods:\n\n```ruby\n# to get a timestamp with the precision configured in the client:\nclient.now\n\n# to get a timestamp with the given precision:\nInfluxDB.now(time_precision)\n\n# to convert a Time into a timestamp with the given precision:\nInfluxDB.convert_timestamp(Time.now, time_precision)\n```\n\nAs with `client.write_point`, allowed values for `time_precision` are:\n\n- `\"ns\"` or `nil` for nanosecond\n- `\"u\"` for microsecond\n- `\"ms\"` for millisecond\n- `\"s\"` for second\n- `\"m\"` for minute\n- `\"h\"` for hour\n\n[docs-faq]: http://docs.influxdata.com/influxdb/v1.7/troubleshooting/frequently-asked-questions/#how-does-influxdb-handle-duplicate-points\n\n### Querying\n\n``` ruby\ndatabase = 'site_development'\ninfluxdb = InfluxDB::Client.new database,\n  username: \"foo\",\n  password: \"bar\"\n\n# without a block:\ninfluxdb.query 'select * from time_series_1 group by region'\n\n# results are grouped by name, but also their tags:\n#\n# [\n#   {\n#     \"name\"=\u003e\"time_series_1\",\n#     \"tags\"=\u003e{\"region\"=\u003e\"uk\"},\n#     \"values\"=\u003e[\n#       {\"time\"=\u003e\"2015-07-09T09:03:31Z\", \"count\"=\u003e32, \"value\"=\u003e0.9673},\n#       {\"time\"=\u003e\"2015-07-09T09:03:49Z\", \"count\"=\u003e122, \"value\"=\u003e0.4444}\n#     ]\n#   },\n#   {\n#     \"name\"=\u003e\"time_series_1\",\n#     \"tags\"=\u003e{\"region\"=\u003e\"us\"},\n#     \"values\"=\u003e[\n#       {\"time\"=\u003e\"2015-07-09T09:02:54Z\", \"count\"=\u003e55, \"value\"=\u003e0.4343}\n#     ]\n#   }\n# ]\n\n# with a block:\ninfluxdb.query 'select * from time_series_1 group by region' do |name, tags, points|\n  printf \"%s [ %p ]\\n\", name, tags\n  points.each do |pt|\n    printf \"  -\u003e %p\\n\", pt\n  end\nend\n\n# result:\n# time_series_1 [ {\"region\"=\u003e\"uk\"} ]\n#   -\u003e {\"time\"=\u003e\"2015-07-09T09:03:31Z\", \"count\"=\u003e32, \"value\"=\u003e0.9673}\n#   -\u003e {\"time\"=\u003e\"2015-07-09T09:03:49Z\", \"count\"=\u003e122, \"value\"=\u003e0.4444}]\n# time_series_1 [ {\"region\"=\u003e\"us\"} ]\n#   -\u003e {\"time\"=\u003e\"2015-07-09T09:02:54Z\", \"count\"=\u003e55, \"value\"=\u003e0.4343}\n```\n\nIf you would rather receive points with integer timestamp, it's possible to set\n`epoch` parameter:\n\n``` ruby\n# globally, on client initialization:\ninfluxdb = InfluxDB::Client.new database, epoch: 's'\n\ninfluxdb.query 'select * from time_series group by region'\n# [\n#   {\n#     \"name\"=\u003e\"time_series\",\n#     \"tags\"=\u003e{\"region\"=\u003e\"uk\"},\n#     \"values\"=\u003e[\n#       {\"time\"=\u003e1438411376, \"count\"=\u003e32, \"value\"=\u003e0.9673}\n#     ]\n#   }\n# ]\n\n# or for a specific query call:\ninfluxdb.query 'select * from time_series group by region', epoch: 'ms'\n# [\n#   {\n#     \"name\"=\u003e\"time_series\",\n#     \"tags\"=\u003e{\"region\"=\u003e\"uk\"},\n#     \"values\"=\u003e[\n#       {\"time\"=\u003e1438411376000, \"count\"=\u003e32, \"value\"=\u003e0.9673}\n#     ]\n#   }\n# ]\n```\n\nWorking with parameterized query strings works as expected:\n\n``` ruby\ninfluxdb = InfluxDB::Client.new database\n\nnamed_parameter_query = \"select * from time_series_0 where time \u003e %{min_time}\"\ninfluxdb.query named_parameter_query, params: { min_time: 0 }\n# compiles to:\n#   select * from time_series_0 where time \u003e 0\n\npositional_params_query = \"select * from time_series_0 where f = %{1} and i \u003c %{2}\"\ninfluxdb.query positional_params_query, params: [\"foobar\", 42]\n# compiles to (note the automatic escaping):\n#   select * from time_series_0 where f = 'foobar' and i \u003c 42\n```\n\n## Advanced Topics\n\n### Administrative tasks\n\nCreate a database:\n\n``` ruby\ndatabase = 'site_development'\n\ninfluxdb.create_database(database)\n```\n\nDelete a database:\n\n``` ruby\ndatabase = 'site_development'\n\ninfluxdb.delete_database(database)\n```\n\nList databases:\n\n``` ruby\ninfluxdb.list_databases\n```\n\nCreate a user for a database:\n\n``` ruby\ndatabase = 'site_development'\nnew_username = 'foo'\nnew_password = 'bar'\npermission = :write\n\n# with all permissions\ninfluxdb.create_database_user(database, new_username, new_password)\n\n# with specified permission - options are: :read, :write, :all\ninfluxdb.create_database_user(database, new_username, new_password, permissions: permission)\n```\n\nUpdate a user password:\n\n``` ruby\nusername = 'foo'\nnew_password = 'bar'\n\ninfluxdb.update_user_password(username, new_password)\n```\n\nGrant user privileges on database:\n\n``` ruby\nusername = 'foobar'\ndatabase = 'foo'\npermission = :read # options are :read, :write, :all\n\ninfluxdb.grant_user_privileges(username, database, permission)\n```\n\nRevoke user privileges from database:\n\n``` ruby\nusername = 'foobar'\ndatabase = 'foo'\npermission = :write # options are :read, :write, :all\n\ninfluxdb.revoke_user_privileges(username, database, permission)\n```\nDelete a user:\n\n``` ruby\nusername = 'foobar'\n\ninfluxdb.delete_user(username)\n```\n\nList users:\n\n``` ruby\ninfluxdb.list_users\n```\n\nCreate cluster admin:\n\n``` ruby\nusername = 'foobar'\npassword = 'pwd'\n\ninfluxdb.create_cluster_admin(username, password)\n```\n\nList cluster admins:\n\n``` ruby\ninfluxdb.list_cluster_admins\n```\n\nRevoke cluster admin privileges from user:\n\n``` ruby\nusername = 'foobar'\n\ninfluxdb.revoke_cluster_admin_privileges(username)\n```\n\n### Continuous Queries\n\nList continuous queries of a database:\n\n``` ruby\ndatabase = 'foo'\n\ninfluxdb.list_continuous_queries(database)\n```\n\nCreate a continuous query for a database:\n\n``` ruby\ndatabase = 'foo'\nname = 'clicks_count'\nquery = 'SELECT COUNT(name) INTO clicksCount_1h FROM clicks GROUP BY time(1h)'\n\ninfluxdb.create_continuous_query(name, database, query)\n```\n\nAdditionally, you can specify the resample interval and the time range over\nwhich the CQ runs:\n\n``` ruby\ninfluxdb.create_continuous_query(name, database, query, resample_every: \"10m\", resample_for: \"65m\")\n```\n\nDelete a continuous query from a database:\n\n``` ruby\ndatabase = 'foo'\nname = 'clicks_count'\n\ninfluxdb.delete_continuous_query(name, database)\n```\n\n### Retention Policies\n\nList retention policies of a database:\n\n``` ruby\ndatabase = 'foo'\n\ninfluxdb.list_retention_policies(database)\n```\n\nCreate a retention policy for a database:\n\n``` ruby\ndatabase    = 'foo'\nname        = '1h.cpu'\nduration    = '10m'\nreplication = 2\n\ninfluxdb.create_retention_policy(name, database, duration, replication)\n```\n\nDelete a retention policy from a database:\n\n``` ruby\ndatabase = 'foo'\nname     = '1h.cpu'\n\ninfluxdb.delete_retention_policy(name, database)\n```\n\nAlter a retention policy for a database:\n\n``` ruby\ndatabase    = 'foo'\nname        = '1h.cpu'\nduration    = '10m'\nreplication = 2\n\ninfluxdb.alter_retention_policy(name, database, duration, replication)\n```\n\n### Reading data\n\n#### (De-) Normalization\n\nBy default, InfluxDB::Client will denormalize points (received from InfluxDB as\ncolumns and rows). If you want to get *raw* data add `denormalize: false` to\nthe initialization options or to query itself:\n\n``` ruby\ninfluxdb.query 'select * from time_series_1 group by region', denormalize: false\n\n# [\n#   {\n#     \"name\"=\u003e\"time_series_1\",\n#     \"tags\"=\u003e{\"region\"=\u003e\"uk\"},\n#     \"columns\"=\u003e[\"time\", \"count\", \"value\"],\n#     \"values\"=\u003e[\n#       [\"2015-07-09T09:03:31Z\", 32, 0.9673],\n#       [\"2015-07-09T09:03:49Z\", 122, 0.4444]\n#     ]\n#   },\n#   {\n#     \"name\"=\u003e\"time_series_1\",\n#     \"tags\"=\u003e{\"region\"=\u003e\"us\"},\n#     \"columns\"=\u003e[\"time\", \"count\", \"value\"],\n#     \"values\"=\u003e[\n#       [\"2015-07-09T09:02:54Z\", 55, 0.4343]\n#     ]\n#   }\n# ]\n\n\ninfluxdb.query 'select * from time_series_1 group by region', denormalize: false do |name, tags, points|\n  printf \"%s [ %p ]\\n\", name, tags\n  points.each do |key, values|\n    printf \"  %p -\u003e %p\\n\", key, values\n  end\nend\n\n# time_series_1 [ {\"region\"=\u003e\"uk\"} ]\n#   columns -\u003e [\"time\", \"count\", \"value\"]\n#   values -\u003e [[\"2015-07-09T09:03:31Z\", 32, 0.9673], [\"2015-07-09T09:03:49Z\", 122, 0.4444]]}\n# time_series_1 [ {\"region\"=\u003e\"us\"} ]\n#   columns -\u003e [\"time\", \"count\", \"value\"]\n#   values -\u003e [[\"2015-07-09T09:02:54Z\", 55, 0.4343]]}\n```\n\nYou can also pick the database to query from:\n\n```\ninfluxdb.query 'select * from time_series_1', database: 'database'\n```\n\n#### Streaming response\n\nIf you expect large quantities of data in a response, you may want to enable\nJSON streaming by setting a `chunk_size`:\n\n``` ruby\ninfluxdb = InfluxDB::Client.new database,\n  username:   username,\n  password:   password,\n  chunk_size: 10000\n```\n\nSee the [official documentation][docs-chunking] for more details.\n\n\n#### Retry\n\nBy default, InfluxDB::Client will keep trying (with exponential fall-off) to\nconnect to the database until it gets a connection. If you want to retry only\na finite number of times (or disable retries altogether), you can pass the\n`:retry` option.\n\n`:retry` can be either `true`, `false` or an `Integer` to retry infinite times,\ndisable retries or retry a finite number of times, respectively. Passing `0` is\nequivalent to `false` and `-1` is equivalent to `true`.\n\n```\n$ irb -r influxdb\n\u003e influxdb = InfluxDB::Client.new 'database', retry: 8\n=\u003e #\u003cInfluxDB::Client:0x00000002bb5ce0 ...\u003e\n\n\u003e influxdb.query 'select * from serie limit 1'\nE, [2016-08-31T23:55:18.287947 #23476] WARN  -- InfluxDB: Failed to contact host localhost: #\u003cErrno::ECONNREFUSED: Failed to open TCP connection to localhost:8086 (Connection refused - connect(2) for \"localhost\" port 8086)\u003e - retrying in 0.01s.\nE, [2016-08-31T23:55:18.298455 #23476] WARN  -- InfluxDB: Failed to contact host localhost: #\u003cErrno::ECONNREFUSED: Failed to open TCP connection to localhost:8086 (Connection refused - connect(2) for \"localhost\" port 8086)\u003e - retrying in 0.02s.\nE, [2016-08-31T23:55:18.319122 #23476] WARN  -- InfluxDB: Failed to contact host localhost: #\u003cErrno::ECONNREFUSED: Failed to open TCP connection to localhost:8086 (Connection refused - connect(2) for \"localhost\" port 8086)\u003e - retrying in 0.04s.\nE, [2016-08-31T23:55:18.359785 #23476] WARN  -- InfluxDB: Failed to contact host localhost: #\u003cErrno::ECONNREFUSED: Failed to open TCP connection to localhost:8086 (Connection refused - connect(2) for \"localhost\" port 8086)\u003e - retrying in 0.08s.\nE, [2016-08-31T23:55:18.440422 #23476] WARN  -- InfluxDB: Failed to contact host localhost: #\u003cErrno::ECONNREFUSED: Failed to open TCP connection to localhost:8086 (Connection refused - connect(2) for \"localhost\" port 8086)\u003e - retrying in 0.16s.\nE, [2016-08-31T23:55:18.600936 #23476] WARN  -- InfluxDB: Failed to contact host localhost: #\u003cErrno::ECONNREFUSED: Failed to open TCP connection to localhost:8086 (Connection refused - connect(2) for \"localhost\" port 8086)\u003e - retrying in 0.32s.\nE, [2016-08-31T23:55:18.921740 #23476] WARN  -- InfluxDB: Failed to contact host localhost: #\u003cErrno::ECONNREFUSED: Failed to open TCP connection to localhost:8086 (Connection refused - connect(2) for \"localhost\" port 8086)\u003e - retrying in 0.64s.\nE, [2016-08-31T23:55:19.562428 #23476] WARN  -- InfluxDB: Failed to contact host localhost: #\u003cErrno::ECONNREFUSED: Failed to open TCP connection to localhost:8086 (Connection refused - connect(2) for \"localhost\" port 8086)\u003e - retrying in 1.28s.\nInfluxDB::ConnectionError: Tried 8 times to reconnect but failed.\n```\n\n## List of configuration options\n\nThis index might be out of date. Please refer to `InfluxDB::DEFAULT_CONFIG_OPTIONS`,\nfound in `lib/influxdb/config.rb` for the source of truth.\n\n| Category        | Option                  | Default value | Notes\n|:----------------|:------------------------|:--------------|:-----\n| HTTP connection | `:host` or `:hosts`     | \"localhost\"   | can be an array and can include port\n|                 | `:port`                 | 8086          | fallback port, unless provided by `:host` option\n|                 | `:prefix`               | \"\"            | URL path prefix (e.g. server is behind reverse proxy)\n|                 | `:username`             | \"root\"        | user credentials\n|                 | `:password`             | \"root\"        | user credentials\n|                 | `:open_timeout`         | 5             | socket timeout\n|                 | `:read_timeout`         | 300           | socket timeout\n|                 | `:auth_method`          | \"params\"      | \"params\", \"basic_auth\" or \"none\"\n| Retry           | `:retry`                | -1            | max. number of retry attempts (reading and writing)\n|                 | `:initial_delay`        | 0.01          | initial wait time (doubles every retry attempt)\n|                 | `:max_delay`            | 30            | max. wait time when retrying\n| SSL/HTTPS       | `:use_ssl`              | false         | whether or not to use SSL (HTTPS)\n|                 | `:verify_ssl`           | true          | verify vertificate when using SSL\n|                 | `:ssl_ca_cert`          | false         | path to or name of CA cert\n| Database        | `:database`             | *empty*       | name of database\n|                 | `:time_precision`       | \"s\"           | time resolution for data send to server\n|                 | `:epoch`                | false         | time resolution for server responses (false = server default)\n| Writer          | `:async`                | false         | Async options hash, [details here](#async-options)\n|                 | `:udp`                  | false         | UDP connection info, [details here](#udp-options)\n|                 | `:discard_write_errors` | false         | suppress UDP socket errors\n| Query           | `:chunk_size`           | *empty*       | [details here](#streaming-response)\n|                 | `:denormalize`          | true          | format of result\n\n## Testing\n\n```\ngit clone git@github.com:influxdata/influxdb-ruby.git\ncd influxdb-ruby\nbundle\nbundle exec rake\n```\n\n## Contributing\n\n- Fork this repository on GitHub.\n- Make your changes.\n  - Add tests.\n  - Add an entry in the `CHANGELOG.md` in the \"unreleased\" section on top.\n- Run the tests: `bundle exec rake`.\n- Send a pull request.\n  - Please rebase against the master branch.\n- If your changes look good, we'll merge them.\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FInfluxCommunity%2Finfluxdb-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FInfluxCommunity%2Finfluxdb-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FInfluxCommunity%2Finfluxdb-ruby/lists"}