All Products
Search
Document Center

Tablestore:Update time series

Last Updated:Apr 11, 2025

You can call the UpdateTimeseriesMeta operation to update the properties in time series metadata. If the time series metadata that you want to update does not exist, the time series metadata is added. You can call this operation to update the metadata of multiple time series at the same time.

Prerequisites

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

Parameters

The following table describes the parameters included in request.

Parameter

Description

timeseries_tablename (Required)

The name of the time series table.

metas (Required)

The list of time series metadata. Time series metadata consists of time series identifiers and time series properties.

  • timeseriesKey (Required): The time series identifiers. This parameter includes the following configuration items:

    • measurement_name (Required): The measurement name of the time series.

    • data_source (Required): The data source information.

    • tags (Required): The tag information of the time series, which consists of multiple key-value pairs.

  • attributes (Required): The property information of the time series, which consists of multiple key-value pairs.

Example

The following sample code provides an example on how to update the properties in the metadata of time series in a time series table.

# The tag information of the time series.
tags = {"tag1": "t1", "tag2": "t2"}
# The time series identifiers.
key = TimeseriesKey("measure1", "datasource1", tags)
# The property information of the time series.
attri = {"aaa": "bbb", "ccc": "ddd"}

try:
    meta = TimeseriesMeta(key, attri)
    request = UpdateTimeseriesMetaRequest("<TIMESERIES_TABLE_NAME>", [meta])
    
    # Call the operation to update the time series metadata.
    ots_client.update_timeseries_meta(request)
    print("update timeseries metas succeeded.")
except Exception as e:
    # If an exception is thrown, the update fails. Handle the exception.
    print("update timeseries metas failed. %s" % e)