use of org.n52.iceland.statistics.api.utils.KibanaImporter in project arctic-sea by 52North.
the class KibanaImporterIT method importValidJson.
@Test
public void importValidJson() throws IOException, InterruptedException {
String json = IOUtils.toString(KibanaImporter.class.getResourceAsStream("/kibana/kibana_config.json"), StandardCharsets.UTF_8);
new KibanaImporter(getEmbeddedClient(), ".kibana", "my-index").importJson(json);
Thread.sleep(1500);
Assert.assertTrue(getEmbeddedClient().prepareExists(".kibana").get().exists());
SearchResponse resp = getEmbeddedClient().prepareSearch(".kibana").setTypes("visualization").get();
Assert.assertTrue(resp.getHits().getTotalHits() > 0);
for (SearchHit hit : resp.getHits().getHits()) {
Assert.assertFalse(hit.getSourceAsString().contains(KibanaImporter.INDEX_NEEDLE));
}
SearchResponse resp2 = getEmbeddedClient().prepareSearch(".kibana").setTypes("dashboard").get();
Assert.assertTrue(resp2.getHits().getTotalHits() > 0);
for (SearchHit hit : resp2.getHits().getHits()) {
Assert.assertFalse(hit.getSourceAsString().contains(KibanaImporter.INDEX_NEEDLE));
}
}
use of org.n52.iceland.statistics.api.utils.KibanaImporter in project arctic-sea by 52North.
the class ElasticsearchAdminHandler method importPreconfiguredKibana.
public void importPreconfiguredKibana() throws JsonParseException, JsonMappingException, IOException {
String json;
if (settings.getKibanaConfPath() == null || settings.getKibanaConfPath().trim().isEmpty()) {
logger.info("No path is defined. Use default settings values");
json = IOUtils.toString(this.getClass().getResourceAsStream("/kibana/kibana_config.json"), StandardCharsets.UTF_8);
} else {
logger.info("Use content of path {}", settings.getKibanaConfPath());
json = IOUtils.toString(new FileInputStream(settings.getKibanaConfPath()), StandardCharsets.UTF_8);
}
new KibanaImporter(client, ".kibana", settings.getIndexId()).importJson(json);
// set to false after successful import
settings.saveBooleanValueToConfigFile(ElasticsearchSettingsKeys.KIBANA_CONFIG_ENABLE, false);
settings.setKibanaConfigEnable(false);
}
Aggregations