|
| 1 | +// Create a new dashboard with llm_observability_stream list_stream widget |
| 2 | + |
| 3 | +import com.datadog.api.client.ApiClient; |
| 4 | +import com.datadog.api.client.ApiException; |
| 5 | +import com.datadog.api.client.v1.api.DashboardsApi; |
| 6 | +import com.datadog.api.client.v1.model.Dashboard; |
| 7 | +import com.datadog.api.client.v1.model.DashboardLayoutType; |
| 8 | +import com.datadog.api.client.v1.model.ListStreamColumn; |
| 9 | +import com.datadog.api.client.v1.model.ListStreamColumnWidth; |
| 10 | +import com.datadog.api.client.v1.model.ListStreamQuery; |
| 11 | +import com.datadog.api.client.v1.model.ListStreamResponseFormat; |
| 12 | +import com.datadog.api.client.v1.model.ListStreamSource; |
| 13 | +import com.datadog.api.client.v1.model.ListStreamWidgetDefinition; |
| 14 | +import com.datadog.api.client.v1.model.ListStreamWidgetDefinitionType; |
| 15 | +import com.datadog.api.client.v1.model.ListStreamWidgetRequest; |
| 16 | +import com.datadog.api.client.v1.model.Widget; |
| 17 | +import com.datadog.api.client.v1.model.WidgetDefinition; |
| 18 | +import java.util.Arrays; |
| 19 | +import java.util.Collections; |
| 20 | + |
| 21 | +public class Example { |
| 22 | + public static void main(String[] args) { |
| 23 | + ApiClient defaultClient = ApiClient.getDefaultApiClient(); |
| 24 | + DashboardsApi apiInstance = new DashboardsApi(defaultClient); |
| 25 | + |
| 26 | + Dashboard body = |
| 27 | + new Dashboard() |
| 28 | + .layoutType(DashboardLayoutType.ORDERED) |
| 29 | + .title("Example-Dashboard with list_stream widget") |
| 30 | + .widgets( |
| 31 | + Collections.singletonList( |
| 32 | + new Widget() |
| 33 | + .definition( |
| 34 | + new WidgetDefinition( |
| 35 | + new ListStreamWidgetDefinition() |
| 36 | + .type(ListStreamWidgetDefinitionType.LIST_STREAM) |
| 37 | + .requests( |
| 38 | + Collections.singletonList( |
| 39 | + new ListStreamWidgetRequest() |
| 40 | + .responseFormat(ListStreamResponseFormat.EVENT_LIST) |
| 41 | + .query( |
| 42 | + new ListStreamQuery() |
| 43 | + .dataSource( |
| 44 | + ListStreamSource |
| 45 | + .LLM_OBSERVABILITY_STREAM) |
| 46 | + .queryString( |
| 47 | + "@event_type:span" |
| 48 | + + " @parent_id:undefined")) |
| 49 | + .columns( |
| 50 | + Arrays.asList( |
| 51 | + new ListStreamColumn() |
| 52 | + .field("@status") |
| 53 | + .width(ListStreamColumnWidth.COMPACT), |
| 54 | + new ListStreamColumn() |
| 55 | + .field("@content.prompt") |
| 56 | + .width(ListStreamColumnWidth.AUTO), |
| 57 | + new ListStreamColumn() |
| 58 | + .field("@content.response.content") |
| 59 | + .width(ListStreamColumnWidth.AUTO), |
| 60 | + new ListStreamColumn() |
| 61 | + .field("timestamp") |
| 62 | + .width(ListStreamColumnWidth.AUTO), |
| 63 | + new ListStreamColumn() |
| 64 | + .field("@ml_app") |
| 65 | + .width(ListStreamColumnWidth.AUTO), |
| 66 | + new ListStreamColumn() |
| 67 | + .field("service") |
| 68 | + .width(ListStreamColumnWidth.AUTO), |
| 69 | + new ListStreamColumn() |
| 70 | + .field("@meta.evaluations.quality") |
| 71 | + .width(ListStreamColumnWidth.AUTO), |
| 72 | + new ListStreamColumn() |
| 73 | + .field("@meta.evaluations.security") |
| 74 | + .width(ListStreamColumnWidth.AUTO), |
| 75 | + new ListStreamColumn() |
| 76 | + .field("@duration") |
| 77 | + .width( |
| 78 | + ListStreamColumnWidth.AUTO))))))))); |
| 79 | + |
| 80 | + try { |
| 81 | + Dashboard result = apiInstance.createDashboard(body); |
| 82 | + System.out.println(result); |
| 83 | + } catch (ApiException e) { |
| 84 | + System.err.println("Exception when calling DashboardsApi#createDashboard"); |
| 85 | + System.err.println("Status code: " + e.getCode()); |
| 86 | + System.err.println("Reason: " + e.getResponseBody()); |
| 87 | + System.err.println("Response headers: " + e.getResponseHeaders()); |
| 88 | + e.printStackTrace(); |
| 89 | + } |
| 90 | + } |
| 91 | +} |
0 commit comments