- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
After installing DogStatsD, you can emit events to your Datadog event explorer with the following function:
event(<title>, <message>, <alert_type>, <aggregation_key>, <source_type_name>, <date_happened>, <priority>, <tags>, <hostname>)
Definitions:
Parameter | Type | Required | Description |
---|---|---|---|
<title> | String | Yes | The title of the event |
<message> | String | Yes | The text body of the event |
<alert_type> | String | No | error , warning , success , or info (defaults to info ) |
<aggregation_key> | String | No | A key to use for aggregating events |
<source_type_name> | String | No | The source type name (defaults to my_apps ) |
<date_happened> | Integer | No | The epoch timestamp for the event (defaults to the current time from the DogStatsD server) |
<priority> | String | No | Specifies the priority of the event (normal or low ) |
<tags> | List of strings | No | A list of tags associated with this event |
<hostname> | String | No | The name of the host |
Run the following code to view errors and exceptions in Datadog with a DogStatsD event. Remember to flush
/close
the client when it is no longer needed.
from datadog import initialize, statsd
options = {
'statsd_host':'127.0.0.1',
'statsd_port':8125
}
initialize(**options)
statsd.event('An error occurred', 'Error message', alert_type='error', tags=['env:dev'])
require 'datadog/statsd'
statsd = Datadog::Statsd.new('localhost', 8125)
statsd.event('An error occurred', "Error message", alert_type: 'error', tags: ['env:dev'])
package main
import (
"log"
"time"
"github.com/DataDog/datadog-go/statsd"
)
func main() {
dogstatsdClient, err := statsd.New("127.0.0.1:8125")
if err != nil {
log.Fatal(err)
}
for {
dogstatsdClient.SimpleEvent("An error occurred", "Error message")
time.Sleep(10 * time.Second)
}
}
import com.timgroup.statsd.Event;
import com.timgroup.statsd.NonBlockingStatsDClientBuilder;
import com.timgroup.statsd.StatsDClient;
public class DogStatsdClient {
public static void main(String[] args) throws Exception {
StatsDClient Statsd = new NonBlockingStatsDClientBuilder()
.prefix("statsd").
.hostname("localhost")
.port(8125)
.build();
Event event = Event.builder()
.withTitle("An error occurred")
.withText("Error message")
.withAlertType(Event.AlertType.ERROR)
.build();
Statsd.recordEvent(event);
}
}
using StatsdClient;
public class DogStatsdClient
{
public static void Main()
{
var dogstatsdConfig = new StatsdConfig
{
StatsdServerName = "127.0.0.1",
StatsdPort = 8125,
};
using (var dogStatsdService = new DogStatsdService())
{
if (!dogStatsdService.Configure(dogstatsdConfig))
throw new InvalidOperationException("Cannot initialize DogstatsD. Set optionalExceptionHandler argument in the `Configure` method for more information.");
dogStatsdService.Event("An error occurred", "Error message", alertType: "error", date_happened='TIMESTAMP', tags: new[] { "env:dev" });
}
}
}
<?php
require __DIR__ . '/vendor/autoload.php';
use DataDog\DogStatsd;
$statsd = new DogStatsd(
array('host' => '127.0.0.1',
'port' => 8125,
)
);
$statsd->event('An error occurred.',
array( 'text' => 'Error message',
'alert_type' => 'error'
)
);
With the DogStatsD-PHP library you can submit events through TCP directly to the Datadog API. It’s slower but more reliable than using the Agent DogStatsD instance since events are forwarded from your application to the Agent using UDP. To use this, you must configure the library with your Datadog API and application keys instead of the local DogStatS instance:
<?php
require __DIR__ . '/vendor/autoload.php';
use DataDog\DogStatsd;
$statsd = new DogStatsd(
array('api_key' => '<DATADOG_API_KEY>',
'app_key' => '<DATADOG_APPLICATION_KEY>',
)
);
$statsd->event('An error occurred.',
array( 'text' => 'Error message',
'alert_type' => 'error'
)
);
Note:
try
/catch
code block to avoid warnings or errors on communication issues with the Datadog API.