Update time series

更新时间:
复制 MD 格式

Call the UpdateTimeseriesMeta operation to update properties in time series metadata. If the specified time series metadata does not exist, it is created automatically. You can update metadata for multiple time series in a single call.

Prerequisites

Before you begin, ensure that you have:

Parameters

The request parameter supports the following fields.

Parameter

Description

timeseries_tablename (Required)

The name of the time series table.

metas (Required)

A list of time series metadata objects. Each object contains a time series identifier and time series properties.

  • timeseriesKey (Required): The time series identifier, which consists of the following fields:

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

    • data_source (Required): The data source of the time series.

    • tags (Required): The tags of the time series, expressed as key-value pairs.

  • attributes (Required): The properties of the time series, expressed as key-value pairs.

Example

The following example updates properties in the metadata of a time series.

# Define the tags that identify the time series.
tags = {"tag1": "t1", "tag2": "t2"}

# Build the time series identifier.
key = TimeseriesKey("measure1", "datasource1", tags)

# Define the properties to update.
attri = {"aaa": "bbb", "ccc": "ddd"}

try:
    meta = TimeseriesMeta(key, attri)
    request = UpdateTimeseriesMetaRequest("<TIMESERIES_TABLE_NAME>", [meta])

    # Update the time series metadata.
    ots_client.update_timeseries_meta(request)
    print("update timeseries metas succeeded.")
except Exception as e:
    print("update timeseries metas failed. %s" % e)