All Products
Search
Document Center

Tablestore:Delete time series

Last Updated:Feb 27, 2026

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

Prerequisites

A TimeseriesClient is initialized. For more information, see Initialize a Tablestore client.

Request parameters

To delete time series metadata, you must specify the time series identifiers of the time series whose metadata you want to delete. You can specify multiple time series identifiers to perform a batch deletion.

ParameterTypeRequiredDescription
timeseriesKeyTimeseriesKeyYesThe identifier of a time series. A timeseriesKey consists of the following components:

TimeseriesKey components

ComponentTypeRequiredDescription
measurementNamestringYesThe measurement name of the time series.
dataSourcestringNoThe data source of the time series. You can leave this parameter empty.
tagsmap[string]stringNoThe tags of the time series. Tags are key-value pairs of the STRING type.

Sample code

The following sample code shows how to delete the metadata of 10 time series from a time series table. Each time series is identified by a combination of a measurement name, a data source, and tags.

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)
}

The following table describes the key steps in the sample code.

StepDescription
Create a requestCall tablestore.NewDeleteTimeseriesMetaRequest(timeseriesTableName) to create a delete request for the specified time series table.
Specify time series identifiersCreate TimeseriesKey objects by calling tablestore.NewTimeseriesKey(), and then set the measurement name, data source, and tags for each time series.
Add identifiers to the requestCall deleteTimeseriesMetaRequest.AddTimeseriesKeys(timeseriesKey) to add each time series identifier to the request.
Send the requestCall tsClient.DeleteTimeseriesMeta(deleteTimeseriesMetaRequest) to send the request. The response contains the RequestId.

References