-
Notifications
You must be signed in to change notification settings - Fork 57
/
ListLogsGet_2034110533.go
32 lines (26 loc) · 1.04 KB
/
ListLogsGet_2034110533.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Get a quick list of logs returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"time"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewLogsApi(apiClient)
resp, r, err := api.ListLogsGet(ctx, *datadogV2.NewListLogsGetOptionalParameters().WithFilterQuery("datadog-agent").WithFilterIndexes([]string{
"main",
}).WithFilterFrom(time.Date(2020, 9, 17, 11, 48, 36, 0, time.UTC)).WithFilterTo(time.Date(2020, 9, 17, 12, 48, 36, 0, time.UTC)).WithPageLimit(5))
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `LogsApi.ListLogsGet`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `LogsApi.ListLogsGet`:\n%s\n", responseContent)
}