use of org.graylog.plugins.views.search.views.widgets.aggregation.AggregationConfigDTO in project graylog2-server by Graylog2.
the class DashboardWidgetConverter method createMapWidget.
private List<WidgetEntity> createMapWidget() {
final String field = config.getString("field");
final PivotDTO fieldPivot = PivotDTO.Builder.builder().type("values").config(ValueConfigDTO.Builder.builder().build()).field(field).build();
final AggregationConfigDTO widgetConfig = AggregationConfigDTO.Builder.builder().series(ImmutableList.of(createSeriesDTO("count", ""))).visualization("map").rowPivots(ImmutableList.of(fieldPivot)).columnPivots(Collections.emptyList()).sort(Collections.emptyList()).build();
final WidgetEntity.Builder widgetEntityBuilder = aggregationWidgetBuilder().config(widgetConfig);
final Optional<String> query = config.getOptionalString("query");
query.ifPresent(s -> widgetEntityBuilder.query(ElasticsearchQueryString.of(s)));
return ImmutableList.of(widgetEntityBuilder.build());
}
use of org.graylog.plugins.views.search.views.widgets.aggregation.AggregationConfigDTO in project graylog2-server by Graylog2.
the class WidgetEntity method createSearchTypeEntity.
public List<SearchTypeEntity> createSearchTypeEntity() {
if (!type().matches(AggregationConfigDTO.NAME)) {
return ImmutableList.of();
}
AggregationConfigDTO config = (AggregationConfigDTO) config();
final PivotEntity.Builder pivotBuilder = PivotEntity.builder().name("chart").streams(streams()).rollup(true).sort(toSortSpec(config)).rowGroups(toRowGroups(config)).series(toSeriesSpecs(config)).id(UUID.randomUUID().toString());
query().ifPresent(pivotBuilder::query);
timerange().ifPresent(pivotBuilder::timerange);
if (config.visualization().matches("numeric")) {
final PivotEntity chart = pivotBuilder.build();
final PivotEntity trend = pivotBuilder.id(UUID.randomUUID().toString()).name("trend").timerange(OffsetRange.Builder.builder().source("search_type").id(chart.id()).build()).build();
return ImmutableList.of(chart, trend);
}
return ImmutableList.of(pivotBuilder.build());
}
use of org.graylog.plugins.views.search.views.widgets.aggregation.AggregationConfigDTO in project graylog2-server by Graylog2.
the class DashboardWidgetConverter method createStatsCountWidget.
private List<WidgetEntity> createStatsCountWidget() {
final String function = config.getString("stats_function");
final String field = config.getString("field");
final boolean trend = config.getBoolean("trend");
final boolean lowerIsBetter = config.getBoolean("lower_is_better");
final AggregationConfigDTO widgetConfig = AggregationConfigDTO.Builder.builder().series(ImmutableList.of(createSeriesDTO(function, field))).visualization("numeric").visualizationConfig(NumberVisualizationConfigDTO.Builder.builder().trend(trend).trendPreference(lowerIsBetter ? NumberVisualizationConfigDTO.TrendPreference.LOWER : NumberVisualizationConfigDTO.TrendPreference.HIGHER).build()).rowPivots(Collections.emptyList()).columnPivots(Collections.emptyList()).sort(Collections.emptyList()).build();
final WidgetEntity.Builder widgetEntityBuilder = aggregationWidgetBuilder().config(widgetConfig);
final Optional<String> query = config.getOptionalString("query");
query.ifPresent(s -> widgetEntityBuilder.query(ElasticsearchQueryString.of(s)));
return ImmutableList.of(widgetEntityBuilder.build());
}
use of org.graylog.plugins.views.search.views.widgets.aggregation.AggregationConfigDTO in project graylog2-server by Graylog2.
the class DashboardWidgetConverter method createSearchResultCount.
private List<WidgetEntity> createSearchResultCount() {
final boolean trend = config.getBoolean("trend");
final boolean lowerIsBetter = config.getBoolean("lower_is_better");
final AggregationConfigDTO widgetConfig = AggregationConfigDTO.Builder.builder().series(ImmutableList.of(createSeriesDTO("count", ""))).visualization("numeric").visualizationConfig(NumberVisualizationConfigDTO.Builder.builder().trend(trend).trendPreference(lowerIsBetter ? NumberVisualizationConfigDTO.TrendPreference.LOWER : NumberVisualizationConfigDTO.TrendPreference.HIGHER).build()).rowPivots(Collections.emptyList()).columnPivots(Collections.emptyList()).sort(Collections.emptyList()).build();
final WidgetEntity.Builder widgetEntityBuilder = aggregationWidgetBuilder().config(widgetConfig);
return ImmutableList.of(widgetEntityBuilder.build());
}
Aggregations