Syntax: SELECT [metric expression] WHERE [predicate]
To start with tsquery, you can click on any existing charts in CM, it will show you the output based on tsquery. In general, it won't allow you to alter the existing chart and it is not recommended. So you can go to CM -> Charts -> Chart builder -> follow the above syntax, it will automatically pop-up metric expression and predicate.
Ex: SELECT physical_memory_used
Pls refer the below links for time series queries, it may help you (i am not a java resource)
@mbigelow Do you collect the metrics using a code or a script?
i'm collecting alot of metrics from Yarn histroy server API and the impala API, intersting in the specific metrics you collected regarding the hive and impala usage analytics