Using the InfluxDBClient.query()
function will return a ResultSet
Object.
A ResultSet can be browsed in several ways. Its get_points
method can be used to retrieve points generators that filter either by measurement, tags, or both.
Using rs.get_points()
will return a generator for all the points in the ResultSet.
Using rs.get_points('cpu')
will return a generator for all the points that are in a series with measurement name cpu
, no matter the tags.
rs = cli.query("SELECT * from cpu") cpu_points = list(rs.get_points(measurement='cpu'))
Using rs.get_points(tags={'host_name': 'influxdb.com'})
will return a generator for all the points that are tagged with the specified tags, no matter the measurement name.
rs = cli.query("SELECT * from cpu") cpu_influxdb_com_points = list(rs.get_points(tags={"host_name": "influxdb.com"}))
Using measurement name and tags will return a generator for all the points that are in a series with the specified measurement name AND whose tags match the given tags.
rs = cli.query("SELECT * from cpu") points = list(rs.get_points(measurement='cpu', tags={'host_name': 'influxdb.com'}))
See the :ref:`api-documentation` page for more information.