delete Method
Description
Deletes a TSDB table or or specific table items.
Syntax
delete(backend, table[, filter='', start='', end='', if_missing=FAIL, metrics=[]])
Parameters
- backend
The backend type —
"tsdb"
for the TSDB backend. See Backend Types.- Type:
str
- Requirement: Required
- Type:
- 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
- Type:
- 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]"
(wherem
= 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 neitherstart norend are set — to delete the entire TSDB table; one hour earlier than the end time (end - 1h
) whenend is set
- Type:
- 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]"
(wherem
= 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 neitherstart norend are set — to delete the entire TSDB table;"now"
whenstart is set
- Type:
- 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 theframes_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
Examples
Following are some usage examples for the
-
Delete a
mytsdb TSDB table in the client's data container (table ). Because no filter parameter is set (start ,end ,filter , ormetrics ), the entire table is deleted.tsdb_table = "mytsdb" client.delete(backend="tsdb", table=tsdb_table)
-
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)
-
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 — betweennow-1d
(start ) andnow
(end ):tsdb_table = "mytsdb" client.delete("tsdb", table=tsdb_table, start="now-1d", end="now")
See Also
- Deleting a TSDB (The TSDB CLI)
- Frames TSDB-Backend Overview
- Frames Client Constructor