airflow.providers.datadog.hooks.datadog¶
Module Contents¶
-
class
airflow.providers.datadog.hooks.datadog.DatadogHook(datadog_conn_id: str = 'datadog_default')[source]¶ Bases:
airflow.hooks.base.BaseHook,airflow.utils.log.logging_mixin.LoggingMixinUses datadog API to send metrics of practically anything measurable, so 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.
- Parameters
datadog_conn_id (str) -- The connection to datadog, containing metadata for api keys.
-
send_metric(self, metric_name: str, datapoint: Union[float, int], tags: Optional[List[str]] = None, type_: Optional[str] = None, interval: Optional[int] = None)[source]¶ Sends a single datapoint metric to DataDog
- Parameters
metric_name (str) -- The name of the metric
datapoint (int or float) -- A single integer or float related to the metric
tags (list) -- A list of tags associated with the metric
type (str) -- Type of your metric: gauge, rate, or count
interval (int) -- If the type of the metric is rate or count, define the corresponding interval
-
query_metric(self, query: str, from_seconds_ago: int, to_seconds_ago: int)[source]¶ Queries datadog for a specific metric, potentially with some function applied to it and returns the results.
-
post_event(self, title: str, text: str, aggregation_key: Optional[str] = None, alert_type: Optional[str] = None, date_happened: Optional[int] = None, handle: Optional[str] = None, priority: Optional[str] = None, related_event_id: Optional[int] = None, tags: Optional[List[str]] = None, device_name: Optional[List[str]] = None)[source]¶ Posts 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.
- Parameters
title (str) -- The title of the event
text (str) -- The body of the event (more information)
aggregation_key (str) -- Key that can be used to aggregate this event in a stream
alert_type (str) -- The alert type for the event, one of ["error", "warning", "info", "success"]
date_happened (int) -- POSIX timestamp of the event; defaults to now
handle -- str
priority (str) -- Priority to post the event as. ("normal" or "low", defaults to "normal")
related_event_id (id) -- Post event as a child of the given event
device_name (list) -- device_name to post the event with
- Handle
User to post the event as; defaults to owner of the application key used to submit.