You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2016/04/18 22:10:39 UTC
karaf-decanter git commit: [KARAF-4443] Add Kibana4 bootstrapping
(indices and dashboards)
Repository: karaf-decanter
Updated Branches:
refs/heads/master c7c21dcdd -> b4d2d8cdb
[KARAF-4443] Add Kibana4 bootstrapping (indices and dashboards)
Project: http://git-wip-us.apache.org/repos/asf/karaf-decanter/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-decanter/commit/b4d2d8cd
Tree: http://git-wip-us.apache.org/repos/asf/karaf-decanter/tree/b4d2d8cd
Diff: http://git-wip-us.apache.org/repos/asf/karaf-decanter/diff/b4d2d8cd
Branch: refs/heads/master
Commit: b4d2d8cdbe1dc2441737e7ae480bb21e849e37ec
Parents: c7c21dc
Author: Jean-Baptiste Onofré <jb...@apache.org>
Authored: Sun Apr 10 11:22:17 2016 +0200
Committer: Jean-Baptiste Onofré <jb...@apache.org>
Committed: Mon Apr 18 22:10:22 2016 +0200
----------------------------------------------------------------------
appender/elasticsearch-rest/pom.xml | 2 +-
kibana-4.x/pom.xml | 23 ++
.../karaf/decanter/kibana4/Activator.java | 322 +++++++++++++++++++
kibana-4.x/src/main/resources/config | 4 +-
4 files changed, 348 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/b4d2d8cd/appender/elasticsearch-rest/pom.xml
----------------------------------------------------------------------
diff --git a/appender/elasticsearch-rest/pom.xml b/appender/elasticsearch-rest/pom.xml
index 6457eba..3d0e314 100644
--- a/appender/elasticsearch-rest/pom.xml
+++ b/appender/elasticsearch-rest/pom.xml
@@ -41,7 +41,7 @@
<dependency>
<groupId>io.searchbox</groupId>
<artifactId>jest</artifactId>
- <version>2.0.0</version>
+ <version>2.0.2</version>
</dependency>
<!-- test -->
http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/b4d2d8cd/kibana-4.x/pom.xml
----------------------------------------------------------------------
diff --git a/kibana-4.x/pom.xml b/kibana-4.x/pom.xml
index 8821a58..a57ac67 100644
--- a/kibana-4.x/pom.xml
+++ b/kibana-4.x/pom.xml
@@ -33,6 +33,20 @@
<packaging>bundle</packaging>
<name>Apache Karaf :: Decanter :: Kibana 4.x</name>
+ <dependencies>
+ <dependency>
+ <groupId>io.searchbox</groupId>
+ <artifactId>jest</artifactId>
+ <version>2.0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.features</groupId>
+ <artifactId>org.apache.karaf.features.core</artifactId>
+ <version>4.0.4</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
<build>
<plugins>
<plugin>
@@ -40,7 +54,16 @@
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
+ <Bundle-Activator>org.apache.karaf.decanter.kibana4.Activator</Bundle-Activator>
<Web-ContextPath>/kibana</Web-ContextPath>
+ <Import-Package>org.apache.log;resolution:=optional,*</Import-Package>
+ <Private-Package>
+ org.apache.karaf.decanter.kibana4,
+ org.apache.http*,
+ org.apache.commons*,
+ io.searchbox*,
+ com.google*
+ </Private-Package>
</instructions>
</configuration>
</plugin>
http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/b4d2d8cd/kibana-4.x/src/main/java/org/apache/karaf/decanter/kibana4/Activator.java
----------------------------------------------------------------------
diff --git a/kibana-4.x/src/main/java/org/apache/karaf/decanter/kibana4/Activator.java b/kibana-4.x/src/main/java/org/apache/karaf/decanter/kibana4/Activator.java
new file mode 100644
index 0000000..291334a
--- /dev/null
+++ b/kibana-4.x/src/main/java/org/apache/karaf/decanter/kibana4/Activator.java
@@ -0,0 +1,322 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.decanter.kibana4;
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import io.searchbox.client.JestClient;
+import io.searchbox.client.JestClientFactory;
+import io.searchbox.client.JestResult;
+import io.searchbox.client.config.HttpClientConfig;
+import io.searchbox.core.Index;
+import io.searchbox.core.Search;
+import io.searchbox.core.SearchResult;
+import io.searchbox.indices.Analyze;
+import io.searchbox.indices.mapping.GetMapping;
+import org.apache.karaf.features.FeatureEvent;
+import org.apache.karaf.features.FeaturesListener;
+import org.apache.karaf.features.RepositoryEvent;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+public class Activator implements BundleActivator {
+
+ private final static Logger LOGGER = LoggerFactory.getLogger(Activator.class);
+
+ private final static String KIBANA_INDEX = ".kibana";
+
+ @Override
+ public void start(BundleContext bundleContext) {
+ LOGGER.debug("Starting Kibana 4 console ...");
+
+ CollectorListener listener = new CollectorListener();
+ bundleContext.registerService(FeaturesListener.class, listener, null);
+ }
+
+ @Override
+ public void stop(BundleContext bundleContext) {
+ LOGGER.debug("Stopping Kibana 4 console ...");
+ }
+
+ private void traverseJson(String parent, JsonObject jsonObject, Map<String, String> map) {
+ if (jsonObject.entrySet().size() > 0) {
+ for (Map.Entry<String, JsonElement> element : jsonObject.entrySet()) {
+ if (element.getKey().equalsIgnoreCase("type") && element.getValue().isJsonPrimitive()) {
+ if (element.getValue().getAsString().equalsIgnoreCase("long") || element.getValue().getAsString().equalsIgnoreCase("double"))
+ map.put(parent, "number");
+ else if (element.getValue().getAsString().equalsIgnoreCase("object")) {
+ // bypass object
+ } else map.put(parent, element.getValue().getAsString());
+ } else if (element.getValue().isJsonObject())
+ traverseJson(element.getKey(), element.getValue().getAsJsonObject(), map);
+ }
+ }
+ }
+
+ private JestClient createClient() {
+ // TODO load the config from resources to get the Kibana index name
+ // and location of the elasticsearch instance
+ String address = "http://localhost:9200/";
+
+ HttpClientConfig.Builder builder = new HttpClientConfig.Builder(address)
+ .discoveryEnabled(true)
+ .discoveryFrequency(1l, TimeUnit.MINUTES)
+ .multiThreaded(true);
+ JestClientFactory factory = new JestClientFactory();
+ factory.setHttpClientConfig(builder.build());
+
+ return factory.getObject();
+ }
+
+ private void updateIndex() {
+ LOGGER.debug("Updating kibana index");
+
+ JestClient client = createClient();
+
+ try {
+ GetMapping getMapping = new GetMapping.Builder().build();
+ JestResult result = client.execute(getMapping);
+ if (!result.isSucceeded()) {
+ throw new IllegalStateException("Can't retrieve mappings");
+ }
+ JsonObject resultJson = result.getJsonObject();
+ JsonObject karafIndex = resultJson.getAsJsonObject();
+
+ Map<String, String> fields = new HashMap<>();
+
+ for (Map.Entry<String, JsonElement> index : karafIndex.entrySet()) {
+ if (index.getKey().startsWith("karaf")) {
+ traverseJson(index.getKey(), index.getValue().getAsJsonObject(), fields);
+ }
+ }
+
+ LOGGER.debug("Updating .kibana index");
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.append("{ \"title\": \"*\",");
+ stringBuilder.append("\"timeFieldName\": \"@timestamp\",");
+ stringBuilder.append("\"fields\": \"[");
+
+ for (String field : fields.keySet()) {
+ stringBuilder.append("{");
+ stringBuilder.append("\\\"name\\\":\\\"").append(field).append("\\\",");
+ stringBuilder.append("\\\"type\\\":\\\"").append(fields.get(field)).append("\\\",");
+ stringBuilder.append("\\\"count\\\":0,");
+ stringBuilder.append("\\\"scripted\\\":false,");
+ if (field.startsWith("_"))
+ stringBuilder.append("\\\"indexed\\\":false,");
+ else stringBuilder.append("\\\"indexed\\\":true,");
+ if (fields.get(field).equalsIgnoreCase("string"))
+ stringBuilder.append("\\\"analyzed\\\":false,");
+ else stringBuilder.append("\\\"analyzed\\\":true,");
+ stringBuilder.append("\\\"doc_values\\\":false");
+ stringBuilder.append("},");
+ }
+ if (stringBuilder.charAt(stringBuilder.length() - 1) == ',')
+ stringBuilder.deleteCharAt(stringBuilder.length() - 1);
+
+ stringBuilder.append("]\" }");
+
+ result = client.execute(new Index.Builder(stringBuilder.toString()).index(KIBANA_INDEX).type("index-pattern").id("*").build());
+ if (!result.isSucceeded()) {
+ throw new IllegalStateException(result.getErrorMessage());
+ }
+ result = client.execute(new Index.Builder("{ \"buildNum\" : 7562, \"defaultIndex\": \"*\" }").index(KIBANA_INDEX).type("config").id("4.1.2-es-2.0").build());
+ if (!result.isSucceeded()) {
+ throw new IllegalStateException(result.getErrorMessage());
+ }
+ Analyze analyze = new Analyze.Builder().analyzer("standard").build();
+ client.execute(analyze);
+ } catch (Exception e) {
+ LOGGER.warn("Can't update .kibana index", e);
+ }
+ }
+
+ private boolean checkCollectedDataType(String type) {
+ JestClient client = createClient();
+
+ String query = "{ \"query\": { \"bool\" : { \"must\" : { \"query_string\" : { \"query\" : \"type:" + type + "\"}}}}}";
+
+ Search search = new Search.Builder(query).build();
+ try {
+ SearchResult result = client.execute(search);
+ if (result.getTotal() > 1) {
+ return true;
+ } else {
+ return false;
+ }
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ private void createLogDashboard() {
+ JestClient client = createClient();
+
+ try {
+ String logLevels = "{\n" +
+ " \"title\": \"Log Levels\",\n" +
+ " \"visState\": \"{\\\"type\\\":\\\"pie\\\",\\\"params\\\":{\\\"shareYAxis\\\":true,\\\"addTooltip\\\":true,\\\"addLegend\\\":true,\\\"isDonut\\\":false},\\\"aggs\\\":[{\\\"id\\\":\\\"1\\\",\\\"type\\\":\\\"count\\\",\\\"schema\\\":\\\"metric\\\",\\\"params\\\":{}},{\\\"id\\\":\\\"2\\\",\\\"type\\\":\\\"terms\\\",\\\"schema\\\":\\\"segment\\\",\\\"params\\\":{\\\"field\\\":\\\"level\\\",\\\"size\\\":5,\\\"order\\\":\\\"desc\\\",\\\"orderBy\\\":\\\"1\\\"}}],\\\"listeners\\\":{}}\",\n" +
+ " \"description\": \"\",\n" +
+ " \"kibanaSavedObjectMeta\": {\n" +
+ " \"searchSourceJSON\": \"{\\\"index\\\":\\\"*\\\",\\\"query\\\":{\\\"query_string\\\":{\\\"query\\\":\\\"*\\\",\\\"analyze_wildcard\\\":true}},\\\"filter\\\":[]}\"\n" +
+ " }\n" +
+ " }\n";
+ String loggers = "{\n" +
+ " \"title\": \"Loggers\",\n" +
+ " \"visState\": \"{\\\"type\\\":\\\"pie\\\",\\\"params\\\":{\\\"shareYAxis\\\":true,\\\"addTooltip\\\":true,\\\"addLegend\\\":true,\\\"isDonut\\\":false},\\\"aggs\\\":[{\\\"id\\\":\\\"1\\\",\\\"type\\\":\\\"count\\\",\\\"schema\\\":\\\"metric\\\",\\\"params\\\":{}},{\\\"id\\\":\\\"2\\\",\\\"type\\\":\\\"terms\\\",\\\"schema\\\":\\\"segment\\\",\\\"params\\\":{\\\"field\\\":\\\"loggerName\\\",\\\"size\\\":5,\\\"order\\\":\\\"desc\\\",\\\"orderBy\\\":\\\"1\\\"}}],\\\"listeners\\\":{}}\",\n" +
+ " \"description\": \"\",\n" +
+ " \"kibanaSavedObjectMeta\": {\n" +
+ " \"searchSourceJSON\": \"{\\\"index\\\":\\\"*\\\",\\\"query\\\":{\\\"query_string\\\":{\\\"query\\\":\\\"*\\\",\\\"analyze_wildcard\\\":true}},\\\"filter\\\":[]}\"\n" +
+ " }\n" +
+ " }\n";
+ String dashboard = "{\n" +
+ " \"title\": \"Log\",\n" +
+ " \"description\": \"\",\n" +
+ " \"panelsJSON\": \"[{\\\"id\\\":\\\"Loggers\\\",\\\"type\\\":\\\"visualization\\\",\\\"size_x\\\":6,\\\"size_y\\\":5,\\\"col\\\":1,\\\"row\\\":1},{\\\"id\\\":\\\"Log-Levels\\\",\\\"type\\\":\\\"visualization\\\",\\\"size_x\\\":6,\\\"size_y\\\":5,\\\"col\\\":7,\\\"row\\\":1}]\",\n" +
+ " \"timeRestore\": false,\n" +
+ " \"kibanaSavedObjectMeta\": {\n" +
+ " \"searchSourceJSON\": \"{\\\"filter\\\":[{\\\"query\\\":{\\\"query_string\\\":{\\\"query\\\":\\\"*\\\",\\\"analyze_wildcard\\\":true}}}]}\"\n" +
+ " }\n" +
+ " }\n";
+
+ client.execute(new Index.Builder(logLevels).index(KIBANA_INDEX).type("visualization").id("Log-Levels").build());
+ client.execute(new Index.Builder(loggers).index(KIBANA_INDEX).type("visualization").id("Loggers").build());
+ client.execute(new Index.Builder(dashboard).index(KIBANA_INDEX).type("dashboard").id("Log").build());
+ } catch (Exception e) {
+ LOGGER.warn("Can't create log dashboard", e);
+ }
+ }
+
+ private void createSystemDashboard() {
+ JestClient client = createClient();
+
+ try {
+ String memory = "{\n" +
+ " \"title\": \"Memory\",\n" +
+ " \"visState\": \"{\\\"type\\\":\\\"line\\\",\\\"params\\\":{\\\"shareYAxis\\\":true,\\\"addTooltip\\\":true,\\\"addLegend\\\":true,\\\"showCircles\\\":true,\\\"smoothLines\\\":false,\\\"interpolate\\\":\\\"linear\\\",\\\"scale\\\":\\\"linear\\\",\\\"drawLinesBetweenPoints\\\":true,\\\"radiusRatio\\\":9,\\\"times\\\":[],\\\"addTimeMarker\\\":false,\\\"defaultYExtents\\\":false,\\\"setYExtents\\\":false,\\\"yAxis\\\":{}},\\\"aggs\\\":[{\\\"id\\\":\\\"1\\\",\\\"type\\\":\\\"avg\\\",\\\"schema\\\":\\\"metric\\\",\\\"params\\\":{\\\"field\\\":\\\"used\\\"}},{\\\"id\\\":\\\"2\\\",\\\"type\\\":\\\"date_histogram\\\",\\\"schema\\\":\\\"segment\\\",\\\"params\\\":{\\\"field\\\":\\\"@timestamp\\\",\\\"interval\\\":\\\"auto\\\",\\\"customInterval\\\":\\\"2h\\\",\\\"min_doc_count\\\":1,\\\"extended_bounds\\\":{}}},{\\\"id\\\":\\\"3\\\",\\\"type\\\":\\\"avg\\\",\\\"schema\\\":\\\"metric\\\",\\\"params\\\":{\\\"field\\\":\\\"max\\\"}},{\\\"id\\\":\\\"4\\\",\\\"type\\\":\
\\"avg\\\",\\\"schema\\\":\\\"metric\\\",\\\"params\\\":{\\\"field\\\":\\\"committed\\\"}}],\\\"listeners\\\":{}}\",\n" +
+ " \"description\": \"\",\n" +
+ " \"kibanaSavedObjectMeta\": {\n" +
+ " \"searchSourceJSON\": \"{\\\"index\\\":\\\"*\\\",\\\"query\\\":{\\\"query_string\\\":{\\\"query\\\":\\\"*\\\",\\\"analyze_wildcard\\\":true}},\\\"filter\\\":[]}\"\n" +
+ " }\n" +
+ " }";
+
+ String gc = "{\n" +
+ " \"title\": \"Garbage Collector\",\n" +
+ " \"visState\": \"{\\\"type\\\":\\\"line\\\",\\\"params\\\":{\\\"shareYAxis\\\":true,\\\"addTooltip\\\":true,\\\"addLegend\\\":true,\\\"showCircles\\\":true,\\\"smoothLines\\\":false,\\\"interpolate\\\":\\\"linear\\\",\\\"scale\\\":\\\"linear\\\",\\\"drawLinesBetweenPoints\\\":true,\\\"radiusRatio\\\":9,\\\"times\\\":[],\\\"addTimeMarker\\\":false,\\\"defaultYExtents\\\":false,\\\"setYExtents\\\":false,\\\"yAxis\\\":{}},\\\"aggs\\\":[{\\\"id\\\":\\\"1\\\",\\\"type\\\":\\\"avg\\\",\\\"schema\\\":\\\"metric\\\",\\\"params\\\":{\\\"field\\\":\\\"CollectionCount\\\"}},{\\\"id\\\":\\\"2\\\",\\\"type\\\":\\\"date_histogram\\\",\\\"schema\\\":\\\"segment\\\",\\\"params\\\":{\\\"field\\\":\\\"@timestamp\\\",\\\"interval\\\":\\\"auto\\\",\\\"customInterval\\\":\\\"2h\\\",\\\"min_doc_count\\\":1,\\\"extended_bounds\\\":{}}},{\\\"id\\\":\\\"3\\\",\\\"type\\\":\\\"avg\\\",\\\"schema\\\":\\\"metric\\\",\\\"params\\\":{\\\"field\\\":\\\"CollectionTime\\\"}},{\\\"id\\\":\\
\"4\\\",\\\"type\\\":\\\"avg\\\",\\\"schema\\\":\\\"metric\\\",\\\"params\\\":{\\\"field\\\":\\\"duration\\\"}}],\\\"listeners\\\":{}}\",\n" +
+ " \"description\": \"\",\n" +
+ " \"kibanaSavedObjectMeta\": {\n" +
+ " \"searchSourceJSON\": \"{\\\"index\\\":\\\"*\\\",\\\"query\\\":{\\\"query_string\\\":{\\\"query\\\":\\\"*\\\",\\\"analyze_wildcard\\\":true}},\\\"filter\\\":[]}\"\n" +
+ " }\n" +
+ " }\n";
+
+ String classLoading = "{\n" +
+ " \"title\": \"Class Loading\",\n" +
+ " \"visState\": \"{\\\"type\\\":\\\"line\\\",\\\"params\\\":{\\\"shareYAxis\\\":true,\\\"addTooltip\\\":true,\\\"addLegend\\\":true,\\\"showCircles\\\":true,\\\"smoothLines\\\":false,\\\"interpolate\\\":\\\"linear\\\",\\\"scale\\\":\\\"linear\\\",\\\"drawLinesBetweenPoints\\\":true,\\\"radiusRatio\\\":9,\\\"times\\\":[],\\\"addTimeMarker\\\":false,\\\"defaultYExtents\\\":false,\\\"setYExtents\\\":false,\\\"yAxis\\\":{}},\\\"aggs\\\":[{\\\"id\\\":\\\"1\\\",\\\"type\\\":\\\"avg\\\",\\\"schema\\\":\\\"metric\\\",\\\"params\\\":{\\\"field\\\":\\\"LoadedClassCount\\\"}},{\\\"id\\\":\\\"2\\\",\\\"type\\\":\\\"date_histogram\\\",\\\"schema\\\":\\\"segment\\\",\\\"params\\\":{\\\"field\\\":\\\"@timestamp\\\",\\\"interval\\\":\\\"auto\\\",\\\"customInterval\\\":\\\"2h\\\",\\\"min_doc_count\\\":1,\\\"extended_bounds\\\":{}}},{\\\"id\\\":\\\"3\\\",\\\"type\\\":\\\"avg\\\",\\\"schema\\\":\\\"metric\\\",\\\"params\\\":{\\\"field\\\":\\\"TotalLoadedClassCount\\\"}},{\\\"i
d\\\":\\\"4\\\",\\\"type\\\":\\\"avg\\\",\\\"schema\\\":\\\"metric\\\",\\\"params\\\":{\\\"field\\\":\\\"UnloadedClassCount\\\"}}],\\\"listeners\\\":{}}\",\n" +
+ " \"description\": \"\",\n" +
+ " \"kibanaSavedObjectMeta\": {\n" +
+ " \"searchSourceJSON\": \"{\\\"index\\\":\\\"*\\\",\\\"query\\\":{\\\"query_string\\\":{\\\"query\\\":\\\"*\\\",\\\"analyze_wildcard\\\":true}},\\\"filter\\\":[]}\"\n" +
+ " }\n" +
+ " }\n";
+
+ String os = "{\n" +
+ " \"title\": \"Operating System\",\n" +
+ " \"visState\": \"{\\\"type\\\":\\\"line\\\",\\\"params\\\":{\\\"shareYAxis\\\":true,\\\"addTooltip\\\":true,\\\"addLegend\\\":true,\\\"showCircles\\\":true,\\\"smoothLines\\\":false,\\\"interpolate\\\":\\\"linear\\\",\\\"scale\\\":\\\"linear\\\",\\\"drawLinesBetweenPoints\\\":true,\\\"radiusRatio\\\":9,\\\"times\\\":[],\\\"addTimeMarker\\\":false,\\\"defaultYExtents\\\":false,\\\"setYExtents\\\":false,\\\"yAxis\\\":{}},\\\"aggs\\\":[{\\\"id\\\":\\\"1\\\",\\\"type\\\":\\\"avg\\\",\\\"schema\\\":\\\"metric\\\",\\\"params\\\":{\\\"field\\\":\\\"FreePhysicalMemorySize\\\"}},{\\\"id\\\":\\\"2\\\",\\\"type\\\":\\\"date_histogram\\\",\\\"schema\\\":\\\"segment\\\",\\\"params\\\":{\\\"field\\\":\\\"@timestamp\\\",\\\"interval\\\":\\\"auto\\\",\\\"customInterval\\\":\\\"2h\\\",\\\"min_doc_count\\\":1,\\\"extended_bounds\\\":{}}},{\\\"id\\\":\\\"3\\\",\\\"type\\\":\\\"avg\\\",\\\"schema\\\":\\\"metric\\\",\\\"params\\\":{\\\"field\\\":\\\"FreeSwapSpaceSize\\\"}},{\\\
"id\\\":\\\"4\\\",\\\"type\\\":\\\"avg\\\",\\\"schema\\\":\\\"metric\\\",\\\"params\\\":{\\\"field\\\":\\\"OpenFileDescriptorCount\\\"}},{\\\"id\\\":\\\"5\\\",\\\"type\\\":\\\"avg\\\",\\\"schema\\\":\\\"metric\\\",\\\"params\\\":{\\\"field\\\":\\\"ProcessCpuLoad\\\"}},{\\\"id\\\":\\\"6\\\",\\\"type\\\":\\\"avg\\\",\\\"schema\\\":\\\"metric\\\",\\\"params\\\":{\\\"field\\\":\\\"SystemCpuLoad\\\"}}],\\\"listeners\\\":{}}\",\n" +
+ " \"description\": \"\",\n" +
+ " \"kibanaSavedObjectMeta\": {\n" +
+ " \"searchSourceJSON\": \"{\\\"index\\\":\\\"*\\\",\\\"query\\\":{\\\"query_string\\\":{\\\"query\\\":\\\"*\\\",\\\"analyze_wildcard\\\":true}},\\\"filter\\\":[]}\"\n" +
+ " }\n" +
+ " }\n";
+
+ String threads = "{\n" +
+ " \"title\": \"Threads\",\n" +
+ " \"visState\": \"{\\\"type\\\":\\\"line\\\",\\\"params\\\":{\\\"shareYAxis\\\":true,\\\"addTooltip\\\":true,\\\"addLegend\\\":true,\\\"showCircles\\\":true,\\\"smoothLines\\\":false,\\\"interpolate\\\":\\\"linear\\\",\\\"scale\\\":\\\"linear\\\",\\\"drawLinesBetweenPoints\\\":true,\\\"radiusRatio\\\":9,\\\"times\\\":[],\\\"addTimeMarker\\\":false,\\\"defaultYExtents\\\":false,\\\"setYExtents\\\":false,\\\"yAxis\\\":{}},\\\"aggs\\\":[{\\\"id\\\":\\\"2\\\",\\\"type\\\":\\\"date_histogram\\\",\\\"schema\\\":\\\"segment\\\",\\\"params\\\":{\\\"field\\\":\\\"@timestamp\\\",\\\"interval\\\":\\\"auto\\\",\\\"customInterval\\\":\\\"2h\\\",\\\"min_doc_count\\\":1,\\\"extended_bounds\\\":{}}},{\\\"id\\\":\\\"3\\\",\\\"type\\\":\\\"avg\\\",\\\"schema\\\":\\\"metric\\\",\\\"params\\\":{\\\"field\\\":\\\"ThreadCount\\\"}},{\\\"id\\\":\\\"4\\\",\\\"type\\\":\\\"avg\\\",\\\"schema\\\":\\\"metric\\\",\\\"params\\\":{\\\"field\\\":\\\"DaemonThreadCount\\\"}},{\\\"id\\\":\\\
"5\\\",\\\"type\\\":\\\"avg\\\",\\\"schema\\\":\\\"metric\\\",\\\"params\\\":{\\\"field\\\":\\\"PeakThreadCount\\\"}}],\\\"listeners\\\":{}}\",\n" +
+ " \"description\": \"\",\n" +
+ " \"kibanaSavedObjectMeta\": {\n" +
+ " \"searchSourceJSON\": \"{\\\"index\\\":\\\"*\\\",\\\"query\\\":{\\\"query_string\\\":{\\\"query\\\":\\\"*\\\",\\\"analyze_wildcard\\\":true}},\\\"filter\\\":[]}\"\n" +
+ " }\n" +
+ " }";
+
+ String dashboard = "{\n" +
+ " \"title\": \"System\",\n" +
+ " \"description\": \"\",\n" +
+ " \"panelsJSON\": \"[{\\\"id\\\":\\\"Class-Loading\\\",\\\"type\\\":\\\"visualization\\\",\\\"size_x\\\":4,\\\"size_y\\\":2,\\\"col\\\":6,\\\"row\\\":4},{\\\"id\\\":\\\"Garbage-Collector\\\",\\\"type\\\":\\\"visualization\\\",\\\"size_x\\\":6,\\\"size_y\\\":3,\\\"col\\\":1,\\\"row\\\":1},{\\\"id\\\":\\\"Memory\\\",\\\"type\\\":\\\"visualization\\\",\\\"size_x\\\":3,\\\"size_y\\\":2,\\\"col\\\":10,\\\"row\\\":4},{\\\"id\\\":\\\"Operating-System\\\",\\\"type\\\":\\\"visualization\\\",\\\"size_x\\\":6,\\\"size_y\\\":3,\\\"col\\\":7,\\\"row\\\":1},{\\\"id\\\":\\\"Threads\\\",\\\"type\\\":\\\"visualization\\\",\\\"size_x\\\":5,\\\"size_y\\\":2,\\\"col\\\":1,\\\"row\\\":4}]\",\n" +
+ " \"timeRestore\": false,\n" +
+ " \"kibanaSavedObjectMeta\": {\n" +
+ " \"searchSourceJSON\": \"{\\\"filter\\\":[{\\\"query\\\":{\\\"query_string\\\":{\\\"query\\\":\\\"*\\\",\\\"analyze_wildcard\\\":true}}}]}\"\n" +
+ " }\n" +
+ " }\n";
+
+ client.execute(new Index.Builder(memory).index(KIBANA_INDEX).type("visualization").id("Memory").build());
+ client.execute(new Index.Builder(gc).index(KIBANA_INDEX).type("visualization").id("Garbage-Collector").build());
+ client.execute(new Index.Builder(classLoading).index(KIBANA_INDEX).type("visualization").id("Class-Loading").build());
+ client.execute(new Index.Builder(os).index(KIBANA_INDEX).type("visualization").id("Operating-System").build());
+ client.execute(new Index.Builder(threads).index(KIBANA_INDEX).type("visualization").id("Threads").build());
+ client.execute(new Index.Builder(dashboard).index(KIBANA_INDEX).type("dashboard").id("System").build());
+ } catch (Exception e) {
+ LOGGER.warn("Can't create system dashboard", e);
+ }
+ }
+
+ class CollectorListener implements FeaturesListener {
+
+ @Override
+ public void featureEvent(FeatureEvent event) {
+ // add a timeout to let some data to be populated
+ if (event.getType().equals(FeatureEvent.EventType.FeatureInstalled)) {
+ if (event.getFeature().getName().equalsIgnoreCase("decanter-collector-log")) {
+ LOGGER.info("Decanter Kibana detected installation of the decanter-collector-log feature");
+ // check if data has been appended
+ while (!checkCollectedDataType("log*")) {
+ try {
+ Thread.sleep(10000);
+ } catch (Exception e) {
+ // nothing to do
+ }
+ }
+ updateIndex();
+ createLogDashboard();
+ }
+ if (event.getFeature().getName().equalsIgnoreCase("decanter-collector-jmx")) {
+ LOGGER.info("Decanter Kibana detected installation of the decanter-collector-log feature");
+ // check if data has been appended
+ while (!checkCollectedDataType("jmx*")) {
+ try {
+ Thread.sleep(10000);
+ } catch (Exception e) {
+ // nothing to do
+ }
+ }
+ updateIndex();
+ createSystemDashboard();
+ }
+ }
+ }
+
+ @Override
+ public void repositoryEvent(RepositoryEvent event) {
+ // nothing to do
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/b4d2d8cd/kibana-4.x/src/main/resources/config
----------------------------------------------------------------------
diff --git a/kibana-4.x/src/main/resources/config b/kibana-4.x/src/main/resources/config
index 1e029f7..27a5766 100644
--- a/kibana-4.x/src/main/resources/config
+++ b/kibana-4.x/src/main/resources/config
@@ -1,6 +1,6 @@
{
- "kibana_index": ".kibana-4",
- "default_app_id": "discover",
+ "kibana_index": ".kibana",
+ "default_app_id": "dashboard/System",
"shard_timeout": 0,
"plugins": [
"plugins/dashboard/index",