Using InfluxQL#

This guide describes how to use the InfluxQL query language with the EFD client.

To execute InfluxQL queries you can use the _influx_client.query() method in conjunction with the EFD client.

from lsst_efd_client import EfdClient

client = EfdClient("usdf_efd")
query = '''SELECT vacuum FROM "lsst.sal.ATCamera.vacuum" WHERE time > now() - 1h'''
await client._influx_client.query(query)

This query returns vaccum measurements for the ATCamera in the last hour. It uses the the InfluxQL now() function to query a time range relative to the server’s current time.

See InfluxQL time syntax documentation for detailed information on how to specify time ranges in InfluxQL queries.

The EFD client helper function build_time_range_query() can also be used to build InfluxQL queries for a topic and time range, which can then be executed with the _influx_client.query() method.

Note

InfluxQL queries are also used in the Chronograf UI, so using InfluxQL queries with the EFD client can be helpful when exploring data in both contexts.

In the following notebooks, you can find more examples using InfluxQL such as downsampling data with GROUP by time(), using aggregation functions, and chunked queries for efficient retrieval of large datasets:

Querying the EFD with InfluxQL

Learn how to use the EFD client and InfluxQL to query EFD data.

https://github.com/lsst-ts/lsst-efd-client/blob/main/docs/user-guide/notebooks/UsingInfluxQL.ipynb
Downsample data with GROUP BY time()

Learn how to downsample data with InfluxQL GROUP BY time().

https://github.com/lsst-ts/lsst-efd-client/blob/main/docs/user-guide/notebooks/Downsampling.ipynb
Chunked queries: Efficient Data Retrieval

Learn how to return chunked responses with the EFD client for efficient retrieval of large datasets.

https://github.com/lsst-ts/lsst-efd-client/blob/main/docs/user-guide/notebooks/ChunkedQueries.ipynb

See the InfluxQL documentation for a complete reference to the InfluxQL capabilities and query syntax.