|
| 1 | +// Create a new dashboard with llm_observability_stream list_stream widget |
| 2 | + |
| 3 | +package main |
| 4 | + |
| 5 | +import ( |
| 6 | + "context" |
| 7 | + "encoding/json" |
| 8 | + "fmt" |
| 9 | + "os" |
| 10 | + |
| 11 | + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" |
| 12 | + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV1" |
| 13 | +) |
| 14 | + |
| 15 | +func main() { |
| 16 | + body := datadogV1.Dashboard{ |
| 17 | + LayoutType: datadogV1.DASHBOARDLAYOUTTYPE_ORDERED, |
| 18 | + Title: "Example-Dashboard with list_stream widget", |
| 19 | + Widgets: []datadogV1.Widget{ |
| 20 | + { |
| 21 | + Definition: datadogV1.WidgetDefinition{ |
| 22 | + ListStreamWidgetDefinition: &datadogV1.ListStreamWidgetDefinition{ |
| 23 | + Type: datadogV1.LISTSTREAMWIDGETDEFINITIONTYPE_LIST_STREAM, |
| 24 | + Requests: []datadogV1.ListStreamWidgetRequest{ |
| 25 | + { |
| 26 | + ResponseFormat: datadogV1.LISTSTREAMRESPONSEFORMAT_EVENT_LIST, |
| 27 | + Query: datadogV1.ListStreamQuery{ |
| 28 | + DataSource: datadogV1.LISTSTREAMSOURCE_LLM_OBSERVABILITY_STREAM, |
| 29 | + QueryString: "@event_type:span @parent_id:undefined", |
| 30 | + Indexes: []string{}, |
| 31 | + }, |
| 32 | + Columns: []datadogV1.ListStreamColumn{ |
| 33 | + { |
| 34 | + Field: "@status", |
| 35 | + Width: datadogV1.LISTSTREAMCOLUMNWIDTH_COMPACT, |
| 36 | + }, |
| 37 | + { |
| 38 | + Field: "@content.prompt", |
| 39 | + Width: datadogV1.LISTSTREAMCOLUMNWIDTH_AUTO, |
| 40 | + }, |
| 41 | + { |
| 42 | + Field: "@content.response.content", |
| 43 | + Width: datadogV1.LISTSTREAMCOLUMNWIDTH_AUTO, |
| 44 | + }, |
| 45 | + { |
| 46 | + Field: "timestamp", |
| 47 | + Width: datadogV1.LISTSTREAMCOLUMNWIDTH_AUTO, |
| 48 | + }, |
| 49 | + { |
| 50 | + Field: "@ml_app", |
| 51 | + Width: datadogV1.LISTSTREAMCOLUMNWIDTH_AUTO, |
| 52 | + }, |
| 53 | + { |
| 54 | + Field: "service", |
| 55 | + Width: datadogV1.LISTSTREAMCOLUMNWIDTH_AUTO, |
| 56 | + }, |
| 57 | + { |
| 58 | + Field: "@meta.evaluations.quality", |
| 59 | + Width: datadogV1.LISTSTREAMCOLUMNWIDTH_AUTO, |
| 60 | + }, |
| 61 | + { |
| 62 | + Field: "@meta.evaluations.security", |
| 63 | + Width: datadogV1.LISTSTREAMCOLUMNWIDTH_AUTO, |
| 64 | + }, |
| 65 | + { |
| 66 | + Field: "@duration", |
| 67 | + Width: datadogV1.LISTSTREAMCOLUMNWIDTH_AUTO, |
| 68 | + }, |
| 69 | + }, |
| 70 | + }, |
| 71 | + }, |
| 72 | + }}, |
| 73 | + }, |
| 74 | + }, |
| 75 | + } |
| 76 | + ctx := datadog.NewDefaultContext(context.Background()) |
| 77 | + configuration := datadog.NewConfiguration() |
| 78 | + apiClient := datadog.NewAPIClient(configuration) |
| 79 | + api := datadogV1.NewDashboardsApi(apiClient) |
| 80 | + resp, r, err := api.CreateDashboard(ctx, body) |
| 81 | + |
| 82 | + if err != nil { |
| 83 | + fmt.Fprintf(os.Stderr, "Error when calling `DashboardsApi.CreateDashboard`: %v\n", err) |
| 84 | + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) |
| 85 | + } |
| 86 | + |
| 87 | + responseContent, _ := json.MarshalIndent(resp, "", " ") |
| 88 | + fmt.Fprintf(os.Stdout, "Response from `DashboardsApi.CreateDashboard`:\n%s\n", responseContent) |
| 89 | +} |
0 commit comments