Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support formulas and functions in Treemap Widget #1147

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.5.1.dev2",
"regenerated": "2022-01-12 15:42:19.405514",
"spec_repo_commit": "9a4c69f"
"regenerated": "2022-01-12 16:36:59.841666",
"spec_repo_commit": "9f3c740"
},
"v2": {
"apigentools_version": "1.5.1.dev2",
"regenerated": "2022-01-12 15:42:20.247481",
"spec_repo_commit": "9a4c69f"
"regenerated": "2022-01-12 16:37:00.753203",
"spec_repo_commit": "9f3c740"
}
}
}
17 changes: 14 additions & 3 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12260,9 +12260,6 @@ components:
required:
- type
- requests
- size_by
- color_by
- group_by
type: object
TreeMapWidgetDefinitionType:
default: treemap
Expand All @@ -12276,9 +12273,23 @@ components:
TreeMapWidgetRequest:
description: An updated treemap widget.
properties:
formulas:
description: List of formulas that operate on queries. **This feature is
currently in beta.**
items:
$ref: '#/components/schemas/WidgetFormula'
type: array
q:
description: The widget metrics query.
type: string
queries:
description: List of queries that can be returned directly or used in formulas.
**This feature is currently in beta.**
items:
$ref: '#/components/schemas/FormulaAndFunctionQueryDefinition'
type: array
response_format:
$ref: '#/components/schemas/FormulaAndFunctionResponseFormat'
type: object
UsageAnalyzedLogsHour:
description: The number of analyzed logs for each hour for a given organization.
Expand Down
6 changes: 3 additions & 3 deletions api_docs/v1/TreeMapWidgetDefinition.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ The treemap visualization found on the Host Dashboards comes from the output of

| Name | Type | Description | Notes |
| ------------ | --------------------------------------------------------------- | --------------------------------- | ---------- |
| **colorBy** | **TreeMapColorBy** | |
| **groupBy** | **TreeMapGroupBy** | |
| **colorBy** | **TreeMapColorBy** | | [optional] |
| **groupBy** | **TreeMapGroupBy** | | [optional] |
| **requests** | [**List<TreeMapWidgetRequest>**](TreeMapWidgetRequest.md) | List of top list widget requests. |
| **sizeBy** | **TreeMapSizeBy** | |
| **sizeBy** | **TreeMapSizeBy** | | [optional] |
| **title** | **String** | Title of your widget. | [optional] |
| **type** | **TreeMapWidgetDefinitionType** | |
9 changes: 6 additions & 3 deletions api_docs/v1/TreeMapWidgetRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ An updated treemap widget.

## Properties

| Name | Type | Description | Notes |
| ----- | ---------- | ------------------------- | ---------- |
| **q** | **String** | The widget metrics query. | [optional] |
| Name | Type | Description | Notes |
| ------------------ | ----------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | ---------- |
| **formulas** | [**List<WidgetFormula>**](WidgetFormula.md) | List of formulas that operate on queries. **This feature is currently in beta.** | [optional] |
| **q** | **String** | The widget metrics query. | [optional] |
| **queries** | [**List<FormulaAndFunctionQueryDefinition>**](FormulaAndFunctionQueryDefinition.md) | List of queries that can be returned directly or used in formulas. **This feature is currently in beta.** | [optional] |
| **responseFormat** | **FormulaAndFunctionResponseFormat** | | [optional] |
118 changes: 118 additions & 0 deletions examples/v1/dashboards/CreateDashboard_1024858348.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
// Create a new dashboard with a formulas and functions treemap widget

import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.api.DashboardsApi;
import com.datadog.api.v1.client.model.Dashboard;
import com.datadog.api.v1.client.model.DashboardLayoutType;
import com.datadog.api.v1.client.model.FormulaAndFunctionEventAggregation;
import com.datadog.api.v1.client.model.FormulaAndFunctionEventQueryDefinition;
import com.datadog.api.v1.client.model.FormulaAndFunctionEventQueryDefinitionCompute;
import com.datadog.api.v1.client.model.FormulaAndFunctionEventQueryDefinitionSearch;
import com.datadog.api.v1.client.model.FormulaAndFunctionEventQueryGroupBy;
import com.datadog.api.v1.client.model.FormulaAndFunctionEventsDataSource;
import com.datadog.api.v1.client.model.FormulaAndFunctionQueryDefinition;
import com.datadog.api.v1.client.model.FormulaAndFunctionResponseFormat;
import com.datadog.api.v1.client.model.TreeMapWidgetDefinition;
import com.datadog.api.v1.client.model.TreeMapWidgetDefinitionType;
import com.datadog.api.v1.client.model.TreeMapWidgetRequest;
import com.datadog.api.v1.client.model.Widget;
import com.datadog.api.v1.client.model.WidgetDefinition;
import com.datadog.api.v1.client.model.WidgetFormula;
import com.datadog.api.v1.client.model.WidgetLayout;
import java.time.*;
import java.util.*;

public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
DashboardsApi apiInstance = new DashboardsApi(defaultClient);

Dashboard body =
new Dashboard()
.title("Example-Create_a_new_dashboard_with_a_formulas_and_functions_treemap_widget")
.widgets(
new ArrayList<Widget>() {
{
add(
new Widget()
.definition(
new WidgetDefinition(
new TreeMapWidgetDefinition()
.title("")
.type(TreeMapWidgetDefinitionType.TREEMAP)
.requests(
new ArrayList<TreeMapWidgetRequest>() {
{
add(
new TreeMapWidgetRequest()
.formulas(
new ArrayList<WidgetFormula>() {
{
add(
new WidgetFormula()
.formula(
"hour_before(query1)"));
add(
new WidgetFormula()
.formula("query1"));
}
})
.queries(
new ArrayList<
FormulaAndFunctionQueryDefinition>() {
{
add(
new FormulaAndFunctionQueryDefinition(
new FormulaAndFunctionEventQueryDefinition()
.dataSource(
FormulaAndFunctionEventsDataSource
.LOGS)
.name("query1")
.search(
new FormulaAndFunctionEventQueryDefinitionSearch()
.query(""))
.indexes(
new ArrayList<
String>() {
{
add("*");
}
})
.compute(
new FormulaAndFunctionEventQueryDefinitionCompute()
.aggregation(
FormulaAndFunctionEventAggregation
.COUNT))
.groupBy(
new ArrayList<
FormulaAndFunctionEventQueryGroupBy>() {
{
;
}
})));
}
})
.responseFormat(
FormulaAndFunctionResponseFormat
.SCALAR));
}
})))
.layout(new WidgetLayout().x(0L).y(0L).width(4L).height(4L)));
}
})
.layoutType(DashboardLayoutType.ORDERED);

try {
Dashboard result = apiInstance.createDashboard(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling DashboardsApi#createDashboard");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,10 @@ public TreeMapWidgetDefinition() {}

@JsonCreator
public TreeMapWidgetDefinition(
@JsonProperty(required = true, value = JSON_PROPERTY_COLOR_BY) TreeMapColorBy colorBy,
@JsonProperty(required = true, value = JSON_PROPERTY_GROUP_BY) TreeMapGroupBy groupBy,
@JsonProperty(required = true, value = JSON_PROPERTY_REQUESTS)
List<TreeMapWidgetRequest> requests,
@JsonProperty(required = true, value = JSON_PROPERTY_SIZE_BY) TreeMapSizeBy sizeBy,
@JsonProperty(required = true, value = JSON_PROPERTY_TYPE) TreeMapWidgetDefinitionType type) {
this.colorBy = colorBy;
this.unparsed |= !colorBy.isValid();
this.groupBy = groupBy;
this.unparsed |= !groupBy.isValid();
this.requests = requests;
this.sizeBy = sizeBy;
this.unparsed |= !sizeBy.isValid();
this.type = type;
this.unparsed |= !type.isValid();
}
Expand All @@ -94,9 +85,10 @@ public TreeMapWidgetDefinition colorBy(TreeMapColorBy colorBy) {
*
* @return colorBy
*/
@ApiModelProperty(required = true, value = "")
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_COLOR_BY)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public TreeMapColorBy getColorBy() {
return colorBy;
}
Expand All @@ -119,9 +111,10 @@ public TreeMapWidgetDefinition groupBy(TreeMapGroupBy groupBy) {
*
* @return groupBy
*/
@ApiModelProperty(required = true, value = "")
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_GROUP_BY)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public TreeMapGroupBy getGroupBy() {
return groupBy;
}
Expand Down Expand Up @@ -177,9 +170,10 @@ public TreeMapWidgetDefinition sizeBy(TreeMapSizeBy sizeBy) {
*
* @return sizeBy
*/
@ApiModelProperty(required = true, value = "")
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_SIZE_BY)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public TreeMapSizeBy getSizeBy() {
return sizeBy;
}
Expand Down
Loading