Module Contents



Uses datadog API to send metrics of practically anything measurable.

class airflow.providers.datadog.hooks.datadog.DatadogHook(datadog_conn_id='datadog_default')[source]

Bases: airflow.hooks.base.BaseHook, airflow.utils.log.logging_mixin.LoggingMixin

Uses datadog API to send metrics of practically anything measurable.

It’s possible to track # of db records inserted/deleted, records read from file and many other useful metrics.

Depends on the datadog API, which has to be deployed on the same server where Airflow runs.


datadog_conn_id (str) – The connection to datadog, containing metadata for api keys.

conn_name_attr = 'datadog_conn_id'[source]
default_conn_name = 'datadog_default'[source]
conn_type = 'datadog'[source]
hook_name = 'Datadog'[source]

Validate Datadog response.

send_metric(metric_name, datapoint, tags=None, type_=None, interval=None)[source]

Send a single datapoint metric to Datadog.

  • metric_name (str) – The name of the metric

  • datapoint (float | int) – A single integer or float related to the metric

  • tags (list[str] | None) – A list of tags associated with the metric

  • type – Type of your metric: gauge, rate, or count

  • interval (int | None) – If the type of the metric is rate or count, define the corresponding interval

query_metric(query, from_seconds_ago, to_seconds_ago)[source]

Query datadog for a metric, potentially with some function applied to it and return the result.

  • query (str) – The datadog query to execute (see datadog docs)

  • from_seconds_ago (int) – How many seconds ago to start querying for.

  • to_seconds_ago (int) – Up to how many seconds ago to query for.

post_event(title, text, aggregation_key=None, alert_type=None, date_happened=None, handle=None, priority=None, related_event_id=None, tags=None, device_name=None)[source]

Post an event to datadog (processing finished, potentially alerts, other issues).

Think about this as a means to maintain persistence of alerts, rather than alerting itself.

  • title (str) – The title of the event

  • text (str) – The body of the event (more information)

  • aggregation_key (str | None) – Key that can be used to aggregate this event in a stream

  • alert_type (str | None) – The alert type for the event, one of [“error”, “warning”, “info”, “success”]

  • date_happened (int | None) – POSIX timestamp of the event; defaults to now

  • handle (str | None) – str

  • priority (str | None) – Priority to post the event as. (“normal” or “low”, defaults to “normal”)

  • related_event_id (int | None) – Post event as a child of the given event

  • tags (list[str] | None) – List of tags to apply to the event

  • device_name (list[str] | None) – device_name to post the event with


User to post the event as; defaults to owner of the application key used to submit.

classmethod get_connection_form_widgets()[source]

Return connection widgets to add to connection form.

classmethod get_ui_field_behaviour()[source]

Return custom field behaviour.

Was this entry helpful?