(Logs)
- SearchLogs - Search logs
- ListLogArchives - Retrieve location and metadata of log archives
Search logs within a time period
package main
import(
"os"
swosdkgo "github.com/solarwinds/swo-sdk-go"
"github.com/solarwinds/swo-sdk-go/models/operations"
"context"
"log"
)
func main() {
s := swosdkgo.New(
swosdkgo.WithSecurity(os.Getenv("SWO_API_TOKEN")),
)
ctx := context.Background()
res, err := s.Logs.SearchLogs(ctx, operations.SearchLogsRequest{})
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
for {
// handle items
res, err = res.Next()
if err != nil {
// handle error
}
if res == nil {
break
}
}
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.SearchLogsRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.SearchLogsResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.APIError | 4XX, 5XX | */* |
Retrieves a list of log archives within a time period.
package main
import(
"os"
swosdkgo "github.com/solarwinds/swo-sdk-go"
"github.com/solarwinds/swo-sdk-go/models/operations"
"context"
"log"
)
func main() {
s := swosdkgo.New(
swosdkgo.WithSecurity(os.Getenv("SWO_API_TOKEN")),
)
ctx := context.Background()
res, err := s.Logs.ListLogArchives(ctx, operations.ListLogArchivesRequest{
StartTime: "<value>",
EndTime: "<value>",
})
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
for {
// handle items
res, err = res.Next()
if err != nil {
// handle error
}
if res == nil {
break
}
}
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.ListLogArchivesRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.ListLogArchivesResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.APIError | 4XX, 5XX | */* |