All Products
Search
Document Center

Tablestore:Delete time series

Last Updated:Apr 25, 2025

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

Prerequisites

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

Parameters

Time series identifiers are used to identify a time series. You can specify time series identifiers of multiple time series to delete the metadata of multiple time series. The following table describes the parameters.

Parameter

Description

timeseriesKey

The identifiers of the time series, which include the following items:

  • measurementName: the metric name of the time series.

  • dataSource: the data source of the time series. You can leave this item 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 the metadata of multiple time series in a time series table:

private static void deleteTimeseriesMeta(TimeseriesClient client) {
    List<TimeseriesKey> timeseriesKeyList = new ArrayList<TimeseriesKey>();
    for (int i = 0; i < 10; i++) {
        Map<String, String> tags = new HashMap<String, String>();
        tags.put("region", "hangzhou");
        tags.put("os", "Ubuntu16.04");
        // Construct time series identifier.
        TimeseriesKey timeseriesKey = new TimeseriesKey("cpu", "host_" + i, tags);
        timeseriesKeyList.add(timeseriesKey);
    }
    // Specify the name of the time series table.
    String tableName = "<TIME_SERIES_TABLE>";
    DeleteTimeseriesMetaRequest deleteTimeseriesMetaRequest = new DeleteTimeseriesMetaRequest(tableName);
    deleteTimeseriesMetaRequest.setTimeseriesKeys(timeseriesKeyList);
    DeleteTimeseriesMetaResponse deleteTimeseriesMetaResponse = client.deleteTimeseriesMeta(deleteTimeseriesMetaRequest);
    // Check whether the metadata of the time series is deleted.
    if (!deleteTimeseriesMetaResponse.isAllSuccess()) {
        for (DeleteTimeseriesMetaResponse.FailedRowResult failedRowResult : deleteTimeseriesMetaResponse.getFailedRows()) {
            System.out.println(failedRowResult.getIndex());
            System.out.println(failedRowResult.getError());
        }
    }
}