You can call the QueryTimeseriesMeta operation to retrieve time series that meet multiple specified conditions.

Prerequisites

  • Time series data is written to the time series table. For more information, see Write time series data.
  • The TimeseriesClient is initialized. For more information, see Initialization.

Parameters

The metaQueryCondition parameter specifies the conditions for a time series retrieval. The conditions include compositeMetaQueryCondition, measurementMetaQueryCondition, dataSourceMetaQueryCondition, tagMetaQueryCondition, attributeMetaQueryCondition, and updateTimeMetaQueryCondition. The following table describes the parameters.

ParameterDescription
compositeMetaQueryConditionThe composite condition that includes the following content:
  • operator: the logical operator. Valid values: AND, OR, and NOT.
  • subConditions: the subconditions that can be combined by using operators for complex queries.
measurementMetaQueryConditionThe measurement name condition that includes the following content:
  • operator: the relational operator or the prefix match condition. Valid values for the relational operator: =, !=, >, >=, <, and <=.
  • value: the measurement name of the time series that you want to retrieve. Type: STRING.
dataSourceMetaQueryConditionThe data source condition that includes the following content:
  • operator: the relational operator or the prefix match condition. Valid values for the relational operator: =, !=, >, >=, <, and <=.
  • value: the data source of the time series that you want to retrieve. Type: STRING.
tagMetaQueryConditionThe tag condition that includes the following content:
  • operator: the relational operator or the prefix match condition. Valid values for the relational operator: =, !=, >, >=, <, and <=.
  • value: the tag of the time series that you want to retrieve. Type: STRING.
attributeMetaQueryConditionThe attribute condition for the metadata of the time series. The attribute condition includes the following content:
  • operator: the relational operator or the prefix match condition. Valid values for the relational operator: =, !=, >, >=, <, and <=.
  • attributeName: the name of the attribute. Type: STRING.
  • value: the value of the attribute. Type: STRING.
updateTimeMetaQueryConditionThe update time condition for the metadata of the time series. The update time condition includes the following content:
  • operator: the relational operator. Valid values: =, !=, >, >=, <, and <=.
  • timeInUs: the timestamp when the metadata of the time series is updated. Unit: microseconds.

Example

/**
 * Use QueryTimeseriesMetaSample to query the metric name, data source, and tag information of a specific time series in a time series table based on a specific condition, which can be a composite condition. 
 */
func QueryTimeseriesMetaSample(client *tablestore.TimeseriesClient , timeseriesTableName string) {
    fmt.Println("[Info]: Begin to query timeseries table meta!")

    // Construct multiple query conditions. 
    measurementMetaQueryCondition := tablestore.NewMeasurementQueryCondition(tablestore.OP_GREATER_EQUAL , "")
    datasourceMetaQueryCondition := tablestore.NewDataSourceMetaQueryCondition(tablestore.OP_GREATER_EQUAL , "")
    tagMetaQueryCondition := tablestore.NewTagMetaQueryCondition(tablestore.OP_GREATER_THAN , "City" , "")

    // Construct a composite condition. 
    compsiteMetaQueryCondition := tablestore.NewCompositeMetaQueryCondition(tablestore.OP_AND)
    compsiteMetaQueryCondition.AddSubConditions(measurementMetaQueryCondition)
    compsiteMetaQueryCondition.AddSubConditions(datasourceMetaQueryCondition)
    compsiteMetaQueryCondition.AddSubConditions(tagMetaQueryCondition)

    // Construct the query request. 
    queryTimeseriesMetaRequest := tablestore.NewQueryTimeseriesMetaRequest(timeseriesTableName)
    queryTimeseriesMetaRequest.SetCondition(compsiteMetaQueryCondition)
    queryTimeseriesMetaRequest.SetLimit(-1)

    // Call the time series client to execute the query request. 
    queryTimeseriesTableResponse , err := client.QueryTimeseriesMeta(queryTimeseriesMetaRequest)
    if err != nil {
        fmt.Println("[Error]: Query timeseries table meta failed with error: " , err)
        return
    }
    fmt.Println("[Info]: Query timeseries table meta succeed: ")
    for i := 0; i < len(queryTimeseriesTableResponse.GetTimeseriesMetas()); i++ {
        curTimeseriesMeta := queryTimeseriesTableResponse.GetTimeseriesMetas()[i]
        fmt.Println("[Info]: Meta_" , i , ": " , "Measurement: " , curTimeseriesMeta.GetTimeseriesKey().GetMeasurementName() ,
            "Source: " , curTimeseriesMeta.GetTimeseriesKey().GetDataSource() ,
            "Tags: " , curTimeseriesMeta.GetTimeseriesKey().GetTagsSlice() ,
            "Attrs: " , curTimeseriesMeta.GetAttributeSlice())
    }
    fmt.Println("[Info]: QueryTimeseriesMetaSample finished !")
}