TTL
Indicates the time-to-live of data.
Sample code
The following sample code is used to set the TTL. The unit of TTL is seconds.
tsdb.ttl(time);
The following sample code is used to query the TTL. The unit of TTL is seconds.
int ttl = tsdb.ttl();
Suggest
Queries metrics, tag keys, and tag values.
Sample code
The following sample code is used to query 10 metrics whose names start with hel.
List<String> metrics = tsdb.suggest(Suggest.Metrics, "hel", 10);
System.out.println("Query result:" + metrics);
DumpMeta
Queries tag values based on the tag key.
Sample code
The following sample code is used to query 10 tag key-value pairs, in which the tag key name is tagk1 and the tag values start with tagv1.
List<TagResult> dumpMeta = tsdb.dumpMeta("tagk1", "tagv1", 10);
System.out.println("Query result:" + dumpMeta);
DeleteData
Deletes data that is reported during a specified period.
Sample code
The following sample code is used to delete the data of the metric hello. The data to be deleted is reported during the period that starts from the time specified by the startTime parameter and ends at the time specified by the nowTime parameter.
tsdb.deleteData("hello", startTime, nowTime);
DeleteMeta
Deletes a specified timeline.
Sample code
The following sample code is used to delete a specified timeline. In the specified timeline, the metric name is hello. The timeline has only one tag key-value pair, in which the tag key name is tagk1 and the tag value is tagv1.
// Create the timeline.
Timeline timeline = Timeline.metric("hello").tag("tagk1", "tagv1").build();
tsdb.deleteMeta(timeline);
Truncate
Clears data from all tables.
Sample code
tsdb.truncate()