Я открыл SSH-туннель следующим образом:
ssh -N -L 8082:ipinfluxdb:80 myhost
Затем я делаю следующий запрос:
curl -i 'http://localhost:8082/infrastructure/query?pretty=true' --data-urlencode "db=telegraf" --data-urlencode "q=SHOW MEASUREMENTS"
, который дает мне отличные результаты.Я хочу выполнить точно такой же запрос, используя InfluxDB-Java
клиент.На данный момент я пробовал следующее:
import org.influxdb.InfluxDB;
import org.influxdb.InfluxDBFactory;
import org.influxdb.dto.Query;
import org.influxdb.dto.QueryResult;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import static junit.framework.TestCase.assertTrue;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class PushedBallotsCountResolverTests {
@Test
public void test01() {
final InfluxDB influxDB = InfluxDBFactory.connect("http://localhost:8082/");
QueryResult query = influxDB.query(new Query("show measurements", "telegraf"));
assertTrue(!query.getResults().isEmpty());
}
}
Но когда я запускаю тест, я получаю
org.influxdb.InfluxDBException: <html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.12.2</center>
</body>
</html>
Как правильно сделать этот запрос с использованием этой библиотеки