Grafana Cloud Enterprise Open source
Last reviewed: July 23, 2026

AWS IoT SiteWise query editor

This document explains how to use the AWS IoT SiteWise query editor. The query editor supports a visual builder for the AWS IoT SiteWise APIs, an SQL clause builder, and a raw SQL code editor.

For general information about the Grafana query editor, refer to Query and transform data.

Before you begin

Before you build a query, ensure you have:

  • Configured the AWS IoT SiteWise data source.
  • Verified that your credentials have read access to the AWS IoT SiteWise assets and properties that you want to query.

Key concepts

If you’re new to AWS IoT SiteWise, these terms are used throughout the query editor.

TermDescription
AssetA representation of a device, piece of equipment, or process in AWS IoT SiteWise.
Asset modelA reusable template that defines the properties and hierarchies for a group of assets.
PropertyA measurement, metric, transform, or attribute that belongs to an asset, such as temperature or pressure.
Property aliasAn alternative name for a property, often an OPC-UA path, that you can use instead of an asset and property ID.
Time seriesA stream of timestamped values for a property.
AggregateA computed value over a time interval, such as the average or maximum.

Editor modes

Use the mode selector to switch between the three ways to build a query.

ModeDescription
BuilderA visual editor for the AWS IoT SiteWise APIs. Select a query type, assets, and properties.
Builder (SQL)A visual editor that builds an AWS IoT SiteWise SQL query clause by clause.
Code (SQL)A raw SQL editor with autocompletion for tables, columns, and macros.

The Builder (SQL) and Code (SQL) modes both run an AWS IoT SiteWise ExecuteQuery request and disable the client cache.

Switch between the Builder and SQL editor modes
Switch between the Builder and SQL editor modes

Query types

In Builder mode, select one of the following query types.

Query typeDescription
Get property valueReturns the latest value for one or more asset properties.
Get property value historyReturns the historical values for one or more asset properties over the dashboard time range.
Get property value aggregatesReturns aggregated values, such as averages, for one or more asset properties.
Get interpolated property valuesReturns interpolated values at a fixed resolution for one or more asset properties.
List assetsReturns a paginated list of assets, filtered by asset model or hierarchy level.
List asset modelsReturns the asset models in the Region.
List associated assetsReturns the child or parent assets associated with an asset.
List time seriesReturns the time series (data streams) in the Region.
The AWS IoT SiteWise visual query builder
The AWS IoT SiteWise visual query builder

Build a visual query

To build a query in Builder mode:

  1. Select the AWS IoT SiteWise data source.
  2. Select a Query type.
  3. Select a Region, or use Default to use the data source’s default Region.
  4. Select the assets and properties, or enter a property alias.
  5. Set any query-specific options, such as aggregates or resolution.

Select assets and properties

Property queries need either an asset and property, or a property alias.

FieldDescription
Property AliasOne or more property aliases, such as an OPC-UA path. Use this field instead of selecting an asset and property.
AssetOne or more assets. Enter an asset ID, an externalId: prefixed value, or a template variable.
PropertyOne or more properties for the selected assets. Property names support the * wildcard.

Click Explore to open the Asset Browser and navigate assets visually.

The Asset Browser for navigating assets and models
The Asset Browser for navigating assets and models

Set aggregates

For the Get property value aggregates query type, select one or more aggregate functions. You can display multiple aggregates for a single property.

AggregateDescription
AverageThe average of the values in the interval. Numeric properties only.
CountThe number of values in the interval.
MaxThe maximum value in the interval. Numeric properties only.
MinThe minimum value in the interval. Numeric properties only.
SumThe sum of the values in the interval. Numeric properties only.
StddevThe standard deviation of the values in the interval. Numeric properties only.
Multiple aggregates shown for a single property
Multiple aggregates shown for a single property

Set the resolution

For aggregate and interpolated queries, select a Resolution to control the interval that AWS IoT SiteWise uses to compute values. Aggregate queries offer the following resolutions. Interpolated queries offer additional finer resolutions, such as Second and 10 Seconds.

ResolutionDescription
AutoGrafana picks a resolution based on the time window, and switches to raw data if a resolution finer than one minute is needed.
MinuteOne point every minute (1m).
15 MinutesOne point every 15 minutes (15m).
HourOne point every hour (1h).
DayOne point every day (1d).

Resolution options also accept template variables.

Set query options

Use the Query options section to refine the results.

OptionDescription
QualityFilter values by quality: GOOD, BAD, or UNCERTAIN. The default is GOOD. Applies to history, aggregate, and interpolated queries.
TimeThe time ordering of the results: ASCENDING or DESCENDING. Applies to history and aggregate queries.
FormatThe response format: Table or Time series. Applies to history, aggregate, and interpolated queries.
Expand Time RangeInclude the last value before the time range and the next value after it. Applies to history and aggregate queries.
Format L4E Anomaly ResultParse Amazon Lookout for Equipment anomaly results into separate fields. Enabled by default. Applies to Get property value and Get property value history queries.
Client cacheCache query results older than 15 minutes for relative time ranges. Enabled by default.

Query-specific fields

Some query types have additional fields.

Query typeFields
List assetsModel ID to filter by asset model, and Filter set to Top Level or All. The All filter requires a model ID.
List associated assetsAsset Hierarchy to select a hierarchy, Parent to list parent assets, or All to list all child hierarchies.
List time seriesTime Series Type set to ALL, ASSOCIATED, or DISASSOCIATED, plus Alias Prefix or Asset Id.

Explore assets with the Asset Browser

The Asset Browser helps you find assets and properties without knowing their IDs. Click Explore next to the Asset field to open it.

The browser has two tabs.

  • Hierarchy: Navigate the asset tree. View parent assets, the selected asset, and child hierarchies, and search within each hierarchy.
  • By Model: Select an asset model, then search and select from the assets that use that model.

Build an SQL query

AWS IoT SiteWise supports an SQL dialect through the ExecuteQuery API. Use Builder (SQL) mode to construct a query clause by clause, or Code (SQL) mode to write raw SQL.

SQL builder clauses

In Builder (SQL) mode, construct the query with the following clauses. A query must include at least a SELECT and a FROM clause to be valid. A preview of the generated SQL appears as you build the query.

ClauseDescription
FromThe view to query. Select one of the AWS IoT SiteWise views.
SelectThe columns to return. Choose columns and optional aggregation functions, or select all columns.
WhereFilter conditions. Combine conditions with AND or OR.
Group ByThe columns to group by.
HavingFilter conditions on aggregated results. Available when a Group By clause is set.
Order ByThe column and direction, either Ascending or Descending.
LimitThe maximum number of rows to return. The default is 100.
The AWS IoT SiteWise SQL query builder
The AWS IoT SiteWise SQL query builder

Available views

The FROM clause supports the following AWS IoT SiteWise views.

ViewDescription
assetAsset metadata, such as name, description, model, and parent asset.
asset_propertyProperty metadata, such as name, alias, data type, and attributes.
raw_time_seriesRaw timestamped property values.
latest_value_time_seriesThe latest value for each time series.
precomputed_aggregatesPrecomputed aggregate values, such as average, sum, and count, at a resolution.
A data preview for an SQL query
A data preview for an SQL query

Write raw SQL

In Code (SQL) mode, write the query directly. The editor provides autocompletion for views, columns, macros, and template variables. Select the AWS Region from the editor header.

The default query is:

SQL
select $__selectAll from raw_time_series where $__timeFilter(event_timestamp)

Macros

Use macros in SQL queries to reference the dashboard time range and other dynamic values. Grafana replaces each macro before sending the query to AWS IoT SiteWise.

MacroDescription
$__selectAllExpands to all columns of the current FROM view.
$__timeFromThe start of the dashboard time range as a timestamp.
$__timeToThe end of the dashboard time range as a timestamp.
$__timeFilter(column)Filters the specified column to the dashboard time range.
$__autoResolution()Returns a resolution based on the panel interval when querying precomputed_aggregates.

Format Amazon Lookout for Equipment results

AWS IoT SiteWise can store Amazon Lookout for Equipment (L4E) anomaly detection results as a composite model property named AWS/L4E_ANOMALY_RESULT. When you enable Format L4E Anomaly Result on a Get property value or Get property value history query, Grafana replaces the original JSON with a frame that contains:

  • time: The timestamp of the prediction.
  • quality: The quality of the value.
  • anomaly_score: The anomaly score for the prediction.
  • prediction_reason: The reason for the prediction.
  • A diagnostic contribution field for each property that contributes to the anomaly.

Inspect query metadata

For Get property value aggregates queries, the data source attaches metadata to the results. To view it, open the panel inspector and select the metadata view. The inspector shows:

  • Resolution: The resolution used for the query, such as 1h.
  • Aggregates: The aggregate functions returned, such as AVERAGE or MAXIMUM.

Query examples

Use the following examples as starting points. The SQL examples use the views described in Available views.

Chart aggregated values with the visual builder

To chart the hourly average of an asset property:

  1. Set Query type to Get property value aggregates.
  2. Select the Asset and Property, or enter a Property Alias.
  3. Set Aggregate to Average and Resolution to Hour.
  4. Set Format to Time series.

Return raw property values

Return the raw values for a property over the dashboard time range:

SQL
select event_timestamp, double_value
from raw_time_series
where $__timeFilter(event_timestamp)
order by event_timestamp asc

Return raw values for a specific asset

Filter the raw values to a single asset:

SQL
select event_timestamp, double_value
from raw_time_series
where asset_id = '<YOUR_ASSET_ID>' and $__timeFilter(event_timestamp)
order by event_timestamp asc

Return the most recent value for each property

SQL
select property_alias, event_timestamp, double_value
from latest_value_time_series
order by property_alias

Return aggregates with automatic resolution

Use the $__autoResolution() macro to match the resolution to the panel interval:

SQL
select event_timestamp, average_value
from precomputed_aggregates
where resolution = '$__autoResolution()' and $__timeFilter(event_timestamp)
order by event_timestamp asc

List the assets that use an asset model

SQL
select asset_id, asset_name
from asset
where asset_model_id = '<YOUR_ASSET_MODEL_ID>'

Use cases

The query editor supports a range of industrial monitoring scenarios, for example:

  • Equipment monitoring: Visualize property values, such as temperature or pressure, across a fleet of assets.
  • Aggregated trends: Chart averages, maximums, and standard deviations over time to spot performance changes.
  • Anomaly detection: Surface Amazon Lookout for Equipment anomaly scores alongside the properties that contribute to them.

Next steps