delete Method

On This Page

Description

Deletes a TSDB table or or specific table items.

Note

When no filter parameter is set (start, end, filter, or metrics), the entire TSDB table and its schema file (.schema) are deleted.

Syntax

delete(backend, table[, filter='', start='', end='', if_missing=FAIL, metrics=[]])

Parameters

backend | end | if_missing | start | table

backend

The backend type — "tsdb" for the TSDB backend. See Backend Types.

  • Type: str
  • Requirement: Required
table

The relative path to the backend data — a directory in the target data container (as configured for the client object) that represents a TSDB table. For example, "mytable" or "examples/tsdb/my_metrics".

  • Type: str
  • Requirement: Required
start

Start (minimum) time for the delete operation — i.e., delete only items whose data sample time is at or after (>=) the specified start time.

  • Type: str
  • Requirement: Optional
  • Valid Values: A string containing an RFC 3339 time, a Unix timestamp in milliseconds, a relative time of the format "now" or "now-[0-9]+[mhd]" (where m = minutes, h = hours, and 'd' = days), or 0 for the earliest time. For example: "2016-01-02T15:34:26Z"; "1451748866"; "now-90m"; "0".
  • Default Value: "" when neither start nor end are set — to delete the entire TSDB table; one hour earlier than the end time (end - 1h) when end is set
end

End (maximum) time for the delete operation — i.e., delete only items whose data sample time is before or at (<=) the specified end time.

  • Type: str
  • Requirement: Optional
  • Valid Values: A string containing an RFC 3339 time, a Unix timestamp in milliseconds, a relative time of the format "now" or "now-[0-9]+[mhd]" (where m = minutes, h = hours, and 'd' = days), or 0 for the earliest time. For example: "2018-09-26T14:10:20Z"; "1537971006000"; "now-3h"; "now-7d".
  • Default Value: "" when neither start nor end are set — to delete the entire TSDB table;"now" when start is set
if_missing

Determines whether to raise an error when the specified TSDB table (table) doesn’t exist.

  • Type: pb.ErrorOptions enumeration. To use the enumeration, import the frames_pb2 module; for example:

    from v3io_frames import frames_pb2 as fpb
    
  • Requirement: Optional
  • Valid Values: FAIL to raise an error when the specified table doesn’t exist; IGNORE to ignore this
  • Default Value: FAIL

Errors

In case of an error, the method raises a DeleteError error.

Examples

Following are some usage examples for the delete method of the Frames TSDB backend.

  1. Delete a mytsdb TSDB table in the client’s data container (table). Because no filter parameter is set (start, end, filter, or metrics), the entire table is deleted.

    tsdb_table = "mytsdb"
    client.delete(backend="tsdb", table=tsdb_table)
    
  2. Delete a tsdb/my_metrics TSDB table in the client’s data container (table); don’t raise an error if the table doesn’t exist (if_missing = IGNORE):

    from v3io_frames import frames_pb2 as fpb
    tsdb_table = "/tsdb/my_metrics"
    client.delete("tsdb", table=tsdb_table, if_missing=fpb.IGNORE)
    
  3. For a mytsdb TSDB table in the client’s data container (table), delete all items for data that was sampled during the last 24 hours — between now-1d (start) and now (end):

    tsdb_table = "mytsdb"
    client.delete("tsdb", table=tsdb_table, start="now-1d", end="now")
    

See Also