Rechercher des événements
https://api.datadoghq.com/api/v2/events/searchhttps://api.us3.datadoghq.com/api/v2/events/searchhttps://api.us5.datadoghq.com/api/v2/events/searchhttps://api.datadoghq.eu/api/v2/events/searchhttps://api.ap1.datadoghq.com/api/v2/events/searchhttps://api.ap2.datadoghq.com/api/v2/events/searchhttps://api.uk1.datadoghq.com/api/v2/events/searchhttps://api.ddog-gov.com/api/v2/events/searchhttps://api.us2.ddog-gov.com/api/v2/events/searchPrésentation
Le endpoint List renvoie les événements qui correspondent à une requête de recherche dʼévénements. Les résultats sont paginés de manière similaire à des logs.
Utilisez cet endpoint pour créer des filtres et un système de recherche complexe des événements.
OAuth apps require the events_read authorization scope to access this endpoint.
Requête
Body Data
filterL'objet envoyé avec la requête pour récupérer une liste dʼévénements de votre organisation.
fromThe minimum time for the requested events. Supports date math and regular timestamps in milliseconds.
now-15mqueryThe search query following the event search syntax.
*toThe maximum time for the requested events. Supports date math and regular timestamps in milliseconds.
nowoptionsThe global query options that are used. Either provide a timezone or a time offset but not both, otherwise the query fails.
timeOffsetThe time offset to apply to the query in seconds.
timezoneThe timezone can be specified as GMT, UTC, an offset from UTC (like UTC+1), or as a Timezone Database identifier (like America/New_York).
UTCpagePagination settings.
cursorThe returned paging point to use to get the next results.
limitThe maximum number of events in the response.
10sortThe sort parameters when querying events.
timestamp, -timestampSearch events returns "OK" response
{
"filter": {
"query": "datadog-agent",
"from": "2020-09-17T11:48:36+01:00",
"to": "2020-09-17T12:48:36+01:00"
},
"sort": "timestamp",
"page": {
"limit": 5
}
}Search events returns "OK" response with pagination
{
"filter": {
"from": "now-15m",
"to": "now"
},
"options": {
"timezone": "GMT"
},
"page": {
"limit": 2
},
"sort": "timestamp"
}Réponse
OK
The response object with all events matching the request and pagination information.
dataAn array of events matching the request.
attributesThe object description of an event response attribute.
attributesObject description of attributes from your event.
aggregation_keyAggregation key of the event.
date_happenedPOSIX timestamp of the event. Must be sent as an integer (no quotation marks). Limited to events no older than 18 hours.
device_nameA device name.
durationThe duration between the triggering of the event and its recovery in nanoseconds.
event_objectThe event title.
evtThe metadata associated with a request.
idEvent ID.
integration_idThe integration ID of the event.
nameThe event name.
source_idEvent source ID.
typeEvent type.
uidA unique identifier for the event. You can use this identifier to query or reference the event.
hostnameHost name to associate with the event. Any tags associated with the host are also applied to this event.
monitorAttributes from the monitor that triggered the event.
created_atThe POSIX timestamp of the monitor's creation in nanoseconds.
group_statusMonitor group status used when there is no result_groups.
groupsGroups to which the monitor belongs.
idThe monitor ID.
messageThe monitor message.
modifiedThe monitor's last-modified timestamp.
nameThe monitor name.
queryThe query that triggers the alert.
tagsA list of tags attached to the monitor.
templated_nameThe templated name of the monitor before resolving any template variables.
typeThe monitor type.
monitor_groupsList of groups referred to in the event.
monitor_idID of the monitor that triggered the event. When an event isn't related to a monitor, this field is empty.
priorityThe priority of the event alert. Legacy events use normal or low.
Alert events use 1 (highest priority) through 5 (lowest priority).
normal, low, 1, 2, 3, 4, 5related_event_idRelated event ID.
serviceService that triggered the event.
source_type_nameThe type of event being posted.
For example, nagios, hudson, jenkins, my_apps, chef, puppet, git or bitbucket.
The list of standard source attribute values is available here.
sourcecategoryIdentifier for the source of the event, such as a monitor alert, an externally-submitted event, or an integration.
statusThe event status. Legacy events can use failure, error, warning,
info, success, user_update, recommendation, or snapshot.
Alert events can use error, warn, or ok.
failure, error, warn, warning, ok, info, success, user_update, recommendation, snapshottagsA list of tags to apply to the event.
timestampPOSIX timestamp of your event in milliseconds.
titleThe event title.
messageThe message of the event.
tagsAn array of tags associated with the event.
timestampThe timestamp of the event.
idthe unique ID of the event.
typeType of the event.
eventeventlinksLinks attributes.
nextLink for the next set of results. Note that the request can also be made using the POST endpoint.
metaThe metadata associated with a request.
elapsedThe time elapsed in milliseconds.
pagePagination attributes.
afterThe cursor to use to get the next results, if any. To make the next request, use the same
parameters with the addition of the page[cursor].
request_idThe identifier of the request.
statusThe request status.
warningsA list of warnings (non-fatal errors) encountered. Partial results might be returned if warnings are present in the response.
codeA unique code for this type of warning.
detailA detailed explanation of this specific warning.
titleA short human-readable summary of the warning.
{
"data": [
{
"attributes": {
"attributes": {
"aggregation_key": "string",
"date_happened": "integer",
"device_name": "string",
"duration": "integer",
"event_object": "Did you hear the news today?",
"evt": {
"id": "6509751066204996294",
"integration_id": "custom-events",
"name": "string",
"source_id": 36,
"type": "error_tracking_alert",
"uid": "AaBJ4QimAABPmEWRwc_8yAAA"
},
"hostname": "string",
"monitor": {
"created_at": 1646318692000,
"group_status": "integer",
"groups": [],
"id": "integer",
"message": "string",
"modified": "integer",
"name": "string",
"query": "string",
"tags": [
"environment:test"
],
"templated_name": "string",
"type": "string"
},
"monitor_groups": [],
"monitor_id": "integer",
"priority": "normal",
"related_event_id": "integer",
"service": "datadog-api",
"source_type_name": "string",
"sourcecategory": "string",
"status": "info",
"tags": [
"environment:test"
],
"timestamp": 1652274265000,
"title": "Oh boy!"
},
"message": "string",
"tags": [
"team:A"
],
"timestamp": "2019-01-02T09:42:36.320Z"
},
"id": "AAAAAWgN8Xwgr1vKDQAAAABBV2dOOFh3ZzZobm1mWXJFYTR0OA",
"type": "event"
}
],
"links": {
"next": "https://app.datadoghq.com/api/v2/events?filter[query]=foo&page[cursor]=eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ=="
},
"meta": {
"elapsed": 132,
"page": {
"after": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ=="
},
"request_id": "MWlFUjVaWGZTTTZPYzM0VXp1OXU2d3xLSVpEMjZKQ0VKUTI0dEYtM3RSOFVR",
"status": "done",
"warnings": [
{
"code": "unknown_index",
"detail": "indexes: foo, bar",
"title": "One or several indexes are missing or invalid. Results hold data from the other indexes."
}
]
}
}Bad Request
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Not Authorized
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Exemple de code
Search events returns "OK" response
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/events/search" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"filter": {
"query": "datadog-agent",
"from": "2020-09-17T11:48:36+01:00",
"to": "2020-09-17T12:48:36+01:00"
},
"sort": "timestamp",
"page": {
"limit": 5
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/events/search" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"filter": {
"query": "datadog-agent",
"from": "2020-09-17T11:48:36+01:00",
"to": "2020-09-17T12:48:36+01:00"
},
"sort": "timestamp",
"page": {
"limit": 5
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/events/search" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"filter": {
"query": "datadog-agent",
"from": "2020-09-17T11:48:36+01:00",
"to": "2020-09-17T12:48:36+01:00"
},
"sort": "timestamp",
"page": {
"limit": 5
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/events/search" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"filter": {
"query": "datadog-agent",
"from": "2020-09-17T11:48:36+01:00",
"to": "2020-09-17T12:48:36+01:00"
},
"sort": "timestamp",
"page": {
"limit": 5
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/events/search" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"filter": {
"query": "datadog-agent",
"from": "2020-09-17T11:48:36+01:00",
"to": "2020-09-17T12:48:36+01:00"
},
"sort": "timestamp",
"page": {
"limit": 5
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/events/search" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"filter": {
"query": "datadog-agent",
"from": "2020-09-17T11:48:36+01:00",
"to": "2020-09-17T12:48:36+01:00"
},
"sort": "timestamp",
"page": {
"limit": 5
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/events/search" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"filter": {
"query": "datadog-agent",
"from": "2020-09-17T11:48:36+01:00",
"to": "2020-09-17T12:48:36+01:00"
},
"sort": "timestamp",
"page": {
"limit": 5
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/events/search" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"filter": {
"query": "datadog-agent",
"from": "2020-09-17T11:48:36+01:00",
"to": "2020-09-17T12:48:36+01:00"
},
"sort": "timestamp",
"page": {
"limit": 5
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/events/search" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"filter": {
"query": "datadog-agent",
"from": "2020-09-17T11:48:36+01:00",
"to": "2020-09-17T12:48:36+01:00"
},
"sort": "timestamp",
"page": {
"limit": 5
}
}
EOFSearch events returns "OK" response with pagination
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/events/search" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"filter": {
"from": "now-15m",
"to": "now"
},
"options": {
"timezone": "GMT"
},
"page": {
"limit": 2
},
"sort": "timestamp"
}
EOF# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/events/search" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"filter": {
"from": "now-15m",
"to": "now"
},
"options": {
"timezone": "GMT"
},
"page": {
"limit": 2
},
"sort": "timestamp"
}
EOF# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/events/search" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"filter": {
"from": "now-15m",
"to": "now"
},
"options": {
"timezone": "GMT"
},
"page": {
"limit": 2
},
"sort": "timestamp"
}
EOF# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/events/search" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"filter": {
"from": "now-15m",
"to": "now"
},
"options": {
"timezone": "GMT"
},
"page": {
"limit": 2
},
"sort": "timestamp"
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/events/search" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"filter": {
"from": "now-15m",
"to": "now"
},
"options": {
"timezone": "GMT"
},
"page": {
"limit": 2
},
"sort": "timestamp"
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/events/search" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"filter": {
"from": "now-15m",
"to": "now"
},
"options": {
"timezone": "GMT"
},
"page": {
"limit": 2
},
"sort": "timestamp"
}
EOF# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/events/search" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"filter": {
"from": "now-15m",
"to": "now"
},
"options": {
"timezone": "GMT"
},
"page": {
"limit": 2
},
"sort": "timestamp"
}
EOF# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/events/search" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"filter": {
"from": "now-15m",
"to": "now"
},
"options": {
"timezone": "GMT"
},
"page": {
"limit": 2
},
"sort": "timestamp"
}
EOF# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/events/search" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"filter": {
"from": "now-15m",
"to": "now"
},
"options": {
"timezone": "GMT"
},
"page": {
"limit": 2
},
"sort": "timestamp"
}
EOFSearch events returns "OK" response
// Search events returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
body := datadogV2.EventsListRequest{
Filter: &datadogV2.EventsQueryFilter{
Query: datadog.PtrString("datadog-agent"),
From: datadog.PtrString("2020-09-17T11:48:36+01:00"),
To: datadog.PtrString("2020-09-17T12:48:36+01:00"),
},
Sort: datadogV2.EVENTSSORT_TIMESTAMP_ASCENDING.Ptr(),
Page: &datadogV2.EventsRequestPage{
Limit: datadog.PtrInt32(5),
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewEventsApi(apiClient)
resp, r, err := api.SearchEvents(ctx, *datadogV2.NewSearchEventsOptionalParameters().WithBody(body))
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `EventsApi.SearchEvents`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `EventsApi.SearchEvents`:\n%s\n", responseContent)
}
Search events returns "OK" response with pagination
// Search events returns "OK" response with pagination
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
body := datadogV2.EventsListRequest{
Filter: &datadogV2.EventsQueryFilter{
From: datadog.PtrString("now-15m"),
To: datadog.PtrString("now"),
},
Options: &datadogV2.EventsQueryOptions{
Timezone: datadog.PtrString("GMT"),
},
Page: &datadogV2.EventsRequestPage{
Limit: datadog.PtrInt32(2),
},
Sort: datadogV2.EVENTSSORT_TIMESTAMP_ASCENDING.Ptr(),
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewEventsApi(apiClient)
resp, _ := api.SearchEventsWithPagination(ctx, *datadogV2.NewSearchEventsOptionalParameters().WithBody(body))
for paginationResult := range resp {
if paginationResult.Error != nil {
fmt.Fprintf(os.Stderr, "Error when calling `EventsApi.SearchEvents`: %v\n", paginationResult.Error)
}
responseContent, _ := json.MarshalIndent(paginationResult.Item, "", " ")
fmt.Fprintf(os.Stdout, "%s\n", responseContent)
}
}
Instructions
First install the library and its dependencies and then save the example to main.go and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"Search events returns "OK" response
// Search events returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.EventsApi;
import com.datadog.api.client.v2.api.EventsApi.SearchEventsOptionalParameters;
import com.datadog.api.client.v2.model.EventsListRequest;
import com.datadog.api.client.v2.model.EventsListResponse;
import com.datadog.api.client.v2.model.EventsQueryFilter;
import com.datadog.api.client.v2.model.EventsRequestPage;
import com.datadog.api.client.v2.model.EventsSort;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
EventsApi apiInstance = new EventsApi(defaultClient);
EventsListRequest body =
new EventsListRequest()
.filter(
new EventsQueryFilter()
.query("datadog-agent")
.from("2020-09-17T11:48:36+01:00")
.to("2020-09-17T12:48:36+01:00"))
.sort(EventsSort.TIMESTAMP_ASCENDING)
.page(new EventsRequestPage().limit(5));
try {
EventsListResponse result =
apiInstance.searchEvents(new SearchEventsOptionalParameters().body(body));
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling EventsApi#searchEvents");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Search events returns "OK" response with pagination
// Search events returns "OK" response with pagination
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.PaginationIterable;
import com.datadog.api.client.v2.api.EventsApi;
import com.datadog.api.client.v2.api.EventsApi.SearchEventsOptionalParameters;
import com.datadog.api.client.v2.model.EventResponse;
import com.datadog.api.client.v2.model.EventsListRequest;
import com.datadog.api.client.v2.model.EventsQueryFilter;
import com.datadog.api.client.v2.model.EventsQueryOptions;
import com.datadog.api.client.v2.model.EventsRequestPage;
import com.datadog.api.client.v2.model.EventsSort;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
EventsApi apiInstance = new EventsApi(defaultClient);
EventsListRequest body =
new EventsListRequest()
.filter(new EventsQueryFilter().from("now-15m").to("now"))
.options(new EventsQueryOptions().timezone("GMT"))
.page(new EventsRequestPage().limit(2))
.sort(EventsSort.TIMESTAMP_ASCENDING);
try {
PaginationIterable<EventResponse> iterable =
apiInstance.searchEventsWithPagination(new SearchEventsOptionalParameters().body(body));
for (EventResponse item : iterable) {
System.out.println(item);
}
} catch (RuntimeException e) {
System.err.println("Exception when calling EventsApi#searchEventsWithPagination");
System.err.println("Reason: " + e.getMessage());
e.printStackTrace();
}
}
}
Instructions
First install the library and its dependencies and then save the example to Example.java and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"Search events returns "OK" response
"""
Search events returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.events_api import EventsApi
from datadog_api_client.v2.model.events_list_request import EventsListRequest
from datadog_api_client.v2.model.events_query_filter import EventsQueryFilter
from datadog_api_client.v2.model.events_request_page import EventsRequestPage
from datadog_api_client.v2.model.events_sort import EventsSort
body = EventsListRequest(
filter=EventsQueryFilter(
query="datadog-agent",
_from="2020-09-17T11:48:36+01:00",
to="2020-09-17T12:48:36+01:00",
),
sort=EventsSort.TIMESTAMP_ASCENDING,
page=EventsRequestPage(
limit=5,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = EventsApi(api_client)
response = api_instance.search_events(body=body)
print(response)
Search events returns "OK" response with pagination
"""
Search events returns "OK" response with pagination
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.events_api import EventsApi
from datadog_api_client.v2.model.events_list_request import EventsListRequest
from datadog_api_client.v2.model.events_query_filter import EventsQueryFilter
from datadog_api_client.v2.model.events_query_options import EventsQueryOptions
from datadog_api_client.v2.model.events_request_page import EventsRequestPage
from datadog_api_client.v2.model.events_sort import EventsSort
body = EventsListRequest(
filter=EventsQueryFilter(
_from="now-15m",
to="now",
),
options=EventsQueryOptions(
timezone="GMT",
),
page=EventsRequestPage(
limit=2,
),
sort=EventsSort.TIMESTAMP_ASCENDING,
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = EventsApi(api_client)
items = api_instance.search_events_with_pagination(body=body)
for item in items:
print(item)
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"Search events returns "OK" response
# Search events returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::EventsAPI.new
body = DatadogAPIClient::V2::EventsListRequest.new({
filter: DatadogAPIClient::V2::EventsQueryFilter.new({
query: "datadog-agent",
from: "2020-09-17T11:48:36+01:00",
to: "2020-09-17T12:48:36+01:00",
}),
sort: DatadogAPIClient::V2::EventsSort::TIMESTAMP_ASCENDING,
page: DatadogAPIClient::V2::EventsRequestPage.new({
limit: 5,
}),
})
opts = {
body: body,
}
p api_instance.search_events(opts)
Search events returns "OK" response with pagination
# Search events returns "OK" response with pagination
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::EventsAPI.new
body = DatadogAPIClient::V2::EventsListRequest.new({
filter: DatadogAPIClient::V2::EventsQueryFilter.new({
from: "now-15m",
to: "now",
}),
options: DatadogAPIClient::V2::EventsQueryOptions.new({
timezone: "GMT",
}),
page: DatadogAPIClient::V2::EventsRequestPage.new({
limit: 2,
}),
sort: DatadogAPIClient::V2::EventsSort::TIMESTAMP_ASCENDING,
})
opts = {
body: body,
}
api_instance.search_events_with_pagination(opts) { |item| puts item }
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"Search events returns "OK" response
// Search events returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_events::EventsAPI;
use datadog_api_client::datadogV2::api_events::SearchEventsOptionalParams;
use datadog_api_client::datadogV2::model::EventsListRequest;
use datadog_api_client::datadogV2::model::EventsQueryFilter;
use datadog_api_client::datadogV2::model::EventsRequestPage;
use datadog_api_client::datadogV2::model::EventsSort;
#[tokio::main]
async fn main() {
let body = EventsListRequest::new()
.filter(
EventsQueryFilter::new()
.from("2020-09-17T11:48:36+01:00".to_string())
.query("datadog-agent".to_string())
.to("2020-09-17T12:48:36+01:00".to_string()),
)
.page(EventsRequestPage::new().limit(5))
.sort(EventsSort::TIMESTAMP_ASCENDING);
let configuration = datadog::Configuration::new();
let api = EventsAPI::with_config(configuration);
let resp = api
.search_events(SearchEventsOptionalParams::default().body(body))
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Search events returns "OK" response with pagination
// Search events returns "OK" response with pagination
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_events::EventsAPI;
use datadog_api_client::datadogV2::api_events::SearchEventsOptionalParams;
use datadog_api_client::datadogV2::model::EventsListRequest;
use datadog_api_client::datadogV2::model::EventsQueryFilter;
use datadog_api_client::datadogV2::model::EventsQueryOptions;
use datadog_api_client::datadogV2::model::EventsRequestPage;
use datadog_api_client::datadogV2::model::EventsSort;
use futures_util::pin_mut;
use futures_util::stream::StreamExt;
#[tokio::main]
async fn main() {
let body = EventsListRequest::new()
.filter(
EventsQueryFilter::new()
.from("now-15m".to_string())
.to("now".to_string()),
)
.options(EventsQueryOptions::new().timezone("GMT".to_string()))
.page(EventsRequestPage::new().limit(2))
.sort(EventsSort::TIMESTAMP_ASCENDING);
let configuration = datadog::Configuration::new();
let api = EventsAPI::with_config(configuration);
let response =
api.search_events_with_pagination(SearchEventsOptionalParams::default().body(body));
pin_mut!(response);
while let Some(resp) = response.next().await {
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
}
Instructions
First install the library and its dependencies and then save the example to src/main.rs and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runSearch events returns "OK" response
/**
* Search events returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
const apiInstance = new v2.EventsApi(configuration);
const params: v2.EventsApiSearchEventsRequest = {
body: {
filter: {
query: "datadog-agent",
from: "2020-09-17T11:48:36+01:00",
to: "2020-09-17T12:48:36+01:00",
},
sort: "timestamp",
page: {
limit: 5,
},
},
};
apiInstance
.searchEvents(params)
.then((data: v2.EventsListResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Search events returns "OK" response with pagination
/**
* Search events returns "OK" response with pagination
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
const apiInstance = new v2.EventsApi(configuration);
const params: v2.EventsApiSearchEventsRequest = {
body: {
filter: {
from: "now-15m",
to: "now",
},
options: {
timezone: "GMT",
},
page: {
limit: 2,
},
sort: "timestamp",
},
};
(async () => {
try {
for await (const item of apiInstance.searchEventsWithPagination(params)) {
console.log(item);
}
} catch (error) {
console.error(error);
}
})();
Instructions
First install the library and its dependencies and then save the example to example.ts and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"