#[non_exhaustive]pub struct TableWidgetRequest {Show 22 fields
pub aggregator: Option<WidgetAggregator>,
pub alias: Option<String>,
pub apm_query: Option<LogQueryDefinition>,
pub apm_stats_query: Option<ApmStatsQueryDefinition>,
pub cell_display_mode: Option<Vec<TableWidgetCellDisplayMode>>,
pub conditional_formats: Option<Vec<WidgetConditionalFormat>>,
pub event_query: Option<LogQueryDefinition>,
pub formulas: Option<Vec<WidgetFormula>>,
pub limit: Option<i64>,
pub log_query: Option<LogQueryDefinition>,
pub network_query: Option<LogQueryDefinition>,
pub order: Option<WidgetSort>,
pub process_query: Option<ProcessQueryDefinition>,
pub profile_metrics_query: Option<LogQueryDefinition>,
pub q: Option<String>,
pub queries: Option<Vec<FormulaAndFunctionQueryDefinition>>,
pub response_format: Option<FormulaAndFunctionResponseFormat>,
pub rum_query: Option<LogQueryDefinition>,
pub security_query: Option<LogQueryDefinition>,
pub sort: Option<WidgetSortBy>,
pub text_formats: Option<Vec<Vec<TableWidgetTextFormatRule>>>,
pub additional_properties: BTreeMap<String, Value>,
/* private fields */
}
Expand description
Updated table widget.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.aggregator: Option<WidgetAggregator>
Aggregator used for the request.
alias: Option<String>
The column name (defaults to the metric name).
apm_query: Option<LogQueryDefinition>
The log query.
apm_stats_query: Option<ApmStatsQueryDefinition>
The APM stats query for table and distributions widgets.
cell_display_mode: Option<Vec<TableWidgetCellDisplayMode>>
A list of display modes for each table cell.
conditional_formats: Option<Vec<WidgetConditionalFormat>>
List of conditional formats.
event_query: Option<LogQueryDefinition>
The log query.
formulas: Option<Vec<WidgetFormula>>
List of formulas that operate on queries.
limit: Option<i64>
For metric queries, the number of lines to show in the table. Only one request should have this property.
log_query: Option<LogQueryDefinition>
The log query.
network_query: Option<LogQueryDefinition>
The log query.
order: Option<WidgetSort>
Widget sorting methods.
process_query: Option<ProcessQueryDefinition>
The process query to use in the widget.
profile_metrics_query: Option<LogQueryDefinition>
The log query.
q: Option<String>
Query definition.
queries: Option<Vec<FormulaAndFunctionQueryDefinition>>
List of queries that can be returned directly or used in formulas.
response_format: Option<FormulaAndFunctionResponseFormat>
Timeseries, scalar, or event list response. Event list response formats are supported by Geomap widgets.
rum_query: Option<LogQueryDefinition>
The log query.
security_query: Option<LogQueryDefinition>
The log query.
sort: Option<WidgetSortBy>
The controls for sorting the widget.
text_formats: Option<Vec<Vec<TableWidgetTextFormatRule>>>
List of text formats for columns produced by tags.
additional_properties: BTreeMap<String, Value>
Implementations§
Source§impl TableWidgetRequest
impl TableWidgetRequest
Sourcepub fn new() -> TableWidgetRequest
pub fn new() -> TableWidgetRequest
Examples found in repository?
27async fn main() {
28 let body = Dashboard::new(
29 DashboardLayoutType::ORDERED,
30 "Example-Dashboard with query table widget and storage parameter".to_string(),
31 vec![Widget::new(WidgetDefinition::TableWidgetDefinition(
32 Box::new(TableWidgetDefinition::new(
33 vec![TableWidgetRequest::new()
34 .formulas(vec![WidgetFormula::new("query1".to_string())
35 .cell_display_mode(TableWidgetCellDisplayMode::BAR)
36 .conditional_formats(vec![])])
37 .queries(vec![
38 FormulaAndFunctionQueryDefinition::FormulaAndFunctionEventQueryDefinition(
39 Box::new(
40 FormulaAndFunctionEventQueryDefinition::new(
41 FormulaAndFunctionEventQueryDefinitionCompute::new(
42 FormulaAndFunctionEventAggregation::COUNT,
43 ),
44 FormulaAndFunctionEventsDataSource::LOGS,
45 "query1".to_string(),
46 )
47 .group_by(vec![])
48 .indexes(vec!["*".to_string()])
49 .search(FormulaAndFunctionEventQueryDefinitionSearch::new(
50 "".to_string(),
51 ))
52 .storage("online_archives".to_string()),
53 ),
54 ),
55 ])
56 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
57 .sort(WidgetSortBy::new().count(50).order_by(vec![
58 WidgetSortOrderBy::WidgetFormulaSort(Box::new(WidgetFormulaSort::new(
59 0,
60 WidgetSort::DESCENDING,
61 FormulaType::FORMULA,
62 ))),
63 ]))],
64 TableWidgetDefinitionType::QUERY_TABLE,
65 )),
66 ))],
67 );
68 let configuration = datadog::Configuration::new();
69 let api = DashboardsAPI::with_config(configuration);
70 let resp = api.create_dashboard(body).await;
71 if let Ok(value) = resp {
72 println!("{:#?}", value);
73 } else {
74 println!("{:#?}", resp.unwrap_err());
75 }
76}
More examples
20async fn main() {
21 let body =
22 Dashboard::new(
23 DashboardLayoutType::ORDERED,
24 "Example-Dashboard".to_string(),
25 vec![
26 Widget::new(
27 WidgetDefinition::TableWidgetDefinition(
28 Box::new(
29 TableWidgetDefinition::new(
30 vec![
31 TableWidgetRequest::new()
32 .queries(
33 vec![
34 FormulaAndFunctionQueryDefinition
35 ::FormulaAndFunctionApmResourceStatsQueryDefinition(
36 Box::new(
37 FormulaAndFunctionApmResourceStatsQueryDefinition::new(
38 FormulaAndFunctionApmResourceStatsDataSource
39 ::APM_RESOURCE_STATS,
40 "ci".to_string(),
41 "query1".to_string(),
42 "cassandra".to_string(),
43 FormulaAndFunctionApmResourceStatName::HITS,
44 )
45 .group_by(vec!["resource_name".to_string()])
46 .operation_name("cassandra.query".to_string())
47 .primary_tag_name("datacenter".to_string())
48 .primary_tag_value("edge-eu1.prod.dog".to_string()),
49 ),
50 )
51 ],
52 )
53 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
54 ],
55 TableWidgetDefinitionType::QUERY_TABLE,
56 )
57 .title("".to_string())
58 .title_align(WidgetTextAlign::LEFT)
59 .title_size("16".to_string()),
60 ),
61 ),
62 ).layout(WidgetLayout::new(4, 4, 0, 0))
63 ],
64 );
65 let configuration = datadog::Configuration::new();
66 let api = DashboardsAPI::with_config(configuration);
67 let resp = api.create_dashboard(body).await;
68 if let Ok(value) = resp {
69 println!("{:#?}", value);
70 } else {
71 println!("{:#?}", resp.unwrap_err());
72 }
73}
20async fn main() {
21 let body =
22 Dashboard::new(
23 DashboardLayoutType::ORDERED,
24 "Example-Dashboard".to_string(),
25 vec![
26 Widget::new(
27 WidgetDefinition::TableWidgetDefinition(
28 Box::new(
29 TableWidgetDefinition::new(
30 vec![
31 TableWidgetRequest::new()
32 .queries(
33 vec![
34 FormulaAndFunctionQueryDefinition
35 ::FormulaAndFunctionApmDependencyStatsQueryDefinition(
36 Box::new(
37 FormulaAndFunctionApmDependencyStatsQueryDefinition::new(
38 FormulaAndFunctionApmDependencyStatsDataSource
39 ::APM_DEPENDENCY_STATS,
40 "ci".to_string(),
41 "query1".to_string(),
42 "cassandra.query".to_string(),
43 "DELETE FROM monitor_history.monitor_state_change_history WHERE org_id = ? AND monitor_id IN ? AND group = ?".to_string(),
44 "cassandra".to_string(),
45 FormulaAndFunctionApmDependencyStatName::AVG_DURATION,
46 )
47 .primary_tag_name("datacenter".to_string())
48 .primary_tag_value("edge-eu1.prod.dog".to_string()),
49 ),
50 )
51 ],
52 )
53 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
54 ],
55 TableWidgetDefinitionType::QUERY_TABLE,
56 )
57 .title("".to_string())
58 .title_align(WidgetTextAlign::LEFT)
59 .title_size("16".to_string()),
60 ),
61 ),
62 ).layout(WidgetLayout::new(4, 4, 0, 0))
63 ],
64 );
65 let configuration = datadog::Configuration::new();
66 let api = DashboardsAPI::with_config(configuration);
67 let resp = api.create_dashboard(body).await;
68 if let Ok(value) = resp {
69 println!("{:#?}", value);
70 } else {
71 println!("{:#?}", resp.unwrap_err());
72 }
73}
30async fn main() {
31 let body =
32 Dashboard::new(
33 DashboardLayoutType::FREE,
34 "Example-Dashboard".to_string(),
35 vec![
36 Widget::new(
37 WidgetDefinition::TableWidgetDefinition(
38 Box::new(
39 TableWidgetDefinition::new(
40 vec![
41 TableWidgetRequest::new()
42 .formulas(
43 vec![
44 WidgetFormula::new("query1".to_string())
45 .cell_display_mode(TableWidgetCellDisplayMode::BAR)
46 .conditional_formats(vec![])
47 ],
48 )
49 .queries(
50 vec![
51 FormulaAndFunctionQueryDefinition
52 ::FormulaAndFunctionMetricQueryDefinition(
53 Box::new(
54 FormulaAndFunctionMetricQueryDefinition::new(
55 FormulaAndFunctionMetricDataSource::METRICS,
56 "query1".to_string(),
57 "avg:system.cpu.user{*} by {host}".to_string(),
58 ).aggregator(FormulaAndFunctionMetricAggregation::AVG),
59 ),
60 )
61 ],
62 )
63 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
64 .sort(
65 WidgetSortBy::new()
66 .count(500)
67 .order_by(
68 vec![
69 WidgetSortOrderBy::WidgetFormulaSort(
70 Box::new(
71 WidgetFormulaSort::new(
72 0,
73 WidgetSort::DESCENDING,
74 FormulaType::FORMULA,
75 ),
76 ),
77 )
78 ],
79 ),
80 )
81 ],
82 TableWidgetDefinitionType::QUERY_TABLE,
83 )
84 .has_search_bar(TableWidgetHasSearchBar::AUTO)
85 .time(WidgetTime::WidgetLegacyLiveSpan(Box::new(WidgetLegacyLiveSpan::new())))
86 .title("".to_string())
87 .title_align(WidgetTextAlign::LEFT)
88 .title_size("16".to_string()),
89 ),
90 ),
91 ).layout(WidgetLayout::new(32, 54, 0, 0))
92 ],
93 )
94 .description(Some("".to_string()))
95 .notify_list(Some(vec![]))
96 .template_variables(Some(vec![]));
97 let configuration = datadog::Configuration::new();
98 let api = DashboardsAPI::with_config(configuration);
99 let resp = api.create_dashboard(body).await;
100 if let Ok(value) = resp {
101 println!("{:#?}", value);
102 } else {
103 println!("{:#?}", resp.unwrap_err());
104 }
105}
33async fn main() {
34 let body =
35 Dashboard::new(
36 DashboardLayoutType::FREE,
37 "Example-Dashboard".to_string(),
38 vec![
39 Widget::new(
40 WidgetDefinition::TableWidgetDefinition(
41 Box::new(
42 TableWidgetDefinition::new(
43 vec![
44 TableWidgetRequest::new()
45 .formulas(
46 vec![
47 WidgetFormula::new("query1".to_string())
48 .cell_display_mode(TableWidgetCellDisplayMode::TREND)
49 .cell_display_mode_options(
50 WidgetFormulaCellDisplayModeOptions::new()
51 .trend_type(
52 WidgetFormulaCellDisplayModeOptionsTrendType::LINE,
53 )
54 .y_scale(
55 WidgetFormulaCellDisplayModeOptionsYScale::SHARED,
56 ),
57 )
58 .conditional_formats(vec![])
59 ],
60 )
61 .queries(
62 vec![
63 FormulaAndFunctionQueryDefinition
64 ::FormulaAndFunctionMetricQueryDefinition(
65 Box::new(
66 FormulaAndFunctionMetricQueryDefinition::new(
67 FormulaAndFunctionMetricDataSource::METRICS,
68 "query1".to_string(),
69 "avg:system.cpu.user{*} by {host}".to_string(),
70 ).aggregator(FormulaAndFunctionMetricAggregation::AVG),
71 ),
72 )
73 ],
74 )
75 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
76 .sort(
77 WidgetSortBy::new()
78 .count(500)
79 .order_by(
80 vec![
81 WidgetSortOrderBy::WidgetFormulaSort(
82 Box::new(
83 WidgetFormulaSort::new(
84 0,
85 WidgetSort::DESCENDING,
86 FormulaType::FORMULA,
87 ),
88 ),
89 )
90 ],
91 ),
92 )
93 ],
94 TableWidgetDefinitionType::QUERY_TABLE,
95 )
96 .has_search_bar(TableWidgetHasSearchBar::AUTO)
97 .time(WidgetTime::WidgetLegacyLiveSpan(Box::new(WidgetLegacyLiveSpan::new())))
98 .title("".to_string())
99 .title_align(WidgetTextAlign::LEFT)
100 .title_size("16".to_string()),
101 ),
102 ),
103 ).layout(WidgetLayout::new(32, 54, 0, 0))
104 ],
105 )
106 .description(Some("".to_string()))
107 .notify_list(Some(vec![]))
108 .template_variables(Some(vec![]));
109 let configuration = datadog::Configuration::new();
110 let api = DashboardsAPI::with_config(configuration);
111 let resp = api.create_dashboard(body).await;
112 if let Ok(value) = resp {
113 println!("{:#?}", value);
114 } else {
115 println!("{:#?}", resp.unwrap_err());
116 }
117}
28async fn main() {
29 let body =
30 Dashboard::new(
31 DashboardLayoutType::FREE,
32 "Example-Dashboard".to_string(),
33 vec![
34 Widget::new(
35 WidgetDefinition::TableWidgetDefinition(
36 Box::new(
37 TableWidgetDefinition::new(
38 vec![
39 TableWidgetRequest::new()
40 .formulas(vec![])
41 .queries(
42 vec![
43 FormulaAndFunctionQueryDefinition
44 ::FormulaAndFunctionMetricQueryDefinition(
45 Box::new(
46 FormulaAndFunctionMetricQueryDefinition::new(
47 FormulaAndFunctionMetricDataSource::METRICS,
48 "query1".to_string(),
49 "avg:aws.stream.globalaccelerator.processed_bytes_in{*} by {aws_account,acceleratoripaddress}".to_string(),
50 ).aggregator(FormulaAndFunctionMetricAggregation::AVG),
51 ),
52 ),
53 FormulaAndFunctionQueryDefinition
54 ::FormulaAndFunctionMetricQueryDefinition(
55 Box::new(
56 FormulaAndFunctionMetricQueryDefinition::new(
57 FormulaAndFunctionMetricDataSource::METRICS,
58 "query2".to_string(),
59 "avg:aws.stream.globalaccelerator.processed_bytes_out{*} by {aws_account,acceleratoripaddress}".to_string(),
60 ).aggregator(FormulaAndFunctionMetricAggregation::AVG),
61 ),
62 )
63 ],
64 )
65 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
66 .text_formats(
67 vec![
68 vec![
69 TableWidgetTextFormatRule::new(
70 TableWidgetTextFormatMatch::new(
71 TableWidgetTextFormatMatchType::IS,
72 "fruit".to_string(),
73 ),
74 )
75 .palette(TableWidgetTextFormatPalette::WHITE_ON_RED)
76 .replace(
77 TableWidgetTextFormatReplace
78 ::TableWidgetTextFormatReplaceAll(
79 Box::new(
80 TableWidgetTextFormatReplaceAll::new(
81 TableWidgetTextFormatReplaceAllType::ALL,
82 "vegetable".to_string(),
83 ),
84 ),
85 ),
86 ),
87 TableWidgetTextFormatRule::new(
88 TableWidgetTextFormatMatch::new(
89 TableWidgetTextFormatMatchType::IS,
90 "animal".to_string(),
91 ),
92 )
93 .custom_bg_color("#632ca6".to_string())
94 .palette(TableWidgetTextFormatPalette::CUSTOM_BG),
95 TableWidgetTextFormatRule::new(
96 TableWidgetTextFormatMatch::new(
97 TableWidgetTextFormatMatchType::IS,
98 "robot".to_string(),
99 ),
100 ).palette(TableWidgetTextFormatPalette::RED_ON_WHITE),
101 TableWidgetTextFormatRule::new(
102 TableWidgetTextFormatMatch::new(
103 TableWidgetTextFormatMatchType::IS,
104 "ai".to_string(),
105 ),
106 ).palette(TableWidgetTextFormatPalette::YELLOW_ON_WHITE)
107 ],
108 vec![
109 TableWidgetTextFormatRule::new(
110 TableWidgetTextFormatMatch::new(
111 TableWidgetTextFormatMatchType::IS_NOT,
112 "xyz".to_string(),
113 ),
114 ).palette(TableWidgetTextFormatPalette::WHITE_ON_YELLOW)
115 ],
116 vec![
117 TableWidgetTextFormatRule::new(
118 TableWidgetTextFormatMatch::new(
119 TableWidgetTextFormatMatchType::CONTAINS,
120 "test".to_string(),
121 ),
122 )
123 .palette(TableWidgetTextFormatPalette::WHITE_ON_GREEN)
124 .replace(
125 TableWidgetTextFormatReplace
126 ::TableWidgetTextFormatReplaceAll(
127 Box::new(
128 TableWidgetTextFormatReplaceAll::new(
129 TableWidgetTextFormatReplaceAllType::ALL,
130 "vegetable".to_string(),
131 ),
132 ),
133 ),
134 )
135 ],
136 vec![
137 TableWidgetTextFormatRule::new(
138 TableWidgetTextFormatMatch::new(
139 TableWidgetTextFormatMatchType::DOES_NOT_CONTAIN,
140 "blah".to_string(),
141 ),
142 ).palette(TableWidgetTextFormatPalette::BLACK_ON_LIGHT_RED)
143 ],
144 vec![
145 TableWidgetTextFormatRule::new(
146 TableWidgetTextFormatMatch::new(
147 TableWidgetTextFormatMatchType::STARTS_WITH,
148 "abc".to_string(),
149 ),
150 ).palette(TableWidgetTextFormatPalette::BLACK_ON_LIGHT_YELLOW)
151 ],
152 vec![
153 TableWidgetTextFormatRule::new(
154 TableWidgetTextFormatMatch::new(
155 TableWidgetTextFormatMatchType::ENDS_WITH,
156 "xyz".to_string(),
157 ),
158 ).palette(TableWidgetTextFormatPalette::BLACK_ON_LIGHT_GREEN),
159 TableWidgetTextFormatRule::new(
160 TableWidgetTextFormatMatch::new(
161 TableWidgetTextFormatMatchType::ENDS_WITH,
162 "zzz".to_string(),
163 ),
164 ).palette(TableWidgetTextFormatPalette::GREEN_ON_WHITE),
165 TableWidgetTextFormatRule::new(
166 TableWidgetTextFormatMatch::new(
167 TableWidgetTextFormatMatchType::IS,
168 "animal".to_string(),
169 ),
170 )
171 .custom_fg_color("#632ca6".to_string())
172 .palette(TableWidgetTextFormatPalette::CUSTOM_TEXT)
173 ]
174 ],
175 )
176 ],
177 TableWidgetDefinitionType::QUERY_TABLE,
178 )
179 .has_search_bar(TableWidgetHasSearchBar::NEVER)
180 .title("".to_string())
181 .title_align(WidgetTextAlign::LEFT)
182 .title_size("16".to_string()),
183 ),
184 ),
185 ).layout(WidgetLayout::new(4, 4, 0, 0))
186 ],
187 )
188 .description(Some("".to_string()))
189 .notify_list(Some(vec![]))
190 .template_variables(Some(vec![]));
191 let configuration = datadog::Configuration::new();
192 let api = DashboardsAPI::with_config(configuration);
193 let resp = api.create_dashboard(body).await;
194 if let Ok(value) = resp {
195 println!("{:#?}", value);
196 } else {
197 println!("{:#?}", resp.unwrap_err());
198 }
199}
pub fn aggregator(self, value: WidgetAggregator) -> Self
pub fn alias(self, value: String) -> Self
pub fn apm_query(self, value: LogQueryDefinition) -> Self
pub fn apm_stats_query(self, value: ApmStatsQueryDefinition) -> Self
pub fn cell_display_mode(self, value: Vec<TableWidgetCellDisplayMode>) -> Self
pub fn conditional_formats(self, value: Vec<WidgetConditionalFormat>) -> Self
pub fn event_query(self, value: LogQueryDefinition) -> Self
Sourcepub fn formulas(self, value: Vec<WidgetFormula>) -> Self
pub fn formulas(self, value: Vec<WidgetFormula>) -> Self
Examples found in repository?
27async fn main() {
28 let body = Dashboard::new(
29 DashboardLayoutType::ORDERED,
30 "Example-Dashboard with query table widget and storage parameter".to_string(),
31 vec![Widget::new(WidgetDefinition::TableWidgetDefinition(
32 Box::new(TableWidgetDefinition::new(
33 vec![TableWidgetRequest::new()
34 .formulas(vec![WidgetFormula::new("query1".to_string())
35 .cell_display_mode(TableWidgetCellDisplayMode::BAR)
36 .conditional_formats(vec![])])
37 .queries(vec![
38 FormulaAndFunctionQueryDefinition::FormulaAndFunctionEventQueryDefinition(
39 Box::new(
40 FormulaAndFunctionEventQueryDefinition::new(
41 FormulaAndFunctionEventQueryDefinitionCompute::new(
42 FormulaAndFunctionEventAggregation::COUNT,
43 ),
44 FormulaAndFunctionEventsDataSource::LOGS,
45 "query1".to_string(),
46 )
47 .group_by(vec![])
48 .indexes(vec!["*".to_string()])
49 .search(FormulaAndFunctionEventQueryDefinitionSearch::new(
50 "".to_string(),
51 ))
52 .storage("online_archives".to_string()),
53 ),
54 ),
55 ])
56 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
57 .sort(WidgetSortBy::new().count(50).order_by(vec![
58 WidgetSortOrderBy::WidgetFormulaSort(Box::new(WidgetFormulaSort::new(
59 0,
60 WidgetSort::DESCENDING,
61 FormulaType::FORMULA,
62 ))),
63 ]))],
64 TableWidgetDefinitionType::QUERY_TABLE,
65 )),
66 ))],
67 );
68 let configuration = datadog::Configuration::new();
69 let api = DashboardsAPI::with_config(configuration);
70 let resp = api.create_dashboard(body).await;
71 if let Ok(value) = resp {
72 println!("{:#?}", value);
73 } else {
74 println!("{:#?}", resp.unwrap_err());
75 }
76}
More examples
30async fn main() {
31 let body =
32 Dashboard::new(
33 DashboardLayoutType::FREE,
34 "Example-Dashboard".to_string(),
35 vec![
36 Widget::new(
37 WidgetDefinition::TableWidgetDefinition(
38 Box::new(
39 TableWidgetDefinition::new(
40 vec![
41 TableWidgetRequest::new()
42 .formulas(
43 vec![
44 WidgetFormula::new("query1".to_string())
45 .cell_display_mode(TableWidgetCellDisplayMode::BAR)
46 .conditional_formats(vec![])
47 ],
48 )
49 .queries(
50 vec![
51 FormulaAndFunctionQueryDefinition
52 ::FormulaAndFunctionMetricQueryDefinition(
53 Box::new(
54 FormulaAndFunctionMetricQueryDefinition::new(
55 FormulaAndFunctionMetricDataSource::METRICS,
56 "query1".to_string(),
57 "avg:system.cpu.user{*} by {host}".to_string(),
58 ).aggregator(FormulaAndFunctionMetricAggregation::AVG),
59 ),
60 )
61 ],
62 )
63 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
64 .sort(
65 WidgetSortBy::new()
66 .count(500)
67 .order_by(
68 vec![
69 WidgetSortOrderBy::WidgetFormulaSort(
70 Box::new(
71 WidgetFormulaSort::new(
72 0,
73 WidgetSort::DESCENDING,
74 FormulaType::FORMULA,
75 ),
76 ),
77 )
78 ],
79 ),
80 )
81 ],
82 TableWidgetDefinitionType::QUERY_TABLE,
83 )
84 .has_search_bar(TableWidgetHasSearchBar::AUTO)
85 .time(WidgetTime::WidgetLegacyLiveSpan(Box::new(WidgetLegacyLiveSpan::new())))
86 .title("".to_string())
87 .title_align(WidgetTextAlign::LEFT)
88 .title_size("16".to_string()),
89 ),
90 ),
91 ).layout(WidgetLayout::new(32, 54, 0, 0))
92 ],
93 )
94 .description(Some("".to_string()))
95 .notify_list(Some(vec![]))
96 .template_variables(Some(vec![]));
97 let configuration = datadog::Configuration::new();
98 let api = DashboardsAPI::with_config(configuration);
99 let resp = api.create_dashboard(body).await;
100 if let Ok(value) = resp {
101 println!("{:#?}", value);
102 } else {
103 println!("{:#?}", resp.unwrap_err());
104 }
105}
33async fn main() {
34 let body =
35 Dashboard::new(
36 DashboardLayoutType::FREE,
37 "Example-Dashboard".to_string(),
38 vec![
39 Widget::new(
40 WidgetDefinition::TableWidgetDefinition(
41 Box::new(
42 TableWidgetDefinition::new(
43 vec![
44 TableWidgetRequest::new()
45 .formulas(
46 vec![
47 WidgetFormula::new("query1".to_string())
48 .cell_display_mode(TableWidgetCellDisplayMode::TREND)
49 .cell_display_mode_options(
50 WidgetFormulaCellDisplayModeOptions::new()
51 .trend_type(
52 WidgetFormulaCellDisplayModeOptionsTrendType::LINE,
53 )
54 .y_scale(
55 WidgetFormulaCellDisplayModeOptionsYScale::SHARED,
56 ),
57 )
58 .conditional_formats(vec![])
59 ],
60 )
61 .queries(
62 vec![
63 FormulaAndFunctionQueryDefinition
64 ::FormulaAndFunctionMetricQueryDefinition(
65 Box::new(
66 FormulaAndFunctionMetricQueryDefinition::new(
67 FormulaAndFunctionMetricDataSource::METRICS,
68 "query1".to_string(),
69 "avg:system.cpu.user{*} by {host}".to_string(),
70 ).aggregator(FormulaAndFunctionMetricAggregation::AVG),
71 ),
72 )
73 ],
74 )
75 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
76 .sort(
77 WidgetSortBy::new()
78 .count(500)
79 .order_by(
80 vec![
81 WidgetSortOrderBy::WidgetFormulaSort(
82 Box::new(
83 WidgetFormulaSort::new(
84 0,
85 WidgetSort::DESCENDING,
86 FormulaType::FORMULA,
87 ),
88 ),
89 )
90 ],
91 ),
92 )
93 ],
94 TableWidgetDefinitionType::QUERY_TABLE,
95 )
96 .has_search_bar(TableWidgetHasSearchBar::AUTO)
97 .time(WidgetTime::WidgetLegacyLiveSpan(Box::new(WidgetLegacyLiveSpan::new())))
98 .title("".to_string())
99 .title_align(WidgetTextAlign::LEFT)
100 .title_size("16".to_string()),
101 ),
102 ),
103 ).layout(WidgetLayout::new(32, 54, 0, 0))
104 ],
105 )
106 .description(Some("".to_string()))
107 .notify_list(Some(vec![]))
108 .template_variables(Some(vec![]));
109 let configuration = datadog::Configuration::new();
110 let api = DashboardsAPI::with_config(configuration);
111 let resp = api.create_dashboard(body).await;
112 if let Ok(value) = resp {
113 println!("{:#?}", value);
114 } else {
115 println!("{:#?}", resp.unwrap_err());
116 }
117}
28async fn main() {
29 let body =
30 Dashboard::new(
31 DashboardLayoutType::FREE,
32 "Example-Dashboard".to_string(),
33 vec![
34 Widget::new(
35 WidgetDefinition::TableWidgetDefinition(
36 Box::new(
37 TableWidgetDefinition::new(
38 vec![
39 TableWidgetRequest::new()
40 .formulas(vec![])
41 .queries(
42 vec![
43 FormulaAndFunctionQueryDefinition
44 ::FormulaAndFunctionMetricQueryDefinition(
45 Box::new(
46 FormulaAndFunctionMetricQueryDefinition::new(
47 FormulaAndFunctionMetricDataSource::METRICS,
48 "query1".to_string(),
49 "avg:aws.stream.globalaccelerator.processed_bytes_in{*} by {aws_account,acceleratoripaddress}".to_string(),
50 ).aggregator(FormulaAndFunctionMetricAggregation::AVG),
51 ),
52 ),
53 FormulaAndFunctionQueryDefinition
54 ::FormulaAndFunctionMetricQueryDefinition(
55 Box::new(
56 FormulaAndFunctionMetricQueryDefinition::new(
57 FormulaAndFunctionMetricDataSource::METRICS,
58 "query2".to_string(),
59 "avg:aws.stream.globalaccelerator.processed_bytes_out{*} by {aws_account,acceleratoripaddress}".to_string(),
60 ).aggregator(FormulaAndFunctionMetricAggregation::AVG),
61 ),
62 )
63 ],
64 )
65 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
66 .text_formats(
67 vec![
68 vec![
69 TableWidgetTextFormatRule::new(
70 TableWidgetTextFormatMatch::new(
71 TableWidgetTextFormatMatchType::IS,
72 "fruit".to_string(),
73 ),
74 )
75 .palette(TableWidgetTextFormatPalette::WHITE_ON_RED)
76 .replace(
77 TableWidgetTextFormatReplace
78 ::TableWidgetTextFormatReplaceAll(
79 Box::new(
80 TableWidgetTextFormatReplaceAll::new(
81 TableWidgetTextFormatReplaceAllType::ALL,
82 "vegetable".to_string(),
83 ),
84 ),
85 ),
86 ),
87 TableWidgetTextFormatRule::new(
88 TableWidgetTextFormatMatch::new(
89 TableWidgetTextFormatMatchType::IS,
90 "animal".to_string(),
91 ),
92 )
93 .custom_bg_color("#632ca6".to_string())
94 .palette(TableWidgetTextFormatPalette::CUSTOM_BG),
95 TableWidgetTextFormatRule::new(
96 TableWidgetTextFormatMatch::new(
97 TableWidgetTextFormatMatchType::IS,
98 "robot".to_string(),
99 ),
100 ).palette(TableWidgetTextFormatPalette::RED_ON_WHITE),
101 TableWidgetTextFormatRule::new(
102 TableWidgetTextFormatMatch::new(
103 TableWidgetTextFormatMatchType::IS,
104 "ai".to_string(),
105 ),
106 ).palette(TableWidgetTextFormatPalette::YELLOW_ON_WHITE)
107 ],
108 vec![
109 TableWidgetTextFormatRule::new(
110 TableWidgetTextFormatMatch::new(
111 TableWidgetTextFormatMatchType::IS_NOT,
112 "xyz".to_string(),
113 ),
114 ).palette(TableWidgetTextFormatPalette::WHITE_ON_YELLOW)
115 ],
116 vec![
117 TableWidgetTextFormatRule::new(
118 TableWidgetTextFormatMatch::new(
119 TableWidgetTextFormatMatchType::CONTAINS,
120 "test".to_string(),
121 ),
122 )
123 .palette(TableWidgetTextFormatPalette::WHITE_ON_GREEN)
124 .replace(
125 TableWidgetTextFormatReplace
126 ::TableWidgetTextFormatReplaceAll(
127 Box::new(
128 TableWidgetTextFormatReplaceAll::new(
129 TableWidgetTextFormatReplaceAllType::ALL,
130 "vegetable".to_string(),
131 ),
132 ),
133 ),
134 )
135 ],
136 vec![
137 TableWidgetTextFormatRule::new(
138 TableWidgetTextFormatMatch::new(
139 TableWidgetTextFormatMatchType::DOES_NOT_CONTAIN,
140 "blah".to_string(),
141 ),
142 ).palette(TableWidgetTextFormatPalette::BLACK_ON_LIGHT_RED)
143 ],
144 vec![
145 TableWidgetTextFormatRule::new(
146 TableWidgetTextFormatMatch::new(
147 TableWidgetTextFormatMatchType::STARTS_WITH,
148 "abc".to_string(),
149 ),
150 ).palette(TableWidgetTextFormatPalette::BLACK_ON_LIGHT_YELLOW)
151 ],
152 vec![
153 TableWidgetTextFormatRule::new(
154 TableWidgetTextFormatMatch::new(
155 TableWidgetTextFormatMatchType::ENDS_WITH,
156 "xyz".to_string(),
157 ),
158 ).palette(TableWidgetTextFormatPalette::BLACK_ON_LIGHT_GREEN),
159 TableWidgetTextFormatRule::new(
160 TableWidgetTextFormatMatch::new(
161 TableWidgetTextFormatMatchType::ENDS_WITH,
162 "zzz".to_string(),
163 ),
164 ).palette(TableWidgetTextFormatPalette::GREEN_ON_WHITE),
165 TableWidgetTextFormatRule::new(
166 TableWidgetTextFormatMatch::new(
167 TableWidgetTextFormatMatchType::IS,
168 "animal".to_string(),
169 ),
170 )
171 .custom_fg_color("#632ca6".to_string())
172 .palette(TableWidgetTextFormatPalette::CUSTOM_TEXT)
173 ]
174 ],
175 )
176 ],
177 TableWidgetDefinitionType::QUERY_TABLE,
178 )
179 .has_search_bar(TableWidgetHasSearchBar::NEVER)
180 .title("".to_string())
181 .title_align(WidgetTextAlign::LEFT)
182 .title_size("16".to_string()),
183 ),
184 ),
185 ).layout(WidgetLayout::new(4, 4, 0, 0))
186 ],
187 )
188 .description(Some("".to_string()))
189 .notify_list(Some(vec![]))
190 .template_variables(Some(vec![]));
191 let configuration = datadog::Configuration::new();
192 let api = DashboardsAPI::with_config(configuration);
193 let resp = api.create_dashboard(body).await;
194 if let Ok(value) = resp {
195 println!("{:#?}", value);
196 } else {
197 println!("{:#?}", resp.unwrap_err());
198 }
199}
pub fn limit(self, value: i64) -> Self
pub fn log_query(self, value: LogQueryDefinition) -> Self
pub fn network_query(self, value: LogQueryDefinition) -> Self
pub fn order(self, value: WidgetSort) -> Self
pub fn process_query(self, value: ProcessQueryDefinition) -> Self
pub fn profile_metrics_query(self, value: LogQueryDefinition) -> Self
pub fn q(self, value: String) -> Self
Sourcepub fn queries(self, value: Vec<FormulaAndFunctionQueryDefinition>) -> Self
pub fn queries(self, value: Vec<FormulaAndFunctionQueryDefinition>) -> Self
Examples found in repository?
27async fn main() {
28 let body = Dashboard::new(
29 DashboardLayoutType::ORDERED,
30 "Example-Dashboard with query table widget and storage parameter".to_string(),
31 vec![Widget::new(WidgetDefinition::TableWidgetDefinition(
32 Box::new(TableWidgetDefinition::new(
33 vec![TableWidgetRequest::new()
34 .formulas(vec![WidgetFormula::new("query1".to_string())
35 .cell_display_mode(TableWidgetCellDisplayMode::BAR)
36 .conditional_formats(vec![])])
37 .queries(vec![
38 FormulaAndFunctionQueryDefinition::FormulaAndFunctionEventQueryDefinition(
39 Box::new(
40 FormulaAndFunctionEventQueryDefinition::new(
41 FormulaAndFunctionEventQueryDefinitionCompute::new(
42 FormulaAndFunctionEventAggregation::COUNT,
43 ),
44 FormulaAndFunctionEventsDataSource::LOGS,
45 "query1".to_string(),
46 )
47 .group_by(vec![])
48 .indexes(vec!["*".to_string()])
49 .search(FormulaAndFunctionEventQueryDefinitionSearch::new(
50 "".to_string(),
51 ))
52 .storage("online_archives".to_string()),
53 ),
54 ),
55 ])
56 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
57 .sort(WidgetSortBy::new().count(50).order_by(vec![
58 WidgetSortOrderBy::WidgetFormulaSort(Box::new(WidgetFormulaSort::new(
59 0,
60 WidgetSort::DESCENDING,
61 FormulaType::FORMULA,
62 ))),
63 ]))],
64 TableWidgetDefinitionType::QUERY_TABLE,
65 )),
66 ))],
67 );
68 let configuration = datadog::Configuration::new();
69 let api = DashboardsAPI::with_config(configuration);
70 let resp = api.create_dashboard(body).await;
71 if let Ok(value) = resp {
72 println!("{:#?}", value);
73 } else {
74 println!("{:#?}", resp.unwrap_err());
75 }
76}
More examples
20async fn main() {
21 let body =
22 Dashboard::new(
23 DashboardLayoutType::ORDERED,
24 "Example-Dashboard".to_string(),
25 vec![
26 Widget::new(
27 WidgetDefinition::TableWidgetDefinition(
28 Box::new(
29 TableWidgetDefinition::new(
30 vec![
31 TableWidgetRequest::new()
32 .queries(
33 vec![
34 FormulaAndFunctionQueryDefinition
35 ::FormulaAndFunctionApmResourceStatsQueryDefinition(
36 Box::new(
37 FormulaAndFunctionApmResourceStatsQueryDefinition::new(
38 FormulaAndFunctionApmResourceStatsDataSource
39 ::APM_RESOURCE_STATS,
40 "ci".to_string(),
41 "query1".to_string(),
42 "cassandra".to_string(),
43 FormulaAndFunctionApmResourceStatName::HITS,
44 )
45 .group_by(vec!["resource_name".to_string()])
46 .operation_name("cassandra.query".to_string())
47 .primary_tag_name("datacenter".to_string())
48 .primary_tag_value("edge-eu1.prod.dog".to_string()),
49 ),
50 )
51 ],
52 )
53 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
54 ],
55 TableWidgetDefinitionType::QUERY_TABLE,
56 )
57 .title("".to_string())
58 .title_align(WidgetTextAlign::LEFT)
59 .title_size("16".to_string()),
60 ),
61 ),
62 ).layout(WidgetLayout::new(4, 4, 0, 0))
63 ],
64 );
65 let configuration = datadog::Configuration::new();
66 let api = DashboardsAPI::with_config(configuration);
67 let resp = api.create_dashboard(body).await;
68 if let Ok(value) = resp {
69 println!("{:#?}", value);
70 } else {
71 println!("{:#?}", resp.unwrap_err());
72 }
73}
20async fn main() {
21 let body =
22 Dashboard::new(
23 DashboardLayoutType::ORDERED,
24 "Example-Dashboard".to_string(),
25 vec![
26 Widget::new(
27 WidgetDefinition::TableWidgetDefinition(
28 Box::new(
29 TableWidgetDefinition::new(
30 vec![
31 TableWidgetRequest::new()
32 .queries(
33 vec![
34 FormulaAndFunctionQueryDefinition
35 ::FormulaAndFunctionApmDependencyStatsQueryDefinition(
36 Box::new(
37 FormulaAndFunctionApmDependencyStatsQueryDefinition::new(
38 FormulaAndFunctionApmDependencyStatsDataSource
39 ::APM_DEPENDENCY_STATS,
40 "ci".to_string(),
41 "query1".to_string(),
42 "cassandra.query".to_string(),
43 "DELETE FROM monitor_history.monitor_state_change_history WHERE org_id = ? AND monitor_id IN ? AND group = ?".to_string(),
44 "cassandra".to_string(),
45 FormulaAndFunctionApmDependencyStatName::AVG_DURATION,
46 )
47 .primary_tag_name("datacenter".to_string())
48 .primary_tag_value("edge-eu1.prod.dog".to_string()),
49 ),
50 )
51 ],
52 )
53 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
54 ],
55 TableWidgetDefinitionType::QUERY_TABLE,
56 )
57 .title("".to_string())
58 .title_align(WidgetTextAlign::LEFT)
59 .title_size("16".to_string()),
60 ),
61 ),
62 ).layout(WidgetLayout::new(4, 4, 0, 0))
63 ],
64 );
65 let configuration = datadog::Configuration::new();
66 let api = DashboardsAPI::with_config(configuration);
67 let resp = api.create_dashboard(body).await;
68 if let Ok(value) = resp {
69 println!("{:#?}", value);
70 } else {
71 println!("{:#?}", resp.unwrap_err());
72 }
73}
30async fn main() {
31 let body =
32 Dashboard::new(
33 DashboardLayoutType::FREE,
34 "Example-Dashboard".to_string(),
35 vec![
36 Widget::new(
37 WidgetDefinition::TableWidgetDefinition(
38 Box::new(
39 TableWidgetDefinition::new(
40 vec![
41 TableWidgetRequest::new()
42 .formulas(
43 vec![
44 WidgetFormula::new("query1".to_string())
45 .cell_display_mode(TableWidgetCellDisplayMode::BAR)
46 .conditional_formats(vec![])
47 ],
48 )
49 .queries(
50 vec![
51 FormulaAndFunctionQueryDefinition
52 ::FormulaAndFunctionMetricQueryDefinition(
53 Box::new(
54 FormulaAndFunctionMetricQueryDefinition::new(
55 FormulaAndFunctionMetricDataSource::METRICS,
56 "query1".to_string(),
57 "avg:system.cpu.user{*} by {host}".to_string(),
58 ).aggregator(FormulaAndFunctionMetricAggregation::AVG),
59 ),
60 )
61 ],
62 )
63 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
64 .sort(
65 WidgetSortBy::new()
66 .count(500)
67 .order_by(
68 vec![
69 WidgetSortOrderBy::WidgetFormulaSort(
70 Box::new(
71 WidgetFormulaSort::new(
72 0,
73 WidgetSort::DESCENDING,
74 FormulaType::FORMULA,
75 ),
76 ),
77 )
78 ],
79 ),
80 )
81 ],
82 TableWidgetDefinitionType::QUERY_TABLE,
83 )
84 .has_search_bar(TableWidgetHasSearchBar::AUTO)
85 .time(WidgetTime::WidgetLegacyLiveSpan(Box::new(WidgetLegacyLiveSpan::new())))
86 .title("".to_string())
87 .title_align(WidgetTextAlign::LEFT)
88 .title_size("16".to_string()),
89 ),
90 ),
91 ).layout(WidgetLayout::new(32, 54, 0, 0))
92 ],
93 )
94 .description(Some("".to_string()))
95 .notify_list(Some(vec![]))
96 .template_variables(Some(vec![]));
97 let configuration = datadog::Configuration::new();
98 let api = DashboardsAPI::with_config(configuration);
99 let resp = api.create_dashboard(body).await;
100 if let Ok(value) = resp {
101 println!("{:#?}", value);
102 } else {
103 println!("{:#?}", resp.unwrap_err());
104 }
105}
33async fn main() {
34 let body =
35 Dashboard::new(
36 DashboardLayoutType::FREE,
37 "Example-Dashboard".to_string(),
38 vec![
39 Widget::new(
40 WidgetDefinition::TableWidgetDefinition(
41 Box::new(
42 TableWidgetDefinition::new(
43 vec![
44 TableWidgetRequest::new()
45 .formulas(
46 vec![
47 WidgetFormula::new("query1".to_string())
48 .cell_display_mode(TableWidgetCellDisplayMode::TREND)
49 .cell_display_mode_options(
50 WidgetFormulaCellDisplayModeOptions::new()
51 .trend_type(
52 WidgetFormulaCellDisplayModeOptionsTrendType::LINE,
53 )
54 .y_scale(
55 WidgetFormulaCellDisplayModeOptionsYScale::SHARED,
56 ),
57 )
58 .conditional_formats(vec![])
59 ],
60 )
61 .queries(
62 vec![
63 FormulaAndFunctionQueryDefinition
64 ::FormulaAndFunctionMetricQueryDefinition(
65 Box::new(
66 FormulaAndFunctionMetricQueryDefinition::new(
67 FormulaAndFunctionMetricDataSource::METRICS,
68 "query1".to_string(),
69 "avg:system.cpu.user{*} by {host}".to_string(),
70 ).aggregator(FormulaAndFunctionMetricAggregation::AVG),
71 ),
72 )
73 ],
74 )
75 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
76 .sort(
77 WidgetSortBy::new()
78 .count(500)
79 .order_by(
80 vec![
81 WidgetSortOrderBy::WidgetFormulaSort(
82 Box::new(
83 WidgetFormulaSort::new(
84 0,
85 WidgetSort::DESCENDING,
86 FormulaType::FORMULA,
87 ),
88 ),
89 )
90 ],
91 ),
92 )
93 ],
94 TableWidgetDefinitionType::QUERY_TABLE,
95 )
96 .has_search_bar(TableWidgetHasSearchBar::AUTO)
97 .time(WidgetTime::WidgetLegacyLiveSpan(Box::new(WidgetLegacyLiveSpan::new())))
98 .title("".to_string())
99 .title_align(WidgetTextAlign::LEFT)
100 .title_size("16".to_string()),
101 ),
102 ),
103 ).layout(WidgetLayout::new(32, 54, 0, 0))
104 ],
105 )
106 .description(Some("".to_string()))
107 .notify_list(Some(vec![]))
108 .template_variables(Some(vec![]));
109 let configuration = datadog::Configuration::new();
110 let api = DashboardsAPI::with_config(configuration);
111 let resp = api.create_dashboard(body).await;
112 if let Ok(value) = resp {
113 println!("{:#?}", value);
114 } else {
115 println!("{:#?}", resp.unwrap_err());
116 }
117}
28async fn main() {
29 let body =
30 Dashboard::new(
31 DashboardLayoutType::FREE,
32 "Example-Dashboard".to_string(),
33 vec![
34 Widget::new(
35 WidgetDefinition::TableWidgetDefinition(
36 Box::new(
37 TableWidgetDefinition::new(
38 vec![
39 TableWidgetRequest::new()
40 .formulas(vec![])
41 .queries(
42 vec![
43 FormulaAndFunctionQueryDefinition
44 ::FormulaAndFunctionMetricQueryDefinition(
45 Box::new(
46 FormulaAndFunctionMetricQueryDefinition::new(
47 FormulaAndFunctionMetricDataSource::METRICS,
48 "query1".to_string(),
49 "avg:aws.stream.globalaccelerator.processed_bytes_in{*} by {aws_account,acceleratoripaddress}".to_string(),
50 ).aggregator(FormulaAndFunctionMetricAggregation::AVG),
51 ),
52 ),
53 FormulaAndFunctionQueryDefinition
54 ::FormulaAndFunctionMetricQueryDefinition(
55 Box::new(
56 FormulaAndFunctionMetricQueryDefinition::new(
57 FormulaAndFunctionMetricDataSource::METRICS,
58 "query2".to_string(),
59 "avg:aws.stream.globalaccelerator.processed_bytes_out{*} by {aws_account,acceleratoripaddress}".to_string(),
60 ).aggregator(FormulaAndFunctionMetricAggregation::AVG),
61 ),
62 )
63 ],
64 )
65 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
66 .text_formats(
67 vec![
68 vec![
69 TableWidgetTextFormatRule::new(
70 TableWidgetTextFormatMatch::new(
71 TableWidgetTextFormatMatchType::IS,
72 "fruit".to_string(),
73 ),
74 )
75 .palette(TableWidgetTextFormatPalette::WHITE_ON_RED)
76 .replace(
77 TableWidgetTextFormatReplace
78 ::TableWidgetTextFormatReplaceAll(
79 Box::new(
80 TableWidgetTextFormatReplaceAll::new(
81 TableWidgetTextFormatReplaceAllType::ALL,
82 "vegetable".to_string(),
83 ),
84 ),
85 ),
86 ),
87 TableWidgetTextFormatRule::new(
88 TableWidgetTextFormatMatch::new(
89 TableWidgetTextFormatMatchType::IS,
90 "animal".to_string(),
91 ),
92 )
93 .custom_bg_color("#632ca6".to_string())
94 .palette(TableWidgetTextFormatPalette::CUSTOM_BG),
95 TableWidgetTextFormatRule::new(
96 TableWidgetTextFormatMatch::new(
97 TableWidgetTextFormatMatchType::IS,
98 "robot".to_string(),
99 ),
100 ).palette(TableWidgetTextFormatPalette::RED_ON_WHITE),
101 TableWidgetTextFormatRule::new(
102 TableWidgetTextFormatMatch::new(
103 TableWidgetTextFormatMatchType::IS,
104 "ai".to_string(),
105 ),
106 ).palette(TableWidgetTextFormatPalette::YELLOW_ON_WHITE)
107 ],
108 vec![
109 TableWidgetTextFormatRule::new(
110 TableWidgetTextFormatMatch::new(
111 TableWidgetTextFormatMatchType::IS_NOT,
112 "xyz".to_string(),
113 ),
114 ).palette(TableWidgetTextFormatPalette::WHITE_ON_YELLOW)
115 ],
116 vec![
117 TableWidgetTextFormatRule::new(
118 TableWidgetTextFormatMatch::new(
119 TableWidgetTextFormatMatchType::CONTAINS,
120 "test".to_string(),
121 ),
122 )
123 .palette(TableWidgetTextFormatPalette::WHITE_ON_GREEN)
124 .replace(
125 TableWidgetTextFormatReplace
126 ::TableWidgetTextFormatReplaceAll(
127 Box::new(
128 TableWidgetTextFormatReplaceAll::new(
129 TableWidgetTextFormatReplaceAllType::ALL,
130 "vegetable".to_string(),
131 ),
132 ),
133 ),
134 )
135 ],
136 vec![
137 TableWidgetTextFormatRule::new(
138 TableWidgetTextFormatMatch::new(
139 TableWidgetTextFormatMatchType::DOES_NOT_CONTAIN,
140 "blah".to_string(),
141 ),
142 ).palette(TableWidgetTextFormatPalette::BLACK_ON_LIGHT_RED)
143 ],
144 vec![
145 TableWidgetTextFormatRule::new(
146 TableWidgetTextFormatMatch::new(
147 TableWidgetTextFormatMatchType::STARTS_WITH,
148 "abc".to_string(),
149 ),
150 ).palette(TableWidgetTextFormatPalette::BLACK_ON_LIGHT_YELLOW)
151 ],
152 vec![
153 TableWidgetTextFormatRule::new(
154 TableWidgetTextFormatMatch::new(
155 TableWidgetTextFormatMatchType::ENDS_WITH,
156 "xyz".to_string(),
157 ),
158 ).palette(TableWidgetTextFormatPalette::BLACK_ON_LIGHT_GREEN),
159 TableWidgetTextFormatRule::new(
160 TableWidgetTextFormatMatch::new(
161 TableWidgetTextFormatMatchType::ENDS_WITH,
162 "zzz".to_string(),
163 ),
164 ).palette(TableWidgetTextFormatPalette::GREEN_ON_WHITE),
165 TableWidgetTextFormatRule::new(
166 TableWidgetTextFormatMatch::new(
167 TableWidgetTextFormatMatchType::IS,
168 "animal".to_string(),
169 ),
170 )
171 .custom_fg_color("#632ca6".to_string())
172 .palette(TableWidgetTextFormatPalette::CUSTOM_TEXT)
173 ]
174 ],
175 )
176 ],
177 TableWidgetDefinitionType::QUERY_TABLE,
178 )
179 .has_search_bar(TableWidgetHasSearchBar::NEVER)
180 .title("".to_string())
181 .title_align(WidgetTextAlign::LEFT)
182 .title_size("16".to_string()),
183 ),
184 ),
185 ).layout(WidgetLayout::new(4, 4, 0, 0))
186 ],
187 )
188 .description(Some("".to_string()))
189 .notify_list(Some(vec![]))
190 .template_variables(Some(vec![]));
191 let configuration = datadog::Configuration::new();
192 let api = DashboardsAPI::with_config(configuration);
193 let resp = api.create_dashboard(body).await;
194 if let Ok(value) = resp {
195 println!("{:#?}", value);
196 } else {
197 println!("{:#?}", resp.unwrap_err());
198 }
199}
Sourcepub fn response_format(self, value: FormulaAndFunctionResponseFormat) -> Self
pub fn response_format(self, value: FormulaAndFunctionResponseFormat) -> Self
Examples found in repository?
27async fn main() {
28 let body = Dashboard::new(
29 DashboardLayoutType::ORDERED,
30 "Example-Dashboard with query table widget and storage parameter".to_string(),
31 vec![Widget::new(WidgetDefinition::TableWidgetDefinition(
32 Box::new(TableWidgetDefinition::new(
33 vec![TableWidgetRequest::new()
34 .formulas(vec![WidgetFormula::new("query1".to_string())
35 .cell_display_mode(TableWidgetCellDisplayMode::BAR)
36 .conditional_formats(vec![])])
37 .queries(vec![
38 FormulaAndFunctionQueryDefinition::FormulaAndFunctionEventQueryDefinition(
39 Box::new(
40 FormulaAndFunctionEventQueryDefinition::new(
41 FormulaAndFunctionEventQueryDefinitionCompute::new(
42 FormulaAndFunctionEventAggregation::COUNT,
43 ),
44 FormulaAndFunctionEventsDataSource::LOGS,
45 "query1".to_string(),
46 )
47 .group_by(vec![])
48 .indexes(vec!["*".to_string()])
49 .search(FormulaAndFunctionEventQueryDefinitionSearch::new(
50 "".to_string(),
51 ))
52 .storage("online_archives".to_string()),
53 ),
54 ),
55 ])
56 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
57 .sort(WidgetSortBy::new().count(50).order_by(vec![
58 WidgetSortOrderBy::WidgetFormulaSort(Box::new(WidgetFormulaSort::new(
59 0,
60 WidgetSort::DESCENDING,
61 FormulaType::FORMULA,
62 ))),
63 ]))],
64 TableWidgetDefinitionType::QUERY_TABLE,
65 )),
66 ))],
67 );
68 let configuration = datadog::Configuration::new();
69 let api = DashboardsAPI::with_config(configuration);
70 let resp = api.create_dashboard(body).await;
71 if let Ok(value) = resp {
72 println!("{:#?}", value);
73 } else {
74 println!("{:#?}", resp.unwrap_err());
75 }
76}
More examples
20async fn main() {
21 let body =
22 Dashboard::new(
23 DashboardLayoutType::ORDERED,
24 "Example-Dashboard".to_string(),
25 vec![
26 Widget::new(
27 WidgetDefinition::TableWidgetDefinition(
28 Box::new(
29 TableWidgetDefinition::new(
30 vec![
31 TableWidgetRequest::new()
32 .queries(
33 vec![
34 FormulaAndFunctionQueryDefinition
35 ::FormulaAndFunctionApmResourceStatsQueryDefinition(
36 Box::new(
37 FormulaAndFunctionApmResourceStatsQueryDefinition::new(
38 FormulaAndFunctionApmResourceStatsDataSource
39 ::APM_RESOURCE_STATS,
40 "ci".to_string(),
41 "query1".to_string(),
42 "cassandra".to_string(),
43 FormulaAndFunctionApmResourceStatName::HITS,
44 )
45 .group_by(vec!["resource_name".to_string()])
46 .operation_name("cassandra.query".to_string())
47 .primary_tag_name("datacenter".to_string())
48 .primary_tag_value("edge-eu1.prod.dog".to_string()),
49 ),
50 )
51 ],
52 )
53 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
54 ],
55 TableWidgetDefinitionType::QUERY_TABLE,
56 )
57 .title("".to_string())
58 .title_align(WidgetTextAlign::LEFT)
59 .title_size("16".to_string()),
60 ),
61 ),
62 ).layout(WidgetLayout::new(4, 4, 0, 0))
63 ],
64 );
65 let configuration = datadog::Configuration::new();
66 let api = DashboardsAPI::with_config(configuration);
67 let resp = api.create_dashboard(body).await;
68 if let Ok(value) = resp {
69 println!("{:#?}", value);
70 } else {
71 println!("{:#?}", resp.unwrap_err());
72 }
73}
20async fn main() {
21 let body =
22 Dashboard::new(
23 DashboardLayoutType::ORDERED,
24 "Example-Dashboard".to_string(),
25 vec![
26 Widget::new(
27 WidgetDefinition::TableWidgetDefinition(
28 Box::new(
29 TableWidgetDefinition::new(
30 vec![
31 TableWidgetRequest::new()
32 .queries(
33 vec![
34 FormulaAndFunctionQueryDefinition
35 ::FormulaAndFunctionApmDependencyStatsQueryDefinition(
36 Box::new(
37 FormulaAndFunctionApmDependencyStatsQueryDefinition::new(
38 FormulaAndFunctionApmDependencyStatsDataSource
39 ::APM_DEPENDENCY_STATS,
40 "ci".to_string(),
41 "query1".to_string(),
42 "cassandra.query".to_string(),
43 "DELETE FROM monitor_history.monitor_state_change_history WHERE org_id = ? AND monitor_id IN ? AND group = ?".to_string(),
44 "cassandra".to_string(),
45 FormulaAndFunctionApmDependencyStatName::AVG_DURATION,
46 )
47 .primary_tag_name("datacenter".to_string())
48 .primary_tag_value("edge-eu1.prod.dog".to_string()),
49 ),
50 )
51 ],
52 )
53 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
54 ],
55 TableWidgetDefinitionType::QUERY_TABLE,
56 )
57 .title("".to_string())
58 .title_align(WidgetTextAlign::LEFT)
59 .title_size("16".to_string()),
60 ),
61 ),
62 ).layout(WidgetLayout::new(4, 4, 0, 0))
63 ],
64 );
65 let configuration = datadog::Configuration::new();
66 let api = DashboardsAPI::with_config(configuration);
67 let resp = api.create_dashboard(body).await;
68 if let Ok(value) = resp {
69 println!("{:#?}", value);
70 } else {
71 println!("{:#?}", resp.unwrap_err());
72 }
73}
30async fn main() {
31 let body =
32 Dashboard::new(
33 DashboardLayoutType::FREE,
34 "Example-Dashboard".to_string(),
35 vec![
36 Widget::new(
37 WidgetDefinition::TableWidgetDefinition(
38 Box::new(
39 TableWidgetDefinition::new(
40 vec![
41 TableWidgetRequest::new()
42 .formulas(
43 vec![
44 WidgetFormula::new("query1".to_string())
45 .cell_display_mode(TableWidgetCellDisplayMode::BAR)
46 .conditional_formats(vec![])
47 ],
48 )
49 .queries(
50 vec![
51 FormulaAndFunctionQueryDefinition
52 ::FormulaAndFunctionMetricQueryDefinition(
53 Box::new(
54 FormulaAndFunctionMetricQueryDefinition::new(
55 FormulaAndFunctionMetricDataSource::METRICS,
56 "query1".to_string(),
57 "avg:system.cpu.user{*} by {host}".to_string(),
58 ).aggregator(FormulaAndFunctionMetricAggregation::AVG),
59 ),
60 )
61 ],
62 )
63 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
64 .sort(
65 WidgetSortBy::new()
66 .count(500)
67 .order_by(
68 vec![
69 WidgetSortOrderBy::WidgetFormulaSort(
70 Box::new(
71 WidgetFormulaSort::new(
72 0,
73 WidgetSort::DESCENDING,
74 FormulaType::FORMULA,
75 ),
76 ),
77 )
78 ],
79 ),
80 )
81 ],
82 TableWidgetDefinitionType::QUERY_TABLE,
83 )
84 .has_search_bar(TableWidgetHasSearchBar::AUTO)
85 .time(WidgetTime::WidgetLegacyLiveSpan(Box::new(WidgetLegacyLiveSpan::new())))
86 .title("".to_string())
87 .title_align(WidgetTextAlign::LEFT)
88 .title_size("16".to_string()),
89 ),
90 ),
91 ).layout(WidgetLayout::new(32, 54, 0, 0))
92 ],
93 )
94 .description(Some("".to_string()))
95 .notify_list(Some(vec![]))
96 .template_variables(Some(vec![]));
97 let configuration = datadog::Configuration::new();
98 let api = DashboardsAPI::with_config(configuration);
99 let resp = api.create_dashboard(body).await;
100 if let Ok(value) = resp {
101 println!("{:#?}", value);
102 } else {
103 println!("{:#?}", resp.unwrap_err());
104 }
105}
33async fn main() {
34 let body =
35 Dashboard::new(
36 DashboardLayoutType::FREE,
37 "Example-Dashboard".to_string(),
38 vec![
39 Widget::new(
40 WidgetDefinition::TableWidgetDefinition(
41 Box::new(
42 TableWidgetDefinition::new(
43 vec![
44 TableWidgetRequest::new()
45 .formulas(
46 vec![
47 WidgetFormula::new("query1".to_string())
48 .cell_display_mode(TableWidgetCellDisplayMode::TREND)
49 .cell_display_mode_options(
50 WidgetFormulaCellDisplayModeOptions::new()
51 .trend_type(
52 WidgetFormulaCellDisplayModeOptionsTrendType::LINE,
53 )
54 .y_scale(
55 WidgetFormulaCellDisplayModeOptionsYScale::SHARED,
56 ),
57 )
58 .conditional_formats(vec![])
59 ],
60 )
61 .queries(
62 vec![
63 FormulaAndFunctionQueryDefinition
64 ::FormulaAndFunctionMetricQueryDefinition(
65 Box::new(
66 FormulaAndFunctionMetricQueryDefinition::new(
67 FormulaAndFunctionMetricDataSource::METRICS,
68 "query1".to_string(),
69 "avg:system.cpu.user{*} by {host}".to_string(),
70 ).aggregator(FormulaAndFunctionMetricAggregation::AVG),
71 ),
72 )
73 ],
74 )
75 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
76 .sort(
77 WidgetSortBy::new()
78 .count(500)
79 .order_by(
80 vec![
81 WidgetSortOrderBy::WidgetFormulaSort(
82 Box::new(
83 WidgetFormulaSort::new(
84 0,
85 WidgetSort::DESCENDING,
86 FormulaType::FORMULA,
87 ),
88 ),
89 )
90 ],
91 ),
92 )
93 ],
94 TableWidgetDefinitionType::QUERY_TABLE,
95 )
96 .has_search_bar(TableWidgetHasSearchBar::AUTO)
97 .time(WidgetTime::WidgetLegacyLiveSpan(Box::new(WidgetLegacyLiveSpan::new())))
98 .title("".to_string())
99 .title_align(WidgetTextAlign::LEFT)
100 .title_size("16".to_string()),
101 ),
102 ),
103 ).layout(WidgetLayout::new(32, 54, 0, 0))
104 ],
105 )
106 .description(Some("".to_string()))
107 .notify_list(Some(vec![]))
108 .template_variables(Some(vec![]));
109 let configuration = datadog::Configuration::new();
110 let api = DashboardsAPI::with_config(configuration);
111 let resp = api.create_dashboard(body).await;
112 if let Ok(value) = resp {
113 println!("{:#?}", value);
114 } else {
115 println!("{:#?}", resp.unwrap_err());
116 }
117}
28async fn main() {
29 let body =
30 Dashboard::new(
31 DashboardLayoutType::FREE,
32 "Example-Dashboard".to_string(),
33 vec![
34 Widget::new(
35 WidgetDefinition::TableWidgetDefinition(
36 Box::new(
37 TableWidgetDefinition::new(
38 vec![
39 TableWidgetRequest::new()
40 .formulas(vec![])
41 .queries(
42 vec![
43 FormulaAndFunctionQueryDefinition
44 ::FormulaAndFunctionMetricQueryDefinition(
45 Box::new(
46 FormulaAndFunctionMetricQueryDefinition::new(
47 FormulaAndFunctionMetricDataSource::METRICS,
48 "query1".to_string(),
49 "avg:aws.stream.globalaccelerator.processed_bytes_in{*} by {aws_account,acceleratoripaddress}".to_string(),
50 ).aggregator(FormulaAndFunctionMetricAggregation::AVG),
51 ),
52 ),
53 FormulaAndFunctionQueryDefinition
54 ::FormulaAndFunctionMetricQueryDefinition(
55 Box::new(
56 FormulaAndFunctionMetricQueryDefinition::new(
57 FormulaAndFunctionMetricDataSource::METRICS,
58 "query2".to_string(),
59 "avg:aws.stream.globalaccelerator.processed_bytes_out{*} by {aws_account,acceleratoripaddress}".to_string(),
60 ).aggregator(FormulaAndFunctionMetricAggregation::AVG),
61 ),
62 )
63 ],
64 )
65 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
66 .text_formats(
67 vec![
68 vec![
69 TableWidgetTextFormatRule::new(
70 TableWidgetTextFormatMatch::new(
71 TableWidgetTextFormatMatchType::IS,
72 "fruit".to_string(),
73 ),
74 )
75 .palette(TableWidgetTextFormatPalette::WHITE_ON_RED)
76 .replace(
77 TableWidgetTextFormatReplace
78 ::TableWidgetTextFormatReplaceAll(
79 Box::new(
80 TableWidgetTextFormatReplaceAll::new(
81 TableWidgetTextFormatReplaceAllType::ALL,
82 "vegetable".to_string(),
83 ),
84 ),
85 ),
86 ),
87 TableWidgetTextFormatRule::new(
88 TableWidgetTextFormatMatch::new(
89 TableWidgetTextFormatMatchType::IS,
90 "animal".to_string(),
91 ),
92 )
93 .custom_bg_color("#632ca6".to_string())
94 .palette(TableWidgetTextFormatPalette::CUSTOM_BG),
95 TableWidgetTextFormatRule::new(
96 TableWidgetTextFormatMatch::new(
97 TableWidgetTextFormatMatchType::IS,
98 "robot".to_string(),
99 ),
100 ).palette(TableWidgetTextFormatPalette::RED_ON_WHITE),
101 TableWidgetTextFormatRule::new(
102 TableWidgetTextFormatMatch::new(
103 TableWidgetTextFormatMatchType::IS,
104 "ai".to_string(),
105 ),
106 ).palette(TableWidgetTextFormatPalette::YELLOW_ON_WHITE)
107 ],
108 vec![
109 TableWidgetTextFormatRule::new(
110 TableWidgetTextFormatMatch::new(
111 TableWidgetTextFormatMatchType::IS_NOT,
112 "xyz".to_string(),
113 ),
114 ).palette(TableWidgetTextFormatPalette::WHITE_ON_YELLOW)
115 ],
116 vec![
117 TableWidgetTextFormatRule::new(
118 TableWidgetTextFormatMatch::new(
119 TableWidgetTextFormatMatchType::CONTAINS,
120 "test".to_string(),
121 ),
122 )
123 .palette(TableWidgetTextFormatPalette::WHITE_ON_GREEN)
124 .replace(
125 TableWidgetTextFormatReplace
126 ::TableWidgetTextFormatReplaceAll(
127 Box::new(
128 TableWidgetTextFormatReplaceAll::new(
129 TableWidgetTextFormatReplaceAllType::ALL,
130 "vegetable".to_string(),
131 ),
132 ),
133 ),
134 )
135 ],
136 vec![
137 TableWidgetTextFormatRule::new(
138 TableWidgetTextFormatMatch::new(
139 TableWidgetTextFormatMatchType::DOES_NOT_CONTAIN,
140 "blah".to_string(),
141 ),
142 ).palette(TableWidgetTextFormatPalette::BLACK_ON_LIGHT_RED)
143 ],
144 vec![
145 TableWidgetTextFormatRule::new(
146 TableWidgetTextFormatMatch::new(
147 TableWidgetTextFormatMatchType::STARTS_WITH,
148 "abc".to_string(),
149 ),
150 ).palette(TableWidgetTextFormatPalette::BLACK_ON_LIGHT_YELLOW)
151 ],
152 vec![
153 TableWidgetTextFormatRule::new(
154 TableWidgetTextFormatMatch::new(
155 TableWidgetTextFormatMatchType::ENDS_WITH,
156 "xyz".to_string(),
157 ),
158 ).palette(TableWidgetTextFormatPalette::BLACK_ON_LIGHT_GREEN),
159 TableWidgetTextFormatRule::new(
160 TableWidgetTextFormatMatch::new(
161 TableWidgetTextFormatMatchType::ENDS_WITH,
162 "zzz".to_string(),
163 ),
164 ).palette(TableWidgetTextFormatPalette::GREEN_ON_WHITE),
165 TableWidgetTextFormatRule::new(
166 TableWidgetTextFormatMatch::new(
167 TableWidgetTextFormatMatchType::IS,
168 "animal".to_string(),
169 ),
170 )
171 .custom_fg_color("#632ca6".to_string())
172 .palette(TableWidgetTextFormatPalette::CUSTOM_TEXT)
173 ]
174 ],
175 )
176 ],
177 TableWidgetDefinitionType::QUERY_TABLE,
178 )
179 .has_search_bar(TableWidgetHasSearchBar::NEVER)
180 .title("".to_string())
181 .title_align(WidgetTextAlign::LEFT)
182 .title_size("16".to_string()),
183 ),
184 ),
185 ).layout(WidgetLayout::new(4, 4, 0, 0))
186 ],
187 )
188 .description(Some("".to_string()))
189 .notify_list(Some(vec![]))
190 .template_variables(Some(vec![]));
191 let configuration = datadog::Configuration::new();
192 let api = DashboardsAPI::with_config(configuration);
193 let resp = api.create_dashboard(body).await;
194 if let Ok(value) = resp {
195 println!("{:#?}", value);
196 } else {
197 println!("{:#?}", resp.unwrap_err());
198 }
199}
pub fn rum_query(self, value: LogQueryDefinition) -> Self
pub fn security_query(self, value: LogQueryDefinition) -> Self
Sourcepub fn sort(self, value: WidgetSortBy) -> Self
pub fn sort(self, value: WidgetSortBy) -> Self
Examples found in repository?
27async fn main() {
28 let body = Dashboard::new(
29 DashboardLayoutType::ORDERED,
30 "Example-Dashboard with query table widget and storage parameter".to_string(),
31 vec![Widget::new(WidgetDefinition::TableWidgetDefinition(
32 Box::new(TableWidgetDefinition::new(
33 vec![TableWidgetRequest::new()
34 .formulas(vec![WidgetFormula::new("query1".to_string())
35 .cell_display_mode(TableWidgetCellDisplayMode::BAR)
36 .conditional_formats(vec![])])
37 .queries(vec![
38 FormulaAndFunctionQueryDefinition::FormulaAndFunctionEventQueryDefinition(
39 Box::new(
40 FormulaAndFunctionEventQueryDefinition::new(
41 FormulaAndFunctionEventQueryDefinitionCompute::new(
42 FormulaAndFunctionEventAggregation::COUNT,
43 ),
44 FormulaAndFunctionEventsDataSource::LOGS,
45 "query1".to_string(),
46 )
47 .group_by(vec![])
48 .indexes(vec!["*".to_string()])
49 .search(FormulaAndFunctionEventQueryDefinitionSearch::new(
50 "".to_string(),
51 ))
52 .storage("online_archives".to_string()),
53 ),
54 ),
55 ])
56 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
57 .sort(WidgetSortBy::new().count(50).order_by(vec![
58 WidgetSortOrderBy::WidgetFormulaSort(Box::new(WidgetFormulaSort::new(
59 0,
60 WidgetSort::DESCENDING,
61 FormulaType::FORMULA,
62 ))),
63 ]))],
64 TableWidgetDefinitionType::QUERY_TABLE,
65 )),
66 ))],
67 );
68 let configuration = datadog::Configuration::new();
69 let api = DashboardsAPI::with_config(configuration);
70 let resp = api.create_dashboard(body).await;
71 if let Ok(value) = resp {
72 println!("{:#?}", value);
73 } else {
74 println!("{:#?}", resp.unwrap_err());
75 }
76}
More examples
30async fn main() {
31 let body =
32 Dashboard::new(
33 DashboardLayoutType::FREE,
34 "Example-Dashboard".to_string(),
35 vec![
36 Widget::new(
37 WidgetDefinition::TableWidgetDefinition(
38 Box::new(
39 TableWidgetDefinition::new(
40 vec![
41 TableWidgetRequest::new()
42 .formulas(
43 vec![
44 WidgetFormula::new("query1".to_string())
45 .cell_display_mode(TableWidgetCellDisplayMode::BAR)
46 .conditional_formats(vec![])
47 ],
48 )
49 .queries(
50 vec![
51 FormulaAndFunctionQueryDefinition
52 ::FormulaAndFunctionMetricQueryDefinition(
53 Box::new(
54 FormulaAndFunctionMetricQueryDefinition::new(
55 FormulaAndFunctionMetricDataSource::METRICS,
56 "query1".to_string(),
57 "avg:system.cpu.user{*} by {host}".to_string(),
58 ).aggregator(FormulaAndFunctionMetricAggregation::AVG),
59 ),
60 )
61 ],
62 )
63 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
64 .sort(
65 WidgetSortBy::new()
66 .count(500)
67 .order_by(
68 vec![
69 WidgetSortOrderBy::WidgetFormulaSort(
70 Box::new(
71 WidgetFormulaSort::new(
72 0,
73 WidgetSort::DESCENDING,
74 FormulaType::FORMULA,
75 ),
76 ),
77 )
78 ],
79 ),
80 )
81 ],
82 TableWidgetDefinitionType::QUERY_TABLE,
83 )
84 .has_search_bar(TableWidgetHasSearchBar::AUTO)
85 .time(WidgetTime::WidgetLegacyLiveSpan(Box::new(WidgetLegacyLiveSpan::new())))
86 .title("".to_string())
87 .title_align(WidgetTextAlign::LEFT)
88 .title_size("16".to_string()),
89 ),
90 ),
91 ).layout(WidgetLayout::new(32, 54, 0, 0))
92 ],
93 )
94 .description(Some("".to_string()))
95 .notify_list(Some(vec![]))
96 .template_variables(Some(vec![]));
97 let configuration = datadog::Configuration::new();
98 let api = DashboardsAPI::with_config(configuration);
99 let resp = api.create_dashboard(body).await;
100 if let Ok(value) = resp {
101 println!("{:#?}", value);
102 } else {
103 println!("{:#?}", resp.unwrap_err());
104 }
105}
33async fn main() {
34 let body =
35 Dashboard::new(
36 DashboardLayoutType::FREE,
37 "Example-Dashboard".to_string(),
38 vec![
39 Widget::new(
40 WidgetDefinition::TableWidgetDefinition(
41 Box::new(
42 TableWidgetDefinition::new(
43 vec![
44 TableWidgetRequest::new()
45 .formulas(
46 vec![
47 WidgetFormula::new("query1".to_string())
48 .cell_display_mode(TableWidgetCellDisplayMode::TREND)
49 .cell_display_mode_options(
50 WidgetFormulaCellDisplayModeOptions::new()
51 .trend_type(
52 WidgetFormulaCellDisplayModeOptionsTrendType::LINE,
53 )
54 .y_scale(
55 WidgetFormulaCellDisplayModeOptionsYScale::SHARED,
56 ),
57 )
58 .conditional_formats(vec![])
59 ],
60 )
61 .queries(
62 vec![
63 FormulaAndFunctionQueryDefinition
64 ::FormulaAndFunctionMetricQueryDefinition(
65 Box::new(
66 FormulaAndFunctionMetricQueryDefinition::new(
67 FormulaAndFunctionMetricDataSource::METRICS,
68 "query1".to_string(),
69 "avg:system.cpu.user{*} by {host}".to_string(),
70 ).aggregator(FormulaAndFunctionMetricAggregation::AVG),
71 ),
72 )
73 ],
74 )
75 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
76 .sort(
77 WidgetSortBy::new()
78 .count(500)
79 .order_by(
80 vec![
81 WidgetSortOrderBy::WidgetFormulaSort(
82 Box::new(
83 WidgetFormulaSort::new(
84 0,
85 WidgetSort::DESCENDING,
86 FormulaType::FORMULA,
87 ),
88 ),
89 )
90 ],
91 ),
92 )
93 ],
94 TableWidgetDefinitionType::QUERY_TABLE,
95 )
96 .has_search_bar(TableWidgetHasSearchBar::AUTO)
97 .time(WidgetTime::WidgetLegacyLiveSpan(Box::new(WidgetLegacyLiveSpan::new())))
98 .title("".to_string())
99 .title_align(WidgetTextAlign::LEFT)
100 .title_size("16".to_string()),
101 ),
102 ),
103 ).layout(WidgetLayout::new(32, 54, 0, 0))
104 ],
105 )
106 .description(Some("".to_string()))
107 .notify_list(Some(vec![]))
108 .template_variables(Some(vec![]));
109 let configuration = datadog::Configuration::new();
110 let api = DashboardsAPI::with_config(configuration);
111 let resp = api.create_dashboard(body).await;
112 if let Ok(value) = resp {
113 println!("{:#?}", value);
114 } else {
115 println!("{:#?}", resp.unwrap_err());
116 }
117}
Sourcepub fn text_formats(self, value: Vec<Vec<TableWidgetTextFormatRule>>) -> Self
pub fn text_formats(self, value: Vec<Vec<TableWidgetTextFormatRule>>) -> Self
Examples found in repository?
28async fn main() {
29 let body =
30 Dashboard::new(
31 DashboardLayoutType::FREE,
32 "Example-Dashboard".to_string(),
33 vec![
34 Widget::new(
35 WidgetDefinition::TableWidgetDefinition(
36 Box::new(
37 TableWidgetDefinition::new(
38 vec![
39 TableWidgetRequest::new()
40 .formulas(vec![])
41 .queries(
42 vec![
43 FormulaAndFunctionQueryDefinition
44 ::FormulaAndFunctionMetricQueryDefinition(
45 Box::new(
46 FormulaAndFunctionMetricQueryDefinition::new(
47 FormulaAndFunctionMetricDataSource::METRICS,
48 "query1".to_string(),
49 "avg:aws.stream.globalaccelerator.processed_bytes_in{*} by {aws_account,acceleratoripaddress}".to_string(),
50 ).aggregator(FormulaAndFunctionMetricAggregation::AVG),
51 ),
52 ),
53 FormulaAndFunctionQueryDefinition
54 ::FormulaAndFunctionMetricQueryDefinition(
55 Box::new(
56 FormulaAndFunctionMetricQueryDefinition::new(
57 FormulaAndFunctionMetricDataSource::METRICS,
58 "query2".to_string(),
59 "avg:aws.stream.globalaccelerator.processed_bytes_out{*} by {aws_account,acceleratoripaddress}".to_string(),
60 ).aggregator(FormulaAndFunctionMetricAggregation::AVG),
61 ),
62 )
63 ],
64 )
65 .response_format(FormulaAndFunctionResponseFormat::SCALAR)
66 .text_formats(
67 vec![
68 vec![
69 TableWidgetTextFormatRule::new(
70 TableWidgetTextFormatMatch::new(
71 TableWidgetTextFormatMatchType::IS,
72 "fruit".to_string(),
73 ),
74 )
75 .palette(TableWidgetTextFormatPalette::WHITE_ON_RED)
76 .replace(
77 TableWidgetTextFormatReplace
78 ::TableWidgetTextFormatReplaceAll(
79 Box::new(
80 TableWidgetTextFormatReplaceAll::new(
81 TableWidgetTextFormatReplaceAllType::ALL,
82 "vegetable".to_string(),
83 ),
84 ),
85 ),
86 ),
87 TableWidgetTextFormatRule::new(
88 TableWidgetTextFormatMatch::new(
89 TableWidgetTextFormatMatchType::IS,
90 "animal".to_string(),
91 ),
92 )
93 .custom_bg_color("#632ca6".to_string())
94 .palette(TableWidgetTextFormatPalette::CUSTOM_BG),
95 TableWidgetTextFormatRule::new(
96 TableWidgetTextFormatMatch::new(
97 TableWidgetTextFormatMatchType::IS,
98 "robot".to_string(),
99 ),
100 ).palette(TableWidgetTextFormatPalette::RED_ON_WHITE),
101 TableWidgetTextFormatRule::new(
102 TableWidgetTextFormatMatch::new(
103 TableWidgetTextFormatMatchType::IS,
104 "ai".to_string(),
105 ),
106 ).palette(TableWidgetTextFormatPalette::YELLOW_ON_WHITE)
107 ],
108 vec![
109 TableWidgetTextFormatRule::new(
110 TableWidgetTextFormatMatch::new(
111 TableWidgetTextFormatMatchType::IS_NOT,
112 "xyz".to_string(),
113 ),
114 ).palette(TableWidgetTextFormatPalette::WHITE_ON_YELLOW)
115 ],
116 vec![
117 TableWidgetTextFormatRule::new(
118 TableWidgetTextFormatMatch::new(
119 TableWidgetTextFormatMatchType::CONTAINS,
120 "test".to_string(),
121 ),
122 )
123 .palette(TableWidgetTextFormatPalette::WHITE_ON_GREEN)
124 .replace(
125 TableWidgetTextFormatReplace
126 ::TableWidgetTextFormatReplaceAll(
127 Box::new(
128 TableWidgetTextFormatReplaceAll::new(
129 TableWidgetTextFormatReplaceAllType::ALL,
130 "vegetable".to_string(),
131 ),
132 ),
133 ),
134 )
135 ],
136 vec![
137 TableWidgetTextFormatRule::new(
138 TableWidgetTextFormatMatch::new(
139 TableWidgetTextFormatMatchType::DOES_NOT_CONTAIN,
140 "blah".to_string(),
141 ),
142 ).palette(TableWidgetTextFormatPalette::BLACK_ON_LIGHT_RED)
143 ],
144 vec![
145 TableWidgetTextFormatRule::new(
146 TableWidgetTextFormatMatch::new(
147 TableWidgetTextFormatMatchType::STARTS_WITH,
148 "abc".to_string(),
149 ),
150 ).palette(TableWidgetTextFormatPalette::BLACK_ON_LIGHT_YELLOW)
151 ],
152 vec![
153 TableWidgetTextFormatRule::new(
154 TableWidgetTextFormatMatch::new(
155 TableWidgetTextFormatMatchType::ENDS_WITH,
156 "xyz".to_string(),
157 ),
158 ).palette(TableWidgetTextFormatPalette::BLACK_ON_LIGHT_GREEN),
159 TableWidgetTextFormatRule::new(
160 TableWidgetTextFormatMatch::new(
161 TableWidgetTextFormatMatchType::ENDS_WITH,
162 "zzz".to_string(),
163 ),
164 ).palette(TableWidgetTextFormatPalette::GREEN_ON_WHITE),
165 TableWidgetTextFormatRule::new(
166 TableWidgetTextFormatMatch::new(
167 TableWidgetTextFormatMatchType::IS,
168 "animal".to_string(),
169 ),
170 )
171 .custom_fg_color("#632ca6".to_string())
172 .palette(TableWidgetTextFormatPalette::CUSTOM_TEXT)
173 ]
174 ],
175 )
176 ],
177 TableWidgetDefinitionType::QUERY_TABLE,
178 )
179 .has_search_bar(TableWidgetHasSearchBar::NEVER)
180 .title("".to_string())
181 .title_align(WidgetTextAlign::LEFT)
182 .title_size("16".to_string()),
183 ),
184 ),
185 ).layout(WidgetLayout::new(4, 4, 0, 0))
186 ],
187 )
188 .description(Some("".to_string()))
189 .notify_list(Some(vec![]))
190 .template_variables(Some(vec![]));
191 let configuration = datadog::Configuration::new();
192 let api = DashboardsAPI::with_config(configuration);
193 let resp = api.create_dashboard(body).await;
194 if let Ok(value) = resp {
195 println!("{:#?}", value);
196 } else {
197 println!("{:#?}", resp.unwrap_err());
198 }
199}
pub fn additional_properties(self, value: BTreeMap<String, Value>) -> Self
Trait Implementations§
Source§impl Clone for TableWidgetRequest
impl Clone for TableWidgetRequest
Source§fn clone(&self) -> TableWidgetRequest
fn clone(&self) -> TableWidgetRequest
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more