@Test public void testGetDashboardForElasticsearch() throws Exception { String expected = "{\"user\":\"guest\",\"group\":\"guest\",\"title\":\"Test Title\",\"tags\":[\"jdbc\",\"db\"],\"dashboard\":\"{\\\"title\\\":\\\"Test Title\\\",\\\"editable\\\":false,\\\"failover\\\":false,\\\"panel_hints\\\":true,\\\"style\\\":\\\"dark\\\",\\\"refresh\\\":\\\"1m\\\",\\\"tags\\\":[\\\"jdbc\\\",\\\"db\\\"],\\\"timezone\\\":\\\"browser\\\"}\"}"; assertEquals(expected, elasticsearchClient.getDashboardForElasticsearch("Test Dashboard.json").toString()); }
ObjectNode getDashboardForElasticsearch(String dashboardPath) throws IOException { final ObjectMapper mapper = JsonUtils.getMapper(); final ObjectNode dashboard = (ObjectNode) mapper.readTree(IOUtils.getResourceAsStream(dashboardPath)); dashboard.put("editable", false); ObjectNode dashboardElasticsearchFormat = mapper.createObjectNode(); dashboardElasticsearchFormat.put("user", "guest"); dashboardElasticsearchFormat.put("group", "guest"); dashboardElasticsearchFormat.set(TITLE, dashboard.get(TITLE)); dashboardElasticsearchFormat.set("tags", dashboard.get("tags")); dashboardElasticsearchFormat.put("dashboard", dashboard.toString()); return dashboardElasticsearchFormat; }
ElasticsearchClient { ObjectNode getDashboardForElasticsearch(String dashboardPath) throws IOException { final ObjectMapper mapper = JsonUtils.getMapper(); final ObjectNode dashboard = (ObjectNode) mapper.readTree(IOUtils.getResourceAsStream(dashboardPath)); dashboard.put("editable", false); ObjectNode dashboardElasticsearchFormat = mapper.createObjectNode(); dashboardElasticsearchFormat.put("user", "guest"); dashboardElasticsearchFormat.put("group", "guest"); dashboardElasticsearchFormat.set(TITLE, dashboard.get(TITLE)); dashboardElasticsearchFormat.set("tags", dashboard.get("tags")); dashboardElasticsearchFormat.put("dashboard", dashboard.toString()); return dashboardElasticsearchFormat; } }
ElasticsearchClient { ObjectNode getDashboardForElasticsearch(String dashboardPath) throws IOException { final ObjectMapper mapper = JsonUtils.getMapper(); final ObjectNode dashboard = (ObjectNode) mapper.readTree(IOUtils.getResourceAsStream(dashboardPath)); dashboard.put("editable", false); ObjectNode dashboardElasticsearchFormat = mapper.createObjectNode(); dashboardElasticsearchFormat.put("user", "guest"); dashboardElasticsearchFormat.put("group", "guest"); dashboardElasticsearchFormat.set(TITLE, dashboard.get(TITLE)); dashboardElasticsearchFormat.set("tags", dashboard.get("tags")); dashboardElasticsearchFormat.put("dashboard", dashboard.toString()); return dashboardElasticsearchFormat; } ElasticsearchClient(final CorePlugin corePlugin, final HttpClient httpClient, int esAvailabilityCheckIntervalSec, List<ElasticsearchAvailabilityObserver> elasticsearchAvailabilityObservers); }
ElasticsearchClient { ObjectNode getDashboardForElasticsearch(String dashboardPath) throws IOException { final ObjectMapper mapper = JsonUtils.getMapper(); final ObjectNode dashboard = (ObjectNode) mapper.readTree(IOUtils.getResourceAsStream(dashboardPath)); dashboard.put("editable", false); ObjectNode dashboardElasticsearchFormat = mapper.createObjectNode(); dashboardElasticsearchFormat.put("user", "guest"); dashboardElasticsearchFormat.put("group", "guest"); dashboardElasticsearchFormat.set(TITLE, dashboard.get(TITLE)); dashboardElasticsearchFormat.set("tags", dashboard.get("tags")); dashboardElasticsearchFormat.put("dashboard", dashboard.toString()); return dashboardElasticsearchFormat; } ElasticsearchClient(final CorePlugin corePlugin, final HttpClient httpClient, int esAvailabilityCheckIntervalSec, List<ElasticsearchAvailabilityObserver> elasticsearchAvailabilityObservers); boolean isElasticsearch7Compatible(); boolean isElasticsearch6Compatible(); String getElasticSearchTemplateResourcePath(); String getKibanaResourcePath(); JsonNode getJson(final String path); JsonNode getJson(final String path, final boolean suppressWarning); T getObject(final String path, Class<T> type); Collection<T> getAll(String path, int limit, Class<T> clazz); int delete(final String path); int sendAsJson(final String method, final String path, final Object requestBody); void updateKibanaIndexPattern(final String indexName, final String indexPatternLocation); void sendMappingTemplate(String mappingJson, String templateName); static String modifyIndexTemplate(String templatePath, int moveToColdNodesAfterDays, Integer numberOfReplicas, Integer numberOfShards); void sendMetricDashboardBulkAsync(final String resource); void sendSpanDashboardBulkAsync(final String resource, boolean logBulkErrors); void deleteIndices(String indexPattern); void forceMergeIndices(String indexPattern); void updateIndexSettings(String indexPattern, final Map<String, ?> settings); void waitForCompletion(); void close(); void scheduleIndexManagement(String indexPrefix, int optimizeAndMoveIndicesToColdNodesOlderThanDays, int deleteIndicesOlderThanDays); static String getBulkHeader(String action, String index, String type); boolean isElasticsearchAvailable(); HttpClient getHttpClient(); URL getElasticsearchUrl(); void createIndexAndSendMapping(final String index, final String type, final InputStream mapping); void createEmptyIndex(String indexName); void checkEsAvailability(); }
ElasticsearchClient { ObjectNode getDashboardForElasticsearch(String dashboardPath) throws IOException { final ObjectMapper mapper = JsonUtils.getMapper(); final ObjectNode dashboard = (ObjectNode) mapper.readTree(IOUtils.getResourceAsStream(dashboardPath)); dashboard.put("editable", false); ObjectNode dashboardElasticsearchFormat = mapper.createObjectNode(); dashboardElasticsearchFormat.put("user", "guest"); dashboardElasticsearchFormat.put("group", "guest"); dashboardElasticsearchFormat.set(TITLE, dashboard.get(TITLE)); dashboardElasticsearchFormat.set("tags", dashboard.get("tags")); dashboardElasticsearchFormat.put("dashboard", dashboard.toString()); return dashboardElasticsearchFormat; } ElasticsearchClient(final CorePlugin corePlugin, final HttpClient httpClient, int esAvailabilityCheckIntervalSec, List<ElasticsearchAvailabilityObserver> elasticsearchAvailabilityObservers); boolean isElasticsearch7Compatible(); boolean isElasticsearch6Compatible(); String getElasticSearchTemplateResourcePath(); String getKibanaResourcePath(); JsonNode getJson(final String path); JsonNode getJson(final String path, final boolean suppressWarning); T getObject(final String path, Class<T> type); Collection<T> getAll(String path, int limit, Class<T> clazz); int delete(final String path); int sendAsJson(final String method, final String path, final Object requestBody); void updateKibanaIndexPattern(final String indexName, final String indexPatternLocation); void sendMappingTemplate(String mappingJson, String templateName); static String modifyIndexTemplate(String templatePath, int moveToColdNodesAfterDays, Integer numberOfReplicas, Integer numberOfShards); void sendMetricDashboardBulkAsync(final String resource); void sendSpanDashboardBulkAsync(final String resource, boolean logBulkErrors); void deleteIndices(String indexPattern); void forceMergeIndices(String indexPattern); void updateIndexSettings(String indexPattern, final Map<String, ?> settings); void waitForCompletion(); void close(); void scheduleIndexManagement(String indexPrefix, int optimizeAndMoveIndicesToColdNodesOlderThanDays, int deleteIndicesOlderThanDays); static String getBulkHeader(String action, String index, String type); boolean isElasticsearchAvailable(); HttpClient getHttpClient(); URL getElasticsearchUrl(); void createIndexAndSendMapping(final String index, final String type, final InputStream mapping); void createEmptyIndex(String indexName); void checkEsAvailability(); static final Map<String, String> CONTENT_TYPE_NDJSON; }