Skip to content
This repository was archived by the owner on May 6, 2022. It is now read-only.

Commit 4aff087

Browse files
author
Florian Lautenschlager
committed
Updated project to latest versions.
1 parent f7f84f7 commit 4aff087

File tree

3 files changed

+187
-57
lines changed

3 files changed

+187
-57
lines changed

chronix-timeseries-exploration/src/main/java/de/qaware/chronix/examples/exploration/ui/MainController.java

Lines changed: 50 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,23 @@
1818
import de.qaware.chronix.ChronixClient;
1919
import de.qaware.chronix.converter.MetricTimeSeriesConverter;
2020
import de.qaware.chronix.examples.exploration.ui.dt.DateAxis;
21+
import de.qaware.chronix.examples.exploration.ui.dt.ResultRow;
2122
import de.qaware.chronix.examples.exploration.ui.log.TextAreaLogger;
2223
import de.qaware.chronix.solr.client.ChronixSolrStorage;
2324
import de.qaware.chronix.timeseries.MetricTimeSeries;
2425
import de.qaware.chronix.timeseries.dts.Point;
2526
import javafx.application.Platform;
27+
import javafx.collections.FXCollections;
28+
import javafx.collections.ObservableList;
2629
import javafx.concurrent.Task;
2730
import javafx.event.EventHandler;
2831
import javafx.fxml.FXML;
2932
import javafx.fxml.Initializable;
3033
import javafx.scene.chart.LineChart;
3134
import javafx.scene.chart.NumberAxis;
3235
import javafx.scene.chart.XYChart;
36+
import javafx.scene.control.TableColumn;
37+
import javafx.scene.control.TableView;
3338
import javafx.scene.control.TextArea;
3439
import javafx.scene.input.KeyCode;
3540
import javafx.scene.input.KeyEvent;
@@ -76,6 +81,24 @@ public class MainController implements Initializable {
7681
@FXML
7782
private LineChart<DateAxis, NumberAxis> chart;
7883

84+
/**
85+
* Table stuff below
86+
*/
87+
@FXML
88+
private TableView<ResultRow> resultTable;
89+
@FXML
90+
private TableColumn<ResultRow, String> timeSeries;
91+
@FXML
92+
private TableColumn<ResultRow, String> aggregationOrAnalysis;
93+
@FXML
94+
private TableColumn<ResultRow, String> arguments;
95+
@FXML
96+
private TableColumn<ResultRow, String> values;
97+
@FXML
98+
private TableColumn<ResultRow, String> order;
99+
100+
private ObservableList<ResultRow> rows = FXCollections.observableArrayList();
101+
79102
//Chronix stuff
80103
private ChronixClient<MetricTimeSeries, SolrClient, SolrQuery> chronix;
81104
private SolrClient solr;
@@ -87,6 +110,14 @@ public void initialize(URL location, ResourceBundle resources) {
87110
//Pipe logs to ui
88111
TextAreaLogger.setTextArea(logs);
89112

113+
//Init table
114+
timeSeries.setCellValueFactory(cellData -> cellData.getValue().timeSeriesProperty());
115+
aggregationOrAnalysis.setCellValueFactory(cellData -> cellData.getValue().aggregationOrAnalysisProperty());
116+
arguments.setCellValueFactory(cellData -> cellData.getValue().argumentsProperty());
117+
values.setCellValueFactory(cellData -> cellData.getValue().valuesProperty());
118+
order.setCellValueFactory(cellData -> cellData.getValue().orderProperty());
119+
resultTable.setItems(rows);
120+
90121
EventHandler<KeyEvent> queryExecuteHandler = event -> {
91122
if (event.getCode() == KeyCode.ENTER && event.isShiftDown()) {
92123
queryTimeSeries();
@@ -107,7 +138,7 @@ public void initChronix(String solrUrl) {
107138
public Void call() {
108139

109140
LOGGER.info("Setting up Chronix with a remote Solr to URL {}", solrUrl);
110-
solr = new HttpSolrClient(solrUrl);
141+
solr = new HttpSolrClient.Builder(solrUrl).build();
111142

112143
boolean solrAvailable = solrAvailable();
113144
LOGGER.info("Checking connection to Solr. Result {}", solrAvailable);
@@ -146,19 +177,18 @@ protected Void call() throws Exception {
146177

147178
Platform.runLater(() -> {
148179
chart.getData().clear();
180+
rows.clear();
149181
//Start the query
150182
chart.setTitle("Your Query was q=" + queryString + " fq=" + fq);
151183
});
152184

153185
SolrQuery query = new SolrQuery(queryString);
186+
query.addField("+data");
187+
154188
boolean hasFilterQueries = !fq.isEmpty();
155189

156190
if (hasFilterQueries) {
157191
query.addFilterQuery(fq);
158-
159-
if (fq.contains("function=")) {
160-
query.addField("+data");
161-
}
162192
}
163193

164194
long queryStart = System.currentTimeMillis();
@@ -167,12 +197,10 @@ protected Void call() throws Exception {
167197
LOGGER.info("Query took: {} ms for {} points", (queryEnd - queryStart), size(result));
168198
queryStart = System.currentTimeMillis();
169199
result.forEach(ts -> {
170-
171200
if (hasFilterQueries) {
172-
convertAggregationOrAnalysisTs(ts, fq.contains("function="));
173-
} else {
174-
convertTsToSeries(ts);
201+
addFunctionsToTable(ts);
175202
}
203+
convertTsToSeries(ts);
176204
});
177205
queryEnd = System.currentTimeMillis();
178206
LOGGER.info("Charting took: {} ms", (queryEnd - queryStart));
@@ -183,47 +211,32 @@ protected Void call() throws Exception {
183211

184212
}
185213

186-
private void convertAggregationOrAnalysisTs(MetricTimeSeries ts, boolean analysis) {
214+
private void addFunctionsToTable(MetricTimeSeries ts) {
187215

188216
//find the aggregations / and analyses
189217

190218
ts.getAttributesReference().forEach((key, value) -> {
191219
//we have function value
192220
if (key.contains("function") && !key.contains("arguments")) {
193221
String[] splits = key.split("_");
194-
XYChart.Series<DateAxis, NumberAxis> series = new XYChart.Series<>();
195222

196223
//function name
197-
String name = splits[1];
198-
series.setName(join(ts) + "-" + name);
199-
200-
//function value
201-
if (analysis) {
202-
ts.sort();
203-
List<Point> points;
204-
if (ts.size() > 200_000) {
205-
points = ts.points().filter(point -> point.getIndex() % 1000 == 0).collect(Collectors.toList());
206-
} else {
207-
points = ts.points().collect(Collectors.toList());
208-
}
209-
//reduce the amount shown in the chart we add every 100ths point
210-
addPointsToSeries(series, points);
211-
Platform.runLater(() -> chart.getData().add(series));
224+
String name = splits[2];
212225

226+
//Check if the function has an argument
227+
Object arguments = ts.attribute(splits[0] + "_" + splits[1] + "_arguments_" + splits[2]);
213228

214-
} else {
215-
Instant start = Instant.ofEpochMilli(ts.getStart());
216-
Instant end = Instant.ofEpochMilli(ts.getEnd());
217-
218-
series.getData().add(new XYChart.Data(start, value));
219-
series.getData().add(new XYChart.Data(end, value));
220-
Platform.runLater(() -> chart.getData().add(series));
229+
ResultRow row = new ResultRow();
230+
row.setTimeSeries(join(ts));
231+
row.setAggregationOrAnalysis(name);
232+
if (arguments != null) {
233+
row.setArguments(arguments.toString());
221234
}
235+
row.setValues(value.toString());
236+
row.setOrder(key);
222237

223238

224-
} else {
225-
//function arguments
226-
//currently ignored
239+
rows.add(row);
227240
}
228241

229242

@@ -276,7 +289,7 @@ private String join(MetricTimeSeries ts) {
276289
if (ts == null) {
277290
return "";
278291
}
279-
return String.valueOf(ts.attribute("host")) + "-" +
292+
return ts.attribute("host") + "-" +
280293
ts.attribute("source") + "-" +
281294
ts.attribute("group") + "-" +
282295
ts.getMetric();
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
* Copyright (C) 2015 QAware GmbH
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package de.qaware.chronix.examples.exploration.ui.dt;
17+
18+
import javafx.beans.property.SimpleStringProperty;
19+
20+
/**
21+
* Simple java fx result row
22+
*
23+
* @author f.lautenschlager
24+
*/
25+
public class ResultRow {
26+
27+
private final SimpleStringProperty timeSeries = new SimpleStringProperty("");
28+
private final SimpleStringProperty aggregationOrAnalysis = new SimpleStringProperty("");
29+
private final SimpleStringProperty arguments = new SimpleStringProperty("");
30+
private final SimpleStringProperty values = new SimpleStringProperty("");
31+
private final SimpleStringProperty order = new SimpleStringProperty("");
32+
33+
34+
public String getTimeSeries() {
35+
return timeSeries.get();
36+
}
37+
38+
public void setTimeSeries(String timeSeries) {
39+
this.timeSeries.set(timeSeries);
40+
}
41+
42+
public SimpleStringProperty timeSeriesProperty() {
43+
return timeSeries;
44+
}
45+
46+
public String getAggregationOrAnalysis() {
47+
return aggregationOrAnalysis.get();
48+
}
49+
50+
public void setAggregationOrAnalysis(String aggregationOrAnalysis) {
51+
this.aggregationOrAnalysis.set(aggregationOrAnalysis);
52+
}
53+
54+
public SimpleStringProperty aggregationOrAnalysisProperty() {
55+
return aggregationOrAnalysis;
56+
}
57+
58+
public String getArguments() {
59+
return arguments.get();
60+
}
61+
62+
public void setArguments(String arguments) {
63+
this.arguments.set(arguments);
64+
}
65+
66+
public SimpleStringProperty argumentsProperty() {
67+
return arguments;
68+
}
69+
70+
public String getValues() {
71+
return values.get();
72+
}
73+
74+
public void setValues(String values) {
75+
this.values.set(values);
76+
}
77+
78+
public SimpleStringProperty valuesProperty() {
79+
return values;
80+
}
81+
82+
public String getOrder() {
83+
return order.get();
84+
}
85+
86+
public void setOrder(String order) {
87+
this.order.set(order);
88+
}
89+
90+
public SimpleStringProperty orderProperty() {
91+
return order;
92+
}
93+
}

chronix-timeseries-exploration/src/main/resources/de/qaware/chronix/examples/exploration/ui/Main.fxml

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
<?import javafx.scene.paint.Color?>
4242
<?import javafx.scene.shape.Circle?>
4343
<?import javafx.scene.text.Font?>
44-
45-
<VBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="600.0" prefWidth="1400.0"
46-
xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
44+
<VBox xmlns:fx="http://javafx.com/fxml/1" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308"
45+
prefHeight="600.0"
46+
prefWidth="1400.0" xmlns="http://javafx.com/javafx/8"
4747
fx:controller="de.qaware.chronix.examples.exploration.ui.MainController">
4848
<children>
4949
<AnchorPane focusTraversable="true" VBox.vgrow="ALWAYS">
@@ -63,29 +63,53 @@
6363
prefWidth="400.0"
6464
visible="true" wrapText="true"
6565

66-
promptText="Enter your filter query to analyze results, e.g., ag=max, ag=dev, analysis=trend"
66+
promptText="Enter your filter query to analyze results, e.g., function=max;dev, function=trend"
6767

6868
/>
6969
</children>
7070
</VBox>
7171
</top>
7272
<center>
73-
7473
<SplitPane orientation="VERTICAL">
75-
<LineChart fx:id="chart" alternativeColumnFillVisible="false" alternativeRowFillVisible="true"
76-
animated="false" cache="true" createSymbols="false" horizontalGridLinesVisible="true"
77-
horizontalZeroLineVisible="true" legendSide="TOP" legendVisible="true"
78-
maxHeight="Infinity" maxWidth="Infinity"
79-
verticalGridLinesVisible="true" verticalZeroLineVisible="true"
80-
BorderPane.alignment="CENTER"
81-
style=" -fx-stroke-width: 1px; -fx-effect: null; -fx-background-color: #ffffff;">
82-
<xAxis>
83-
<DateAxis side="BOTTOM"/>
84-
</xAxis>
85-
<yAxis>
86-
<NumberAxis side="LEFT"/>
87-
</yAxis>
88-
</LineChart>
74+
<TabPane prefHeight="600">
75+
<tabs>
76+
<Tab text="Chart" closable="false">
77+
<content>
78+
<LineChart fx:id="chart" alternativeColumnFillVisible="false"
79+
alternativeRowFillVisible="true"
80+
animated="false" cache="true" createSymbols="false"
81+
horizontalGridLinesVisible="true"
82+
horizontalZeroLineVisible="true" legendSide="TOP"
83+
legendVisible="true"
84+
maxHeight="Infinity" maxWidth="Infinity"
85+
verticalGridLinesVisible="true" verticalZeroLineVisible="true"
86+
BorderPane.alignment="CENTER"
87+
style=" -fx-stroke-width: 1px; -fx-effect: null; -fx-background-color: #ffffff;">
88+
<xAxis>
89+
<DateAxis side="BOTTOM"/>
90+
</xAxis>
91+
<yAxis>
92+
<NumberAxis side="LEFT"/>
93+
</yAxis>
94+
</LineChart>
95+
</content>
96+
</Tab>
97+
<Tab text="Function results" closable="false">
98+
<content>
99+
<TableView fx:id="resultTable" GridPane.columnIndex="0" GridPane.rowIndex="1">
100+
<columns>
101+
<TableColumn fx:id="timeSeries" text="Time Series" prefWidth="300"/>
102+
<TableColumn fx:id="aggregationOrAnalysis"
103+
text="Aggregation or Analysis" prefWidth="300"/>
104+
<TableColumn fx:id="arguments" text="Arguments" prefWidth="300"/>
105+
<TableColumn fx:id="values" text="Values" prefWidth="300"/>
106+
<TableColumn fx:id="order" text="Execution Order" prefWidth="300"/>
107+
</columns>
108+
</TableView>
109+
</content>
110+
</Tab>
111+
</tabs>
112+
</TabPane>
89113
<AnchorPane>
90114
<children>
91115
<TextArea fx:id="logs" AnchorPane.leftAnchor="0" AnchorPane.bottomAnchor="0"
@@ -119,4 +143,4 @@
119143
</padding>
120144
</HBox>
121145
</children>
122-
</VBox>
146+
</VBox>

0 commit comments

Comments
 (0)