|
| 1 | +// Create a new dashboard with llm_observability_stream list_stream widget |
| 2 | +use datadog_api_client::datadog; |
| 3 | +use datadog_api_client::datadogV1::api_dashboards::DashboardsAPI; |
| 4 | +use datadog_api_client::datadogV1::model::Dashboard; |
| 5 | +use datadog_api_client::datadogV1::model::DashboardLayoutType; |
| 6 | +use datadog_api_client::datadogV1::model::ListStreamColumn; |
| 7 | +use datadog_api_client::datadogV1::model::ListStreamColumnWidth; |
| 8 | +use datadog_api_client::datadogV1::model::ListStreamQuery; |
| 9 | +use datadog_api_client::datadogV1::model::ListStreamResponseFormat; |
| 10 | +use datadog_api_client::datadogV1::model::ListStreamSource; |
| 11 | +use datadog_api_client::datadogV1::model::ListStreamWidgetDefinition; |
| 12 | +use datadog_api_client::datadogV1::model::ListStreamWidgetDefinitionType; |
| 13 | +use datadog_api_client::datadogV1::model::ListStreamWidgetRequest; |
| 14 | +use datadog_api_client::datadogV1::model::Widget; |
| 15 | +use datadog_api_client::datadogV1::model::WidgetDefinition; |
| 16 | + |
| 17 | +#[tokio::main] |
| 18 | +async fn main() { |
| 19 | + let body = Dashboard::new( |
| 20 | + DashboardLayoutType::ORDERED, |
| 21 | + "Example-Dashboard with list_stream widget".to_string(), |
| 22 | + vec![Widget::new(WidgetDefinition::ListStreamWidgetDefinition( |
| 23 | + Box::new(ListStreamWidgetDefinition::new( |
| 24 | + vec![ListStreamWidgetRequest::new( |
| 25 | + vec![ |
| 26 | + ListStreamColumn::new( |
| 27 | + "@status".to_string(), |
| 28 | + ListStreamColumnWidth::COMPACT, |
| 29 | + ), |
| 30 | + ListStreamColumn::new( |
| 31 | + "@content.prompt".to_string(), |
| 32 | + ListStreamColumnWidth::AUTO, |
| 33 | + ), |
| 34 | + ListStreamColumn::new( |
| 35 | + "@content.response.content".to_string(), |
| 36 | + ListStreamColumnWidth::AUTO, |
| 37 | + ), |
| 38 | + ListStreamColumn::new("timestamp".to_string(), ListStreamColumnWidth::AUTO), |
| 39 | + ListStreamColumn::new("@ml_app".to_string(), ListStreamColumnWidth::AUTO), |
| 40 | + ListStreamColumn::new("service".to_string(), ListStreamColumnWidth::AUTO), |
| 41 | + ListStreamColumn::new( |
| 42 | + "@meta.evaluations.quality".to_string(), |
| 43 | + ListStreamColumnWidth::AUTO, |
| 44 | + ), |
| 45 | + ListStreamColumn::new( |
| 46 | + "@meta.evaluations.security".to_string(), |
| 47 | + ListStreamColumnWidth::AUTO, |
| 48 | + ), |
| 49 | + ListStreamColumn::new("@duration".to_string(), ListStreamColumnWidth::AUTO), |
| 50 | + ], |
| 51 | + ListStreamQuery::new( |
| 52 | + ListStreamSource::LLM_OBSERVABILITY_STREAM, |
| 53 | + "@event_type:span @parent_id:undefined".to_string(), |
| 54 | + ) |
| 55 | + .indexes(vec![]), |
| 56 | + ListStreamResponseFormat::EVENT_LIST, |
| 57 | + )], |
| 58 | + ListStreamWidgetDefinitionType::LIST_STREAM, |
| 59 | + )), |
| 60 | + ))], |
| 61 | + ); |
| 62 | + let configuration = datadog::Configuration::new(); |
| 63 | + let api = DashboardsAPI::with_config(configuration); |
| 64 | + let resp = api.create_dashboard(body).await; |
| 65 | + if let Ok(value) = resp { |
| 66 | + println!("{:#?}", value); |
| 67 | + } else { |
| 68 | + println!("{:#?}", resp.unwrap_err()); |
| 69 | + } |
| 70 | +} |
0 commit comments