influxdb-client 1.12.0.pre.1596 → 1.12.0

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.
@@ -1,35 +0,0 @@
1
- $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
2
- require 'influxdb-client'
3
-
4
- username = 'username'
5
- password = 'password'
6
-
7
- database = 'telegraf'
8
- retention_policy = 'autogen'
9
-
10
- bucket = "#{database}/#{retention_policy}"
11
-
12
- client = InfluxDB2::Client.new('http://localhost:8086',
13
- "#{username}:#{password}",
14
- bucket: bucket,
15
- org: '-',
16
- use_ssl: false,
17
- precision: InfluxDB2::WritePrecision::NANOSECOND)
18
-
19
- puts '*** Write Points ***'
20
-
21
- write_api = client.create_write_api
22
- point = InfluxDB2::Point.new(name: 'mem')
23
- .add_tag('host', 'host1')
24
- .add_field('used_percent', 21.43234543)
25
- puts point.to_line_protocol
26
- write_api.write(data: point)
27
-
28
- puts '*** Query Points ***'
29
-
30
- query_api = client.create_query_api
31
- query = "from(bucket: \"#{bucket}\") |> range(start: -1h)"
32
- result = query_api.query(query: query)
33
- result[0].records.each { |record| puts "#{record.time} #{record.measurement}: #{record.field} #{record.value}" }
34
-
35
- client.close!