All Products
Search
Document Center

Call other interfaces

Last Updated: May 24, 2020

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.

  1. tsdb.ttl(time);

The following sample code is used to query the TTL. The unit of TTL is seconds.

  1. 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.

  1. List<String> metrics = tsdb.suggest(Suggest.Metrics, "hel", 10);
  2. 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.

  1. List<TagResult> dumpMeta = tsdb.dumpMeta("tagk1", "tagv1", 10);
  2. 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.

  1. 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.

  1. // Create the timeline.
  2. Timeline timeline = Timeline.metric("hello").tag("tagk1", "tagv1").build();
  3. tsdb.deleteMeta(timeline);

Truncate

Clears data from all tables.

Sample code

  1. tsdb.truncate()