Le service d’événements vous permet de programmer l’envoi et la récupération d’événements dans le flux d’événements. Les événements sont limités à 4 000 caractères. Si un événement est envoyé avec un message contenant plus de 4 000 caractères, seuls les 4 000 premiers caractères seront affichés.
An arbitrary string to use for aggregation. Limited to 100 characters.
If you specify a key, all events using that key are grouped together in the Event Stream.
alert_type
enum
If an alert event is enabled, set its type.
For example, error, warning, info, success, user_update,
recommendation, and snapshot.
Allowed enum values: error,warning,info,success,user_update,recommendation,snapshot
date_happened
int64
POSIX timestamp of the event. Must be sent as an integer (that is no quotes).
Limited to events no older than 18 hours
device_name
string
A device name.
host
string
Host name to associate with the event.
Any tags associated with the host are also applied to this event.
priority
enum
The priority of the event. For example, normal or low.
Allowed enum values: normal,low
related_event_id
int64
ID of the parent event. Must be sent as an integer (that is no quotes).
source_type_name
string
The type of event being posted. Option examples include nagios, hudson, jenkins, my_apps, chef, puppet, git, bitbucket, etc.
A complete list of source attribute values available here.
tags
[string]
A list of tags to apply to the event.
text [required]
string
The body of the event. Limited to 4000 characters. The text supports markdown.
To use markdown in the event text, start the text block with %%% \n and end the text block with \n %%%.
Use msg_text with the Datadog Ruby library.
title [required]
string
The event title.
{"title":"Example-Post_an_event_returns_OK_response","text":"A text message.","tags":["test:ExamplePostaneventreturnsOKresponse"]}
{"title":"Example-Post_an_event_with_a_long_title_returns_OK_response very very very looooooooong looooooooooooong loooooooooooooooooooooong looooooooooooooooooooooooooong title with 100+ characters","text":"A text message.","tags":["test:ExamplePostaneventwithalongtitlereturnsOKresponse"]}
If an alert event is enabled, set its type.
For example, error, warning, info, success, user_update,
recommendation, and snapshot.
Allowed enum values: error,warning,info,success,user_update,recommendation,snapshot
date_happened
int64
POSIX timestamp of the event. Must be sent as an integer (that is no quotes).
Limited to events no older than 18 hours.
device_name
string
A device name.
host
string
Host name to associate with the event.
Any tags associated with the host are also applied to this event.
id
int64
Integer ID of the event.
id_str
string
Handling IDs as large 64-bit numbers can cause loss of accuracy issues with some programming languages.
Instead, use the string representation of the Event ID to avoid losing accuracy.
payload
string
Payload of the event.
priority
enum
The priority of the event. For example, normal or low.
Allowed enum values: normal,low
source_type_name
string
The type of event being posted. Option examples include nagios, hudson, jenkins, my_apps, chef, puppet, git, bitbucket, etc.
The list of standard source attribute values available here.
tags
[string]
A list of tags to apply to the event.
text
string
The body of the event. Limited to 4000 characters. The text supports markdown.
To use markdown in the event text, start the text block with %%% \n and end the text block with \n %%%.
Use msg_text with the Datadog Ruby library.
title
string
The event title.
url
string
URL of the event.
status
string
A status.
{"event":{"alert_type":"info","date_happened":"integer","device_name":"string","host":"string","id":"integer","id_str":"string","payload":"{}","priority":"normal","source_type_name":"string","tags":["environment:test"],"text":"Oh boy!","title":"Did you hear the news today?","url":"string"},"status":"string"}
# Curl commandcurl-XPOST"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/events" \
-H"Content-Type: application/json" \
-H"DD-API-KEY: ${DD_API_KEY}" \
-d@-<<EOF{
"title": "Example-Post_an_event_with_a_long_title_returns_OK_response very very very looooooooong looooooooooooong loooooooooooooooooooooong looooooooooooooooooooooooooong title with 100+ characters",
"text": "A text message.",
"tags": [
"test:ExamplePostaneventwithalongtitlereturnsOKresponse"
]
}EOF
// Post an event returns "OK" response
packagemainimport("context""encoding/json""fmt""os"datadog"github.com/DataDog/datadog-api-client-go/api/v1/datadog")funcmain(){body:=datadog.EventCreateRequest{Title:"Example-Post_an_event_returns_OK_response",Text:"A text message.",Tags:[]string{"test:ExamplePostaneventreturnsOKresponse",},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)resp,r,err:=apiClient.EventsApi.CreateEvent(ctx,body)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `EventsApi.CreateEvent`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `EventsApi.CreateEvent`:\n%s\n",responseContent)}
// Post an event with a long title returns "OK" response
packagemainimport("context""encoding/json""fmt""os"datadog"github.com/DataDog/datadog-api-client-go/api/v1/datadog")funcmain(){body:=datadog.EventCreateRequest{Title:"Example-Post_an_event_with_a_long_title_returns_OK_response very very very looooooooong looooooooooooong loooooooooooooooooooooong looooooooooooooooooooooooooong title with 100+ characters",Text:"A text message.",Tags:[]string{"test:ExamplePostaneventwithalongtitlereturnsOKresponse",},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)resp,r,err:=apiClient.EventsApi.CreateEvent(ctx,body)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `EventsApi.CreateEvent`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `EventsApi.CreateEvent`:\n%s\n",responseContent)}
// Post an event returns "OK" response
importcom.datadog.api.v1.client.ApiClient;importcom.datadog.api.v1.client.ApiException;importcom.datadog.api.v1.client.Configuration;importcom.datadog.api.v1.client.api.EventsApi;importcom.datadog.api.v1.client.model.EventCreateRequest;importcom.datadog.api.v1.client.model.EventCreateResponse;importjava.util.Collections;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=Configuration.getDefaultApiClient();EventsApiapiInstance=newEventsApi(defaultClient);EventCreateRequestbody=newEventCreateRequest().title("Example-Post_an_event_returns_OK_response").text("A text message.").tags(Collections.singletonList("test:ExamplePostaneventreturnsOKresponse"));try{EventCreateResponseresult=apiInstance.createEvent(body);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling EventsApi#createEvent");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// Post an event with a long title returns "OK" response
importcom.datadog.api.v1.client.ApiClient;importcom.datadog.api.v1.client.ApiException;importcom.datadog.api.v1.client.Configuration;importcom.datadog.api.v1.client.api.EventsApi;importcom.datadog.api.v1.client.model.EventCreateRequest;importcom.datadog.api.v1.client.model.EventCreateResponse;importjava.util.Collections;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=Configuration.getDefaultApiClient();EventsApiapiInstance=newEventsApi(defaultClient);EventCreateRequestbody=newEventCreateRequest().title("Example-Post_an_event_with_a_long_title_returns_OK_response very very very"+" looooooooong looooooooooooong loooooooooooooooooooooong"+" looooooooooooooooooooooooooong title with 100+ characters").text("A text message.").tags(Collections.singletonList("test:ExamplePostaneventwithalongtitlereturnsOKresponse"));try{EventCreateResponseresult=apiInstance.createEvent(body);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling EventsApi#createEvent");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
fromdatadogimportinitialize,apioptions={'api_key':'<DATADOG_API_KEY>','app_key':'<DATADOG_APPLICATION_KEY>'}initialize(**options)title="Something big happened!"text='And let me tell you all about it here!'tags=['version:1','application:web']api.Event.create(title=title,text=text,tags=tags)# If you are programmatically adding a comment to this new event# you might want to insert a pause of .5 - 1 second to allow the# event to be available.
"""
Post an event returns "OK" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v1.api.events_apiimportEventsApifromdatadog_api_client.v1.model.event_create_requestimportEventCreateRequestbody=EventCreateRequest(title="Example-Post_an_event_returns_OK_response",text="A text message.",tags=["test:ExamplePostaneventreturnsOKresponse",],)configuration=Configuration()withApiClient(configuration)asapi_client:api_instance=EventsApi(api_client)response=api_instance.create_event(body=body)print(response)
"""
Post an event with a long title returns "OK" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v1.api.events_apiimportEventsApifromdatadog_api_client.v1.model.event_create_requestimportEventCreateRequestbody=EventCreateRequest(title="Example-Post_an_event_with_a_long_title_returns_OK_response very very very looooooooong looooooooooooong loooooooooooooooooooooong looooooooooooooooooooooooooong title with 100+ characters",text="A text message.",tags=["test:ExamplePostaneventwithalongtitlereturnsOKresponse",],)configuration=Configuration()withApiClient(configuration)asapi_client:api_instance=EventsApi(api_client)response=api_instance.create_event(body=body)print(response)
require'rubygems'require'dogapi'api_key='<DATADOG_API_KEY>'app_key='<DATADOG_APPLICATION_KEY>'dog=Dogapi::Client.new(api_key,app_key)# submitting events doesn 't require an application_key,# so we don't bother setting itdog=Dogapi::Client.new(api_key)dog.emit_event(Dogapi::Event.new('msg_text',:msg_title=>'Title'))# If you are programmatically adding a comment to this new event# you might want to insert a pause of.5 - 1 second to allow the# event to be available.
# Post an event returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V1::EventsAPI.newbody=DatadogAPIClient::V1::EventCreateRequest.new({title:"Example-Post_an_event_returns_OK_response",text:"A text message.",tags:["test:ExamplePostaneventreturnsOKresponse",],})papi_instance.create_event(body)
# Post an event with a long title returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V1::EventsAPI.newbody=DatadogAPIClient::V1::EventCreateRequest.new({title:"Example-Post_an_event_with_a_long_title_returns_OK_response very very very looooooooong looooooooooooong loooooooooooooooooooooong looooooooooooooooooooooooooong title with 100+ characters",text:"A text message.",tags:["test:ExamplePostaneventwithalongtitlereturnsOKresponse",],})papi_instance.create_event(body)
/**
* Post an event returns "OK" response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.EventsApi(configuration);constparams: v1.EventsApiCreateEventRequest={body:{title:"Example-Post_an_event_returns_OK_response",text:"A text message.",tags:["test:ExamplePostaneventreturnsOKresponse"],},};apiInstance.createEvent(params).then((data: v1.EventCreateResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
/**
* Post an event with a long title returns "OK" response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.EventsApi(configuration);constparams: v1.EventsApiCreateEventRequest={body:{title:"Example-Post_an_event_with_a_long_title_returns_OK_response very very very looooooooong looooooooooooong loooooooooooooooooooooong looooooooooooooooooooooooooong title with 100+ characters",text:"A text message.",tags:["test:ExamplePostaneventwithalongtitlereturnsOKresponse"],},};apiInstance.createEvent(params).then((data: v1.EventCreateResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
Le flux d’événements peut être interrogé et filtré par période, priorité, source et tag.
Remarques :
Si l’événement que vous interrogez comprend de la mise en forme Markdown, les caractères %,\,n peuvent s’afficher dans votre sortie.
Cet endpoint renvoie jusqu’à 1000 résultats parmi les plus récents. Pour renvoyer davantage de résultats, identifiez le dernier timestamp du dernier résultat et définissez-le en tant que end de l’intervalle de requête pour paginer les résultats. Vous pouvez également utiliser le paramètre de page pour spécifier l’ensemble de 1000 résultats à renvoyer.
This endpoint requires the events_read authorization scope.
Arguments
Chaînes de requête
Nom
Type
Description
start [required]
integer
POSIX timestamp.
end [required]
integer
POSIX timestamp.
priority
enum
Priority of your events, either low or normal. Allowed enum values: normal, low
sources
string
A comma separated string of sources.
tags
string
A comma separated list indicating what tags, if any, should be used to filter the list of monitors by scope.
unaggregated
boolean
Set unaggregated to true to return all events within the specified [start,end] timeframe.
Otherwise if an event is aggregated to a parent event with a timestamp outside of the timeframe,
it won’t be available in the output. Aggregated events with is_aggregate=true in the response will still be returned unless exclude_aggregate is set to true.
exclude_aggregate
boolean
Set exclude_aggregate to true to only return unaggregated events where is_aggregate=false in the response. If the exclude_aggregate parameter is set to true,
then the unaggregated parameter is ignored and will be true by default.
page
integer
By default 1000 results are returned per request. Set page to the number of the page to return with 0 being the first page. The page parameter can only be used
when either unaggregated or exclude_aggregate is set to true.
If an alert event is enabled, set its type.
For example, error, warning, info, success, user_update,
recommendation, and snapshot.
Allowed enum values: error,warning,info,success,user_update,recommendation,snapshot
date_happened
int64
POSIX timestamp of the event. Must be sent as an integer (that is no quotes).
Limited to events no older than 18 hours.
device_name
string
A device name.
host
string
Host name to associate with the event.
Any tags associated with the host are also applied to this event.
id
int64
Integer ID of the event.
id_str
string
Handling IDs as large 64-bit numbers can cause loss of accuracy issues with some programming languages.
Instead, use the string representation of the Event ID to avoid losing accuracy.
payload
string
Payload of the event.
priority
enum
The priority of the event. For example, normal or low.
Allowed enum values: normal,low
source_type_name
string
The type of event being posted. Option examples include nagios, hudson, jenkins, my_apps, chef, puppet, git, bitbucket, etc.
The list of standard source attribute values available here.
tags
[string]
A list of tags to apply to the event.
text
string
The body of the event. Limited to 4000 characters. The text supports markdown.
To use markdown in the event text, start the text block with %%% \n and end the text block with \n %%%.
Use msg_text with the Datadog Ruby library.
title
string
The event title.
url
string
URL of the event.
status
string
A status.
{"events":[{"alert_type":"info","date_happened":"integer","device_name":"string","host":"string","id":"integer","id_str":"string","payload":"{}","priority":"normal","source_type_name":"string","tags":["environment:test"],"text":"Oh boy!","title":"Did you hear the news today?","url":"string"}],"status":"string"}
Cet endpoint vous permet d’interroger un événement pour obtenir des informations à son sujet.
Remarque : si l’événement que vous interrogez comprend de la mise en forme Markdown, les caractères « % », « \ » ou encore « n » peuvent s’afficher dans votre sortie.
This endpoint requires the events_read authorization scope.
If an alert event is enabled, set its type.
For example, error, warning, info, success, user_update,
recommendation, and snapshot.
Allowed enum values: error,warning,info,success,user_update,recommendation,snapshot
date_happened
int64
POSIX timestamp of the event. Must be sent as an integer (that is no quotes).
Limited to events no older than 18 hours.
device_name
string
A device name.
host
string
Host name to associate with the event.
Any tags associated with the host are also applied to this event.
id
int64
Integer ID of the event.
id_str
string
Handling IDs as large 64-bit numbers can cause loss of accuracy issues with some programming languages.
Instead, use the string representation of the Event ID to avoid losing accuracy.
payload
string
Payload of the event.
priority
enum
The priority of the event. For example, normal or low.
Allowed enum values: normal,low
source_type_name
string
The type of event being posted. Option examples include nagios, hudson, jenkins, my_apps, chef, puppet, git, bitbucket, etc.
The list of standard source attribute values available here.
tags
[string]
A list of tags to apply to the event.
text
string
The body of the event. Limited to 4000 characters. The text supports markdown.
To use markdown in the event text, start the text block with %%% \n and end the text block with \n %%%.
Use msg_text with the Datadog Ruby library.
title
string
The event title.
url
string
URL of the event.
status
string
A status.
{"event":{"alert_type":"info","date_happened":"integer","device_name":"string","host":"string","id":"integer","id_str":"string","payload":"{}","priority":"normal","source_type_name":"string","tags":["environment:test"],"text":"Oh boy!","title":"Did you hear the news today?","url":"string"},"status":"string"}
"""
Get an event returns "OK" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v1.api.events_apiimportEventsApiconfiguration=Configuration()withApiClient(configuration)asapi_client:api_instance=EventsApi(api_client)response=api_instance.get_event(event_id=9223372036854775807,)print(response)
# Get an event returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V1::EventsAPI.newpapi_instance.get_event(9223372036854775807)
/**
* Get an event returns "OK" response
*/import{client,v1}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv1.EventsApi(configuration);constparams: v1.EventsApiGetEventRequest={eventId: 9223372036854775807,};apiInstance.getEvent(params).then((data: v1.EventResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
// Get an event returns "OK" response
packagemainimport("context""encoding/json""fmt""os"datadog"github.com/DataDog/datadog-api-client-go/api/v1/datadog")funcmain(){ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)resp,r,err:=apiClient.EventsApi.GetEvent(ctx,9223372036854775807)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `EventsApi.GetEvent`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `EventsApi.GetEvent`:\n%s\n",responseContent)}