We are working with SQL REST API and would like to get the same hierarchy as shown in the investigator as the output of the query.
Is it possible to get the same hierarchy as shown in the investigator by using the SQL REST API?
Yes, it is possible. Basically the Investigator tree is showing all metrics in a hierarchy of "Agent Domain" -> "Host" -> "Process" -> "Name" -> "Metric Path" and the SQL REST API metrics table have all these columns.
Using APMSQL REST API