All Products
Search
Document Center

Tablestore:Delete time series metadata

Last Updated:Jan 19, 2024

You can call the DeleteTimeseriesMeta operation to delete the metadata of multiple time series at a time.

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

A time series identifier is used to identify a time series. You can specify multiple time series identifiers to delete the metadata of multiple time series. The following table describes the parameter.

ParameterDescription
timeseriesKeyThe identifier of the time series. The identifier includes the following content:
  • measurementName: the measurement name of the time series.
  • dataSource: the data source of the time series. You can leave this parameter empty.
  • tags: the tags of the time series. The tags are multiple key-value pairs of the STRING type.

Example

The following sample code provides an example on how to delete some time series from a time series table:

func DeleteTimeseriesMetaSample(tsClient *tablestore.TimeseriesClient, timeseriesTableName string) {
    fmt.Println("[Info]: Begin to delete timeseries meta: ", timeseriesTableName)
    // Construct a request to delete time series metadata. 
    deleteTimeseriesMetaRequest := tablestore.NewDeleteTimeseriesMetaRequest(timeseriesTableName) 
    for i := 0; i < 10; i++ {
        timeseriesKey := tablestore.NewTimeseriesKey()
        timeseriesKey.SetMeasurementName("cpu")
        timeseriesKey.SetDataSource("host_" + strconv.Itoa(i))
        timeseriesKey.AddTag("region", "hangzhou")
        timeseriesKey.AddTag("os", "Ubuntu16.04")
        deleteTimeseriesMetaRequest.AddTimeseriesKeys(timeseriesKey)
    }
    deleteTimeseriesMetaResponse, err := tsClient.DeleteTimeseriesMeta(deleteTimeseriesMetaRequest)
    if err != nil {
        fmt.Println("[Error]: Failed to delete timeseries meta with error: ", err)
        return
    }
    fmt.Println("[Info]: DeleteTimeseriesMeta finished! RequestId: ", deleteTimeseriesMetaResponse.RequestId)
}