Explore data using InfluxQL

To start exploring data with InfluxQL, do the following:

  1. Verify your bucket has a database and retention policy (DBRP) mapping by listing DBRP mappings for your bucket. If not, create a new DBRP mapping.

  2. Configure timestamps in the InfluxQL shell.

  3. (Optional) If you would like to use the data used in the examples below, download the NOAA sample data.

  4. Use the InfluxQL SELECT statement with other key clauses to explore your data.

SELECT statement

Use the SELECT statement to query data from a particular measurement or measurements.

  1. SELECT <field_key>[,<field_key>,<tag_key>] FROM <measurement_name>[,<measurement_name>]

Read more


WHERE clause

Use the WHERE clause to filter data based on fields, tags, and/or timestamps.

  1. SELECT_clause FROM_clause WHERE <conditional_expression> [(AND|OR) <conditional_expression> [...]]

Read more


GROUP BY clause

Use the GROUP BY clause to group query results by one or more specified tags and/or a specified time interval.

  1. SELECT_clause FROM_clause [WHERE_clause] GROUP BY [* | <tag_key>[,<tag_key]]

Read more


ORDER BY clause

Use the ORDER BY clause to sort data in ascending or descending order.

  1. SELECT_clause FROM_clause [WHERE_clause] [GROUP_BY_clause] ORDER BY time DESC

Read more


LIMIT and SLIMIT clauses

Use the LIMIT and SLIMIT clauses to limit the number of points and series returned in queries.

  1. SELECT_clause FROM_clause [WHERE_clause] [GROUP_BY_clause] [ORDER_BY_clause] LIMIT <N>

Read more


OFFSET and SOFFSET clauses

Use the OFFSET and SOFFSET clauses to paginate points and series.

  1. SELECT_clause FROM_clause [WHERE_clause] [GROUP_BY_clause] [ORDER_BY_clause] LIMIT_clause OFFSET <N> [SLIMIT_clause]

Read more


Time and timezone queries

Explore InfluxQL features used specifically for working with time. Use the tz (timezone) clause to return the UTC offset for the specified timezone.

  1. SELECT_clause FROM_clause [WHERE_clause] [GROUP_BY_clause] [ORDER_BY_clause] [LIMIT_clause] [OFFSET_clause] [SLIMIT_clause] [SOFFSET_clause] tz('<time_zone>')

Read more


Subqueries

Use a subquery to apply a query as a condition in the enclosing query.

  1. SELECT_clause FROM ( SELECT_statement ) [...]

Read more


Regular expressions

Use regular expressions to match patterns in your data.

  1. SELECT /<regular_expression_field_key>/ FROM /<regular_expression_measurement>/ WHERE [<tag_key> <operator> /<regular_expression_tag_value>/ | <field_key> <operator> /<regular_expression_field_value>/] GROUP BY /<regular_expression_tag_key>/

Read more


Download sample data

The example InfluxQL queries in this documentation use publicly available National Oceanic and Atmospheric Administration (NOAA) data.

To download a subset of NOAA data used in examples, run the script under NOAA water sample data (for example, copy and paste the script into your Data Explorer - Script Editor), and replace “example-org” in the script with the name of your InfluxDB organization.

Let’s get acquainted with this subsample of the data in the h2o_feet measurement:

Output:

Name: h2o_feet

timelevel descriptionlocationwater_level
2019-08-18T00:00:00Zbetween 6 and 9 feetcoyote_creek8.1200000000
2019-08-18T00:00:00Zbelow 3 feetsanta_monica2.0640000000
2019-08-18T00:06:00Zbetween 6 and 9 feetcoyote_creek8.0050000000
2019-08-18T00:06:00Zbelow 3 feetsanta_monica2.1160000000
2019-08-18T00:12:00Zbetween 6 and 9 feetcoyote_creek7.8870000000
2019-08-18T00:12:00Zbelow 3 feetsanta_monica2.0280000000

The data in the h2o_feet measurement occurs at six-minute time intervals. This measurement has one tag key (location) which has two tag values: coyote_creek and santa_monica. The measurement also has two fields: level description stores string field values and water_level stores float field values.

Configure timestamps in the InfluxQL shell

By default, the InfluxQL shell returns timestamps in nanosecond UNIX epoch format by default. To return human-readable RFC3339 timestamps instead of Unix nanosecond timestamps, use the precision helper command ` to configure the timestamp format:

  1. precision rfc3339

The InfluxDB API returns timestamps in RFC3339 format by default. Specify alternative formats with the epoch query string parameter.