Créer un monitor
https://api.datadoghq.com/api/v1/monitorhttps://api.us3.datadoghq.com/api/v1/monitorhttps://api.us5.datadoghq.com/api/v1/monitorhttps://api.datadoghq.eu/api/v1/monitorhttps://api.ap1.datadoghq.com/api/v1/monitorhttps://api.ap2.datadoghq.com/api/v1/monitorhttps://api.uk1.datadoghq.com/api/v1/monitorhttps://api.ddog-gov.com/api/v1/monitorhttps://api.us2.ddog-gov.com/api/v1/monitorPrésentation
Créez un monitor à l'aide des options suivantes.
Types de monitors
Voici les types de monitors qui peuvent être sélectionnés :
- Monitor d'anomalies :
query alert - Monitor APM :
query alertoutrace-analytics alert - Monitor composite :
composite - Monitor personnalisé :
service check - Monitor de prévisions :
query alert - Monitor de host :
service check - Monitor d'intégration :
query alertouservice check - Monitor de live process :
process alert - Monitor de log :
log alert - Monitor de métrique :
query alert - Monitor réseau :
service check - Monitor outlier :
query alert - Monitor de processus :
service check - Monitor RUM :
rum alert - Monitor de SLO :
slo alert - Monitor Watchdog :
event-v2 alert - Monitor d'événement v2 :
event-v2 alert - Monitor d'audit :
audit alert - Monitor Error Tracking :
error-tracking alert - Monitor Database Monitoring :
database-monitoring alert - Monitor de performance réseau :
network-performance alert - Monitor Cloud Cost :
cost alert - Monitor Network Path :
network-path alert
Remarques :
- Les monitors Synthetic sont créés par l'intermédiaire de l'API Synthetics. Consultez la documentation dédiée à cette API pour en savoir plus.
- Les monitors de log nécessitent une clé d'application sans restriction.
Types de requêtes
Requête d'alerte de métrique
Exemple : time_aggr(time_window):space_aggr:metric{tags} [by {key}] operator #
time_aggr: avg, sum, max, min, change ou pct_change.time_window:last_#m(#doit être compris entre 1 et 10080 selon le type de monitor),last_#h(#doit être compris entre 1 et 168 selon le type de monitor),last_1doulast_1w.space_aggr: avg, sum, min ou max.tags: un ou plusieurs tags (séparés par des virgules), ou *key: la « key » de la syntaxe de tag key:value. Définit une alerte distincte pour chaque tag du groupe (alertes multiples).operator: <, <=, >, >=, == ou !=.#: un nombre entier ou décimal utilisé pour définir le seuil.
Si vous utilisez l'agrégateur temporel _change_ ou _pct_change_, utilisez plutôt change_aggr(time_aggr(time_window), timeshift):space_aggr:metric{tags} [by {key}] operator # avec :
change_aggrchange ou pct_change.time_aggravg, sum, max ou min en savoir plus.time_windowlast_#m (entre 1 et 2880 selon le type de monitor), last_#h (entre 1 et 48 selon le type de monitor) ou last_#d (1 ou 2).timeshift#m_ago (5, 10, 15 ou 30), #h_ago (1, 2 ou 4) ou 1d_ago.
Pour créer un monitor outlier, utilisez la requête suivante :
avg(last_30m):outliers(avg:system.cpu.user{role:es-events-data} by {host}, 'dbscan', 7) > 0
Requête de check de service
Exemple : "check".over(tags).last(count).by(group).count_by_status()
check: le nom du check, par exempledatadog.agent.up.tags: un ou plusieurs tags entre guillemets (séparés par des virgules) ou "*". Exemple :.over("env:prod", "role:db");overne peut pas être vide.count: doit être supérieur ou égal à votre seuil maximum (défini dansoptions). Valeur maximale : 100. Par exemple, si vous souhaitez recevoir une notification à partir d'un statut critical, de trois statuts ok, et de deux statuts warn,countdoit être supérieur ou égal à 3.group: doit être défini pour les monitors de check. Le regroupement par check est déjà explicitement connu pour certains checks de service. Par exemple, les monitors de l'intégration Postgres possèdent les tagsdb,hostetport, tandis que les monitors réseau possèdent les tagshost,instanceeturl. Consultez la section Checks de service pour en savoir plus.
Requête d'alerte d'événement
Remarque : la requête d'alerte d'événement a été remplacée par la requête d'alerte d'événement v2. Pour en savoir plus, consultez le guide de migration des événements.
Requête d'alerte d'événement v2
Exemple : events(query).rollup(rollup_method[, measure]).last(time_window) operator #
query: la requête de recherche respectant la syntaxe de recherche de logs.rollup_method: la méthode de cumul des statistiques ; les méthodescount,avgetcardinalitysont prises en charge.measure- pour lesrollup_methodavgetcardinality: indiquez le nom de la mesure ou de la facette à utiliser.time_window: #m (entre 1 et 2880) ou #h (entre 1 et 48).operator:<,<=,>,>=,==ou!=.#: un nombre entier ou décimal utilisé pour définir le seuil.
Requête d'alerte de processus
Exemple : processes(search).over(tags).rollup('count').last(timeframe) operator #
search: chaîne de recherche en texte libre pour interroger les processus. Les processus renvoyés correspondent aux résultats de la page Live Processes.tags: un ou plusieurs tags (séparés par des virgules).timeframe: l'intervalle sur lequel les totaux doivent être cumulés. Exemples : 10m ou 4h. Intervalles pris en charge : s, m, h et doperator: <, <=, >, >=, == ou !=#: un nombre entier ou décimal utilisé pour définir le seuil.
Requête d'alerte de log
Exemple : logs(query).index(index_name).rollup(rollup_method[, measure]).last(time_window) operator #
query: la requête de recherche respectant la syntaxe de recherche de logs.index_name: pour les organisations avec plusieurs index, l'index de log sur lequel la requête porte.rollup_method: la méthode de cumul des statistiques ; les méthodescount,avgetcardinalitysont prises en charge.measure- pour lesrollup_methodavgetcardinality: indiquez le nom de la mesure ou de la facette à utiliser.time_window: #m (entre 1 et 2880) ou #h (entre 1 et 48).operator:<,<=,>,>=,==ou!=.#: un nombre entier ou décimal utilisé pour définir le seuil.
Requête de monitor composite
Exemple : 12345 && 67890, où 12345 et 67890 sont les identifiants de monitors non composites.
name[requis, valeur par défaut = dynamique, en fonction de la requête] : le nom de l'alerte.message[requis, valeur par défaut = dynamique, en fonction de la requête] : un message à inclure avec les notifications pour ce monitor. Des notifications par e-mail peuvent être envoyées à des utilisateurs spécifiques, en utilisant la même notation « @nomutilisateur » que pour les événements.tags[facultatif, valeur par défaut = liste vide] : la liste des tags à associer à votre monitor. Lorsque vous récupérez tous les détails des monitors via l'API, utilisez l'argumentmonitor_tagspour filtrer les résultats en fonction de ces tags. Ces valeurs ne peuvent être obtenues qu'avec l'API et ne sont ni visibles ni modifiables dans l'interface Datadog.
Requête d'alerte SLO
Exemple : error_budget("slo_id").over("time_window") operator #
slo_id: l'ID alphanumérique du SLO pour lequel vous configurez l'alerte.time_window: l'intervalle du SLO cible pour lequel vous souhaitez envoyer une alerte. Valeurs autorisées :7d,30dou90d.operator:>=ou>
Requête d'alerte d'audit
Exemple : audits(query).rollup(rollup_method[, measure]).last(time_window) operator #
query: la requête de recherche respectant la syntaxe de recherche de logs.rollup_method: la méthode de cumul des statistiques ; les méthodescount,avgetcardinalitysont prises en charge.measure- pour lesrollup_methodavgetcardinality: indiquez le nom de la mesure ou de la facette à utiliser.time_window: #m (entre 1 et 2880) ou #h (entre 1 et 48).operator:<,<=,>,>=,==ou!=.#: un nombre entier ou décimal utilisé pour définir le seuil.
Requêtes d'alerte de pipelines CI
Exemple : ci-pipelines(query).rollup(rollup_method[, measure]).last(time_window) operator #
query: la requête de recherche respectant la syntaxe de recherche de logs.rollup_method: la méthode de cumul des statistiques ; les méthodescount,avgetcardinalitysont prises en charge.measure- pour lesrollup_methodavgetcardinality: indiquez le nom de la mesure ou de la facette à utiliser.time_window: #m (entre 1 et 2880) ou #h (entre 1 et 48).operator:<,<=,>,>=,==ou!=.#: un nombre entier ou décimal utilisé pour définir le seuil.
Requête d'alerte de tests CI
Exemple : ci-tests(query).rollup(rollup_method[, measure]).last(time_window) operator #
query: la requête de recherche respectant la syntaxe de recherche de logs.rollup_method: la méthode de cumul des statistiques ; les méthodescount,avgetcardinalitysont prises en charge.measure- pour lesrollup_methodavgetcardinality: indiquez le nom de la mesure ou de la facette à utiliser.time_window: #m (entre 1 et 2880) ou #h (entre 1 et 48).operator:<,<=,>,>=,==ou!=.#: un nombre entier ou décimal utilisé pour définir le seuil.
Requête d'alerte Error Tracking
Exemple de nouveau problème : error-tracking(query).source(issue_source).new().rollup(rollup_method[, measure]).by(group_by).last(time_window) operator #
Exemple de problème à fort impact : error-tracking(query).source(issue_source).impact().rollup(rollup_method[, measure]).by(group_by).last(time_window) operator #
query: la requête de recherche respectant la syntaxe de recherche de logs.issue_source: la source du problème ; les sourcesall,browser,mobileetbackendsont prises en charge. Si aucune source n'est spécifiée, la valeurallest appliquée par défaut.rollup_method: la méthode de cumul des statistiques ; les méthodescount,avgetcardinalitysont prises en charge. Si aucune méthode n'est spécifiée, la valeurcountest définie par défaut.measure- pour lesrollup_methodavgetcardinality: indiquez le nom de la mesure ou de la facette à utiliser.group by: la liste d'attributs séparés par des virgules à partir de laquelle effectuer le regroupement. Elle doit contenir au moinsissue.id.time_window: #m (entre 1 et 2880) ou #h (entre 1 et 48).operator:<,<=,>,>=,==ou!=.#: un nombre entier ou décimal utilisé pour définir le seuil.
Requête d'alerte Database Monitoring
Exemple : database-monitoring(query).rollup(rollup_method[, measure]).last(time_window) operator #
query: la requête de recherche respectant la syntaxe de recherche de logs.rollup_method: la méthode de cumul des statistiques ; les méthodescount,avgetcardinalitysont prises en charge.measure- pour lesrollup_methodavgetcardinality: indiquez le nom de la mesure ou de la facette à utiliser.time_window: #m (entre 1 et 2880) ou #h (entre 1 et 48).operator:<,<=,>,>=,==ou!=.#: un nombre entier ou décimal utilisé pour définir le seuil.
Requête d'alerte de performance réseau
Exemple : network-performance(query).rollup(rollup_method[, measure]).last(time_window) operator #
query: la requête de recherche respectant la syntaxe de recherche de logs.rollup_method: la méthode de cumul des statistiques ; les méthodescount,avgetcardinalitysont prises en charge.measure- pour lesrollup_methodavgetcardinality: indiquez le nom de la mesure ou de la facette à utiliser.time_window: #m (entre 1 et 2880) ou #h (entre 1 et 48).operator:<,<=,>,>=,==ou!=.#: un nombre entier ou décimal utilisé pour définir le seuil.
Requête d'alerte sur les coûts
Exemple : formula(query).timeframe_type(time_window).function(parameter) operator #
query: la requête de recherche respectant la syntaxe de recherche de logs.timeframe_type: le type d'intervalle à appliquer pour évaluer le coût. - Les monitorsforecastprennent en charge l'intervallecurrent. - Les monitorschange,anomalyetthresholdprennent en charge l'intervallelast.time_window: prend en charge le cumul quotidien, par exemple7d.function[facultatif, défini par défaut sur le monitorthresholdsi aucune valeur n'est spécifiée] : prend en charge les monitorschange,anomalyetforecast.parameter: spécifiez le paramètre du type.- Pour les monitors
change:- Prise en charge de
relativeouabsolute. - [facultatif] Prise en charge de
#, où#correspond à un nombre entier ou décimal utilisé pour définir le seuil.
- Prise en charge de
- Pour les monitors
anomaly:- Prise en charge de
direction=both,direction=aboveoudirection=below. - [facultatif] Prise en charge de
threshold=#, où#correspond à un nombre entier ou décimal utilisé pour définir le seuil.
- Prise en charge de
- Pour les monitors
operator- Pour les monitors
threshold: prend en charge<,<=,>,>=,==ou!=. - Pour les monitors
change: prend en charge>ou<. - Pour les monitors
anomaly: prend en charge>=. - Pour les monitors
forecast: prend en charge>.
- Pour les monitors
#: un nombre entier ou décimal utilisé pour définir le seuil.
Requête d'alerte Network Path
Exemple : network-path(query).index(index_name).rollup(rollup_method[, measure]).last(time_window) operator #
query: la requête de recherche respectant la syntaxe de recherche de logs.index_name: le type de données à surveiller ; les typesnetpath-pathetnetpath-hopsont pris en charge.rollup_method: la méthode de cumul des statistiques ; les méthodescount,avgetcardinalitysont prises en charge.measure- pour lesrollup_methodavgetcardinality: indiquez le nom de la mesure ou de la facette à utiliser.time_window: #m (entre 1 et 2880) ou #h (entre 1 et 48).operator:<,<=,>,>=,==ou!=.#: un nombre entier ou décimal utilisé pour définir le seuil.
OAuth apps require one of the following authorization scopes to access this endpoint: monitors_write, monitors_draft_write.
Requête
Body Data (required)
Corps de requête pour la création d'un monitor.
assetsObjet décrivant un monitor.
category [required]Indicates the type of asset this entity represents on a monitor.
runbookname [required]Name for the monitor asset
resource_keyRepresents the identifier of the internal Datadog resource that this asset represents. IDs in this field should be passed in as strings.
resource_typeType of internal Datadog resource associated with a monitor asset.
notebookurl [required]URL link for the asset. For links with an internal resource type set, this should be the relative path to where the Datadog domain is appended internally. For external links, this should be the full URL path.
draft_statusIndicates whether the monitor is in a draft or published state.
draft: The monitor appears as Draft and does not send notifications.
published: The monitor is active and evaluates conditions and notify as configured.
This field is in preview. The draft value is only available to customers with the feature enabled.
publisheddraft, publishedmatching_downtimesA list of active v1 downtimes that match this monitor.
endPOSIX timestamp to end the downtime.
scopeThe scope(s) to which the downtime applies. Must be in key:value format. For example, host:app2.
Provide multiple scopes as a comma-separated list like env:dev,env:prod.
The resulting downtime applies to sources that matches ALL provided scopes (env:dev AND env:prod).
startPOSIX timestamp to start the downtime.
messageA message to include with notifications for this monitor.
nameThe monitor name.
optionsList of options associated with your monitor.
enable_logs_sampleWhether or not to send a log sample when the log monitor triggers.
enable_samplesWhether or not to send a list of samples when the monitor triggers. This is only used by CI Test and Pipeline monitors.
escalation_messageWe recommend using the is_renotify,
block in the original message instead.
A message to include with a re-notification. Supports the @username notification we allow elsewhere.
Not applicable if renotify_interval is None.
evaluation_delayTime (in seconds) to delay evaluation, as a non-negative integer. For example, if the value is set to 300 (5min),
the timeframe is set to last_5m and the time is 7:00, the monitor evaluates data from 6:50 to 6:55.
This is useful for AWS CloudWatch and other backfilled metrics to ensure the monitor always has data during evaluation.
group_retention_durationThe time span after which groups with missing data are dropped from the monitor state. The minimum value is one hour, and the maximum value is 72 hours. Example values are: "60m", "1h", and "2d". This option is only available for APM Trace Analytics, Audit Trail, CI, Error Tracking, Event, Logs, and RUM monitors.
groupby_simple_monitorDEPRECATED Whether the log alert monitor triggers a single alert or multiple alerts when any group breaches a threshold. Use notify_by instead.
include_tagsA Boolean indicating whether notifications from this monitor automatically inserts its triggering tags into the title.
Examples
- If
True,[Triggered on {host:h1}] Monitor Title - If
False,[Triggered] Monitor Title
truelockedDEPRECATED Whether or not the monitor is locked (only editable by creator and admins). Use restricted_roles instead.
min_failure_durationHow long the test should be in failure before alerting (integer, number of seconds, max 7200).
0min_location_failedThe minimum number of locations in failure at the same time during
at least one moment in the min_failure_duration period (min_location_failed and min_failure_duration
are part of the advanced alerting rules - integer, >= 1).
1new_group_delayTime (in seconds) to skip evaluations for new groups.
For example, this option can be used to skip evaluations for new hosts while they initialize.
Must be a non negative integer.
new_host_delayDEPRECATED Time (in seconds) to allow a host to boot and applications to fully start before starting the evaluation of monitor results. Should be a non negative integer.
Use new_group_delay instead.
300no_data_timeframeThe number of minutes before a monitor notifies after data stops reporting. Datadog recommends at least 2x the monitor timeframe for query alerts or 2 minutes for service checks. If omitted, 2x the evaluation timeframe is used for query alerts, and 24 hours is used for service checks.
notification_preset_nameToggles the display of additional content sent in the monitor notification.
show_allshow_all, hide_query, hide_handles, hide_all, hide_query_and_handles, show_only_snapshot, hide_handles_and_footernotify_auditA Boolean indicating whether tagged users is notified on changes to this monitor.
falsenotify_byControls what granularity a monitor alerts on. Only available for monitors with groupings.
For instance, a monitor grouped by cluster, namespace, and pod can be configured to only notify on each
new cluster violating the alert conditions by setting notify_by to ["cluster"]. Tags mentioned
in notify_by must be a subset of the grouping tags in the query.
For example, a query grouped by cluster and namespace cannot notify on region.
Setting notify_by to ["*"] configures the monitor to notify as a simple-alert.
notify_no_dataA Boolean indicating whether this monitor notifies when data stops reporting. Defaults to false.
on_missing_dataControls how groups or monitors are treated if an evaluation does not return any data points.
The default option results in different behavior depending on the monitor query type.
For monitors using Count queries, an empty monitor evaluation is treated as 0 and is compared to the threshold conditions.
For monitors using any query type other than Count, for example Gauge, Measure, or Rate, the monitor shows the last known status.
This option is available for APM Trace Analytics, Audit Trail, CI, Error Tracking, Event, Logs, and RUM monitors.
It is also required for metric monitors that use scheduling_options.custom_schedule.
default, show_no_data, show_and_notify_no_data, resolverenotify_intervalThe number of minutes after the last notification before a monitor re-notifies on the current status. It only re-notifies if it’s not resolved.
nullrenotify_occurrencesThe number of times re-notification messages should be sent on the current status at the provided re-notification interval.
renotify_statusesThe types of monitor statuses for which re-notification messages are sent.
Default: null if renotify_interval is null.
If renotify_interval is set, defaults to renotify on Alert and No Data.
require_full_windowA Boolean indicating whether this monitor needs a full window of data before it’s evaluated.
We highly recommend you set this to false for sparse metrics,
otherwise some evaluations are skipped. Default is false. This setting only applies to
metric monitors.
scheduling_optionsConfiguration options for scheduling.
custom_scheduleConfiguration options for the custom schedule. This feature is in private beta.
recurrencesArray of custom schedule recurrences.
rruleDefines the recurrence rule (RRULE) for a given schedule.
startDefines the start date and time of the recurring schedule.
timezoneDefines the timezone the schedule runs on.
evaluation_windowConfiguration options for the evaluation window. If hour_starts is set, no other fields may be set. Otherwise, day_starts and month_starts must be set together.
day_startsThe time of the day at which a one day cumulative evaluation window starts.
hour_startsThe minute of the hour at which a one hour cumulative evaluation window starts.
month_startsThe day of the month at which a one month cumulative evaluation window starts.
timezoneThe timezone of the time of the day of the cumulative evaluation window start.
silencedDEPRECATED Information about the downtime applied to the monitor. Only shows v1 downtimes.
<any-key>UTC epoch timestamp in seconds when the downtime for the group expires.
synthetics_check_idDEPRECATED ID of the corresponding Synthetic check.
threshold_windowsAlerting time window options.
recovery_windowDescribes how long an anomalous metric must be normal before the alert recovers.
trigger_windowDescribes how long a metric must be anomalous before an alert triggers.
thresholdsList of the different monitor threshold available.
criticalThe monitor CRITICAL threshold.
critical_queryQuery evaluated as a dynamic CRITICAL threshold. Only supported on metric monitors with a formula query and options['variables']. Cannot be combined with static thresholds. This field is in preview.
critical_recoveryThe monitor CRITICAL recovery threshold.
critical_recovery_queryQuery evaluated as a dynamic CRITICAL recovery threshold. Only supported on metric monitors with a formula query and options['variables']. Cannot be combined with static thresholds. This field is in preview.
okThe monitor OK threshold.
unknownThe monitor UNKNOWN threshold.
warningThe monitor WARNING threshold.
warning_recoveryThe monitor WARNING recovery threshold.
timeout_hThe number of hours of the monitor not reporting data before it automatically resolves from a triggered state. The minimum allowed value is 0 hours. The maximum allowed value is 24 hours.
nullvariablesList of requests that can be used in the monitor query. This feature is currently in beta.
Object 1A formula and functions events query.
compute [required]Compute options.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgintervalA time interval in milliseconds.
metricMeasurable attribute to compute.
nameThe name assigned to this aggregation, when multiple aggregations are defined for a query.
sourceSource reference for composite query payloads.
data_source [required]Data source for event platform-based queries.
rum, ci_pipelines, ci_tests, audit, events, logs, spans, database_queries, network, network_pathgroup_byGroup by options.
facet [required]Event facet.
limitNumber of groups to return.
sortOptions for sorting group by results.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgmetricMetric used for sorting group by results.
orderDirection of sort.
descasc, descsourceSource reference for composite query payloads.
indexesAn array of index names to query in the stream. Omit or use [] to query all indexes at once.
name [required]Name of the query for use in formulas.
searchSearch options.
query [required]Events search string.
Object 2A formula and functions cost query.
aggregatorAggregation methods for metric queries.
avg, sum, max, min, last, area, l2norm, percentile, stddevdata_source [required]Data source for cost queries.
metrics, cloud_cost, datadog_usagename [required]Name of the query for use in formulas.
query [required]The monitor query.
Object 3A formula and functions data quality query.
data_source [required]Data source for data quality queries.
data_quality_metricsfilter [required]Filter expression used to match on data entities. Uses Aastra query syntax.
group_byOptional grouping fields for aggregation.
measure [required]The data quality measure to query. Common values include:
bytes, cardinality, custom, freshness, max, mean, min,
nullness, percent_negative, percent_zero, row_count, stddev,
sum, uniqueness. Additional values may be supported.
monitor_optionsMonitor configuration options for data quality queries.
crontab_overrideCrontab expression to override the default schedule.
custom_sqlCustom SQL query for the monitor.
custom_whereCustom WHERE clause for the query.
group_by_columnsColumns to group results by.
model_configurationTuning options for the anomaly detection model used by the monitor.
auto_resolve_daysNumber of days after which an open alert is automatically resolved. When unset, alerts stay open until the measure returns within bounds.
enable_flatline_detectionWhether to alert when the measure stops changing entirely.
Defaults to true.
functionFunction applied to the measure before it is compared against the predicted bounds.
DIFF, DIFF_PERCENTmin_lower_bound_sizeMinimum distance between the predicted value and the lower bound. Widening the lower bound to at least this size suppresses alerts on small downward deviations. When unset, no minimum is enforced.
min_upper_bound_sizeMinimum distance between the predicted value and the upper bound. Widening the upper bound to at least this size suppresses alerts on small upward deviations. When unset, no minimum is enforced.
model_bounds_overrideRestricts which predicted bound the monitor alerts on. UPPER_ONLY alerts only when
the measure rises above the upper bound, LOWER_ONLY only when it falls below the
lower bound. When unset, the monitor alerts on both.
UPPER_ONLY, LOWER_ONLYmodel_type_overrideOverride for the model type used in anomaly detection.
freshness, percentage, anysensitivitySensitivity of the anomaly detection model, expressed as a multiplier on the width
of the predicted bounds. Higher values widen the bounds and produce fewer alerts;
lower values tighten them and produce more alerts. Defaults to 3.0.
source_to_target_configConfiguration for a source to target monitor, which compares the same measure across two data entities and alerts on the difference between them.
diff_type [required]How the difference between the source and target measures is computed.
absolute subtracts the two values, diff_percent expresses the difference
as a percentage of the source value.
absolute, diff_percententity_type [required]Type of the data entities being compared.
source [required]Measure configuration for one side of a source to target comparison.
custom_sqlCustom SQL query used to compute the measure for this entity.
custom_whereCustom WHERE clause applied when computing the measure for this entity.
entity_id [required]Identifier of the data entity to measure.
entity_type [required]Type of the data entity to measure.
group_by_columnsColumns to group results by when computing the measure for this entity.
target [required]Measure configuration for one side of a source to target comparison.
custom_sqlCustom SQL query used to compute the measure for this entity.
custom_whereCustom WHERE clause applied when computing the measure for this entity.
entity_id [required]Identifier of the data entity to measure.
entity_type [required]Type of the data entity to measure.
group_by_columnsColumns to group results by when computing the measure for this entity.
name [required]Name of the query for use in formulas.
schema_versionSchema version for the data quality query.
scopeOptional scoping expression to further filter metrics. Uses metrics filter syntax. This is useful when an entity has been configured to emit metrics with additional tags.
Object 4A formula and functions data jobs query.
job_type [required]The type of job being monitored. Valid values include:
databricks.job, spark.application, airflow.dag,
dbt.job, dbt.model, dbt.test, glue.job.
Custom job types are supported with the custom.ol. prefix.
jobs_query [required]Filter expression used to select the jobs to monitor.
name [required]Name of the query for use in formulas. Must be run_query.
query_dialect [required]Query dialect for data jobs queries. Currently only metric is supported.
Object 5A formula and functions aggregate augmented query. Used to enrich base query results with data from a reference table.
augment_query [required]Augment query for aggregate augmented queries. Can be an events query or a reference table query.
Object 1A formula and functions events query.
compute [required]Compute options.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgintervalA time interval in milliseconds.
metricMeasurable attribute to compute.
nameThe name assigned to this aggregation, when multiple aggregations are defined for a query.
sourceSource reference for composite query payloads.
data_source [required]Data source for event platform-based queries.
rum, ci_pipelines, ci_tests, audit, events, logs, spans, database_queries, network, network_pathgroup_byGroup by options.
facet [required]Event facet.
limitNumber of groups to return.
sortOptions for sorting group by results.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgmetricMetric used for sorting group by results.
orderDirection of sort.
descasc, descsourceSource reference for composite query payloads.
indexesAn array of index names to query in the stream. Omit or use [] to query all indexes at once.
name [required]Name of the query for use in formulas.
searchSearch options.
query [required]Events search string.
<data_source=reference_table>A reference table query for use in aggregate queries.
columnsList of columns to retrieve from the reference table.
aliasOptional alias for the column.
name [required]Name of the column.
data_source [required]Data source for reference table queries.
reference_tablenameName of the query.
query_filterOptional filter expression for the reference table query.
table_name [required]Name of the reference table.
base_query [required]Base query for aggregate queries. Can be an events query or a metrics query.
Object 1A formula and functions events query.
compute [required]Compute options.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgintervalA time interval in milliseconds.
metricMeasurable attribute to compute.
nameThe name assigned to this aggregation, when multiple aggregations are defined for a query.
sourceSource reference for composite query payloads.
data_source [required]Data source for event platform-based queries.
rum, ci_pipelines, ci_tests, audit, events, logs, spans, database_queries, network, network_pathgroup_byGroup by options.
facet [required]Event facet.
limitNumber of groups to return.
sortOptions for sorting group by results.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgmetricMetric used for sorting group by results.
orderDirection of sort.
descasc, descsourceSource reference for composite query payloads.
indexesAn array of index names to query in the stream. Omit or use [] to query all indexes at once.
name [required]Name of the query for use in formulas.
searchSearch options.
query [required]Events search string.
Object 2A formula and functions metrics query for use in aggregate queries.
aggregatorAggregator for metrics queries.
avg, min, max, sum, last, mean, area, l2norm, percentile, stddevShow 1 more
count_uniquedata_source [required]Data source for metrics queries.
metrics, cloud_cost, datadog_usagenameName of the query for use in formulas.
query [required]The metrics query definition.
compute [required]Compute options for the query.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgintervalA time interval in milliseconds.
metricMeasurable attribute to compute.
nameThe name assigned to this aggregation, when multiple aggregations are defined for a query.
sourceSource reference for composite query payloads.
data_source [required]Data source for aggregate augmented queries.
aggregate_augmented_querygroup_by [required]Group by options for the query.
facet [required]Event facet.
limitNumber of groups to return.
sortOptions for sorting group by results.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgmetricMetric used for sorting group by results.
orderDirection of sort.
descasc, descsourceSource reference for composite query payloads.
join_condition [required]Join condition for aggregate augmented queries.
augment_attribute [required]Attribute from the augment query to join on.
base_attribute [required]Attribute from the base query to join on.
join_type [required]Join type for aggregate query join conditions.
inner, leftnameName of the query for use in formulas.
Object 6A formula and functions aggregate filtered query. Used to filter base query results using data from another source.
base_query [required]Base query for aggregate queries. Can be an events query or a metrics query.
Object 1A formula and functions events query.
compute [required]Compute options.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgintervalA time interval in milliseconds.
metricMeasurable attribute to compute.
nameThe name assigned to this aggregation, when multiple aggregations are defined for a query.
sourceSource reference for composite query payloads.
data_source [required]Data source for event platform-based queries.
rum, ci_pipelines, ci_tests, audit, events, logs, spans, database_queries, network, network_pathgroup_byGroup by options.
facet [required]Event facet.
limitNumber of groups to return.
sortOptions for sorting group by results.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgmetricMetric used for sorting group by results.
orderDirection of sort.
descasc, descsourceSource reference for composite query payloads.
indexesAn array of index names to query in the stream. Omit or use [] to query all indexes at once.
name [required]Name of the query for use in formulas.
searchSearch options.
query [required]Events search string.
Object 2A formula and functions metrics query for use in aggregate queries.
aggregatorAggregator for metrics queries.
avg, min, max, sum, last, mean, area, l2norm, percentile, stddevShow 1 more
count_uniquedata_source [required]Data source for metrics queries.
metrics, cloud_cost, datadog_usagenameName of the query for use in formulas.
query [required]The metrics query definition.
computeCompute options for the query.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgintervalA time interval in milliseconds.
metricMeasurable attribute to compute.
nameThe name assigned to this aggregation, when multiple aggregations are defined for a query.
sourceSource reference for composite query payloads.
data_source [required]Data source for aggregate filtered queries.
aggregate_filtered_queryfilter_query [required]Filter query for aggregate filtered queries. Can be an events query or a reference table query.
Object 1A formula and functions events query.
compute [required]Compute options.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgintervalA time interval in milliseconds.
metricMeasurable attribute to compute.
nameThe name assigned to this aggregation, when multiple aggregations are defined for a query.
sourceSource reference for composite query payloads.
data_source [required]Data source for event platform-based queries.
rum, ci_pipelines, ci_tests, audit, events, logs, spans, database_queries, network, network_pathgroup_byGroup by options.
facet [required]Event facet.
limitNumber of groups to return.
sortOptions for sorting group by results.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgmetricMetric used for sorting group by results.
orderDirection of sort.
descasc, descsourceSource reference for composite query payloads.
indexesAn array of index names to query in the stream. Omit or use [] to query all indexes at once.
name [required]Name of the query for use in formulas.
searchSearch options.
query [required]Events search string.
<data_source=reference_table>A reference table query for use in aggregate queries.
columnsList of columns to retrieve from the reference table.
aliasOptional alias for the column.
name [required]Name of the column.
data_source [required]Data source for reference table queries.
reference_tablenameName of the query.
query_filterOptional filter expression for the reference table query.
table_name [required]Name of the reference table.
filters [required]Filter conditions for the query.
base_attribute [required]Attribute from the base query to filter on.
excludeWhether to exclude matching records instead of including them.
falsefilter_attribute [required]Attribute from the filter query to match against.
group_byGroup by options for the query.
facet [required]Event facet.
limitNumber of groups to return.
sortOptions for sorting group by results.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgmetricMetric used for sorting group by results.
orderDirection of sort.
descasc, descsourceSource reference for composite query payloads.
nameName of the query for use in formulas.
priorityInteger from 1 (high) to 5 (low) indicating alert severity.
query [required]The monitor query.
restricted_rolesA list of unique role identifiers to define which roles are allowed to edit the monitor. The unique identifiers for all roles can be pulled from the Roles API and are located in the data.id field. Editing a monitor includes any updates to the monitor configuration, monitor deletion, and muting of the monitor for any amount of time. You can use the Restriction Policies API to manage write authorization for individual monitors by teams and users, in addition to roles.
tagsTags associated to your monitor.
type [required]The type of the monitor. For more information about type, see the monitor options docs.
composite, event alert, log alert, metric alert, process alert, query alert, rum alert, service check, synthetics alert, trace-analytics alertShow 13 more
slo alert, event-v2 alert, audit alert, ci-pipelines alert, ci-tests alert, error-tracking alert, database-monitoring alert, network-performance alert, cost alert, data-quality alert, network-path alert, data-jobs alert, llm-observability alertCreate a Cost Monitor returns "OK" response
{
"name": "Example Monitor",
"type": "cost alert",
"query": "formula(\"exclude_null(query1)\").last(\"7d\").anomaly(direction=\"above\", threshold=10) >= 5",
"message": "some message Notify: @hipchat-channel",
"tags": [
"test:examplemonitor",
"env:ci"
],
"priority": 3,
"options": {
"thresholds": {
"critical": 5,
"warning": 3
},
"variables": [
{
"data_source": "cloud_cost",
"query": "sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)",
"name": "query1",
"aggregator": "sum"
}
],
"include_tags": true
}
}Create a Data Jobs monitor returns "OK" response
{
"name": "Example-Monitor",
"type": "data-jobs alert",
"query": "formula(\"failed_runs(run_query)\").by(job_name,workspace_name).last(10d) > 0",
"message": "Data jobs alert triggered",
"tags": [
"test:examplemonitor",
"env:ci"
],
"options": {
"thresholds": {
"critical": 0
},
"variables": [
{
"name": "run_query",
"jobs_query": "job_name:*",
"job_type": "databricks.job",
"query_dialect": "metric"
}
]
}
}Create a Data Quality monitor returns "OK" response
{
"name": "Example-Monitor",
"type": "data-quality alert",
"query": "formula(\"query1\").last(\"5m\") > 100",
"message": "Data quality alert triggered",
"tags": [
"test:examplemonitor",
"env:ci"
],
"priority": 3,
"options": {
"thresholds": {
"critical": 100
},
"variables": [
{
"name": "query1",
"data_source": "data_quality_metrics",
"measure": "row_count",
"filter": "search for column where `database:production AND table:users`",
"group_by": [
"entity_id"
]
}
]
}
}Réponse
OK
Object describing a monitor.
assetsThe list of monitor assets tied to a monitor, which represents key links for users to take action on monitor alerts (for example, runbooks).
category [required]Indicates the type of asset this entity represents on a monitor.
runbookname [required]Name for the monitor asset
resource_keyRepresents the identifier of the internal Datadog resource that this asset represents. IDs in this field should be passed in as strings.
resource_typeType of internal Datadog resource associated with a monitor asset.
notebookurl [required]URL link for the asset. For links with an internal resource type set, this should be the relative path to where the Datadog domain is appended internally. For external links, this should be the full URL path.
createdTimestamp of the monitor creation.
creatorObject describing the creator of the shared element.
emailEmail of the creator.
handleHandle of the creator.
nameName of the creator.
deletedWhether or not the monitor is deleted. (Always null)
draft_statusIndicates whether the monitor is in a draft or published state.
draft: The monitor appears as Draft and does not send notifications.
published: The monitor is active and evaluates conditions and notify as configured.
This field is in preview. The draft value is only available to customers with the feature enabled.
publisheddraft, publishedidID of this monitor.
matching_downtimesA list of active v1 downtimes that match this monitor.
endPOSIX timestamp to end the downtime.
id [required]The downtime ID.
scopeThe scope(s) to which the downtime applies. Must be in key:value format. For example, host:app2.
Provide multiple scopes as a comma-separated list like env:dev,env:prod.
The resulting downtime applies to sources that matches ALL provided scopes (env:dev AND env:prod).
startPOSIX timestamp to start the downtime.
messageA message to include with notifications for this monitor.
modifiedLast timestamp when the monitor was edited.
multiWhether or not the monitor is broken down on different groups.
nameThe monitor name.
optionsList of options associated with your monitor.
aggregationType of aggregation performed in the monitor query.
group_byGroup to break down the monitor on.
metricMetric name used in the monitor.
typeMetric type used in the monitor.
device_idsDEPRECATED IDs of the device the Synthetics monitor is running on.
enable_logs_sampleWhether or not to send a log sample when the log monitor triggers.
enable_samplesWhether or not to send a list of samples when the monitor triggers. This is only used by CI Test and Pipeline monitors.
escalation_messageWe recommend using the is_renotify,
block in the original message instead.
A message to include with a re-notification. Supports the @username notification we allow elsewhere.
Not applicable if renotify_interval is None.
evaluation_delayTime (in seconds) to delay evaluation, as a non-negative integer. For example, if the value is set to 300 (5min),
the timeframe is set to last_5m and the time is 7:00, the monitor evaluates data from 6:50 to 6:55.
This is useful for AWS CloudWatch and other backfilled metrics to ensure the monitor always has data during evaluation.
group_retention_durationThe time span after which groups with missing data are dropped from the monitor state. The minimum value is one hour, and the maximum value is 72 hours. Example values are: "60m", "1h", and "2d". This option is only available for APM Trace Analytics, Audit Trail, CI, Error Tracking, Event, Logs, and RUM monitors.
groupby_simple_monitorDEPRECATED Whether the log alert monitor triggers a single alert or multiple alerts when any group breaches a threshold. Use notify_by instead.
include_tagsA Boolean indicating whether notifications from this monitor automatically inserts its triggering tags into the title.
Examples
- If
True,[Triggered on {host:h1}] Monitor Title - If
False,[Triggered] Monitor Title
truelockedDEPRECATED Whether or not the monitor is locked (only editable by creator and admins). Use restricted_roles instead.
min_failure_durationHow long the test should be in failure before alerting (integer, number of seconds, max 7200).
0min_location_failedThe minimum number of locations in failure at the same time during
at least one moment in the min_failure_duration period (min_location_failed and min_failure_duration
are part of the advanced alerting rules - integer, >= 1).
1new_group_delayTime (in seconds) to skip evaluations for new groups.
For example, this option can be used to skip evaluations for new hosts while they initialize.
Must be a non negative integer.
new_host_delayDEPRECATED Time (in seconds) to allow a host to boot and applications to fully start before starting the evaluation of monitor results. Should be a non negative integer.
Use new_group_delay instead.
300no_data_timeframeThe number of minutes before a monitor notifies after data stops reporting. Datadog recommends at least 2x the monitor timeframe for query alerts or 2 minutes for service checks. If omitted, 2x the evaluation timeframe is used for query alerts, and 24 hours is used for service checks.
notification_preset_nameToggles the display of additional content sent in the monitor notification.
show_allshow_all, hide_query, hide_handles, hide_all, hide_query_and_handles, show_only_snapshot, hide_handles_and_footernotify_auditA Boolean indicating whether tagged users is notified on changes to this monitor.
falsenotify_byControls what granularity a monitor alerts on. Only available for monitors with groupings.
For instance, a monitor grouped by cluster, namespace, and pod can be configured to only notify on each
new cluster violating the alert conditions by setting notify_by to ["cluster"]. Tags mentioned
in notify_by must be a subset of the grouping tags in the query.
For example, a query grouped by cluster and namespace cannot notify on region.
Setting notify_by to ["*"] configures the monitor to notify as a simple-alert.
notify_no_dataA Boolean indicating whether this monitor notifies when data stops reporting. Defaults to false.
on_missing_dataControls how groups or monitors are treated if an evaluation does not return any data points.
The default option results in different behavior depending on the monitor query type.
For monitors using Count queries, an empty monitor evaluation is treated as 0 and is compared to the threshold conditions.
For monitors using any query type other than Count, for example Gauge, Measure, or Rate, the monitor shows the last known status.
This option is available for APM Trace Analytics, Audit Trail, CI, Error Tracking, Event, Logs, and RUM monitors.
It is also required for metric monitors that use scheduling_options.custom_schedule.
default, show_no_data, show_and_notify_no_data, resolverenotify_intervalThe number of minutes after the last notification before a monitor re-notifies on the current status. It only re-notifies if it’s not resolved.
nullrenotify_occurrencesThe number of times re-notification messages should be sent on the current status at the provided re-notification interval.
renotify_statusesThe types of monitor statuses for which re-notification messages are sent.
Default: null if renotify_interval is null.
If renotify_interval is set, defaults to renotify on Alert and No Data.
require_full_windowA Boolean indicating whether this monitor needs a full window of data before it’s evaluated.
We highly recommend you set this to false for sparse metrics,
otherwise some evaluations are skipped. Default is false. This setting only applies to
metric monitors.
scheduling_optionsConfiguration options for scheduling.
custom_scheduleConfiguration options for the custom schedule. This feature is in private beta.
recurrencesArray of custom schedule recurrences.
rruleDefines the recurrence rule (RRULE) for a given schedule.
startDefines the start date and time of the recurring schedule.
timezoneDefines the timezone the schedule runs on.
evaluation_windowConfiguration options for the evaluation window. If hour_starts is set, no other fields may be set. Otherwise, day_starts and month_starts must be set together.
day_startsThe time of the day at which a one day cumulative evaluation window starts.
hour_startsThe minute of the hour at which a one hour cumulative evaluation window starts.
month_startsThe day of the month at which a one month cumulative evaluation window starts.
timezoneThe timezone of the time of the day of the cumulative evaluation window start.
silencedDEPRECATED Information about the downtime applied to the monitor. Only shows v1 downtimes.
<any-key>UTC epoch timestamp in seconds when the downtime for the group expires.
synthetics_check_idDEPRECATED ID of the corresponding Synthetic check.
threshold_windowsAlerting time window options.
recovery_windowDescribes how long an anomalous metric must be normal before the alert recovers.
trigger_windowDescribes how long a metric must be anomalous before an alert triggers.
thresholdsList of the different monitor threshold available.
criticalThe monitor CRITICAL threshold.
critical_queryQuery evaluated as a dynamic CRITICAL threshold. Only supported on metric monitors with a formula query and options['variables']. Cannot be combined with static thresholds. This field is in preview.
critical_recoveryThe monitor CRITICAL recovery threshold.
critical_recovery_queryQuery evaluated as a dynamic CRITICAL recovery threshold. Only supported on metric monitors with a formula query and options['variables']. Cannot be combined with static thresholds. This field is in preview.
okThe monitor OK threshold.
unknownThe monitor UNKNOWN threshold.
warningThe monitor WARNING threshold.
warning_recoveryThe monitor WARNING recovery threshold.
timeout_hThe number of hours of the monitor not reporting data before it automatically resolves from a triggered state. The minimum allowed value is 0 hours. The maximum allowed value is 24 hours.
nullvariablesList of requests that can be used in the monitor query. This feature is currently in beta.
Object 1A formula and functions events query.
compute [required]Compute options.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgintervalA time interval in milliseconds.
metricMeasurable attribute to compute.
nameThe name assigned to this aggregation, when multiple aggregations are defined for a query.
sourceSource reference for composite query payloads.
data_source [required]Data source for event platform-based queries.
rum, ci_pipelines, ci_tests, audit, events, logs, spans, database_queries, network, network_pathgroup_byGroup by options.
facet [required]Event facet.
limitNumber of groups to return.
sortOptions for sorting group by results.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgmetricMetric used for sorting group by results.
orderDirection of sort.
descasc, descsourceSource reference for composite query payloads.
indexesAn array of index names to query in the stream. Omit or use [] to query all indexes at once.
name [required]Name of the query for use in formulas.
searchSearch options.
query [required]Events search string.
Object 2A formula and functions cost query.
aggregatorAggregation methods for metric queries.
avg, sum, max, min, last, area, l2norm, percentile, stddevdata_source [required]Data source for cost queries.
metrics, cloud_cost, datadog_usagename [required]Name of the query for use in formulas.
query [required]The monitor query.
Object 3A formula and functions data quality query.
data_source [required]Data source for data quality queries.
data_quality_metricsfilter [required]Filter expression used to match on data entities. Uses Aastra query syntax.
group_byOptional grouping fields for aggregation.
measure [required]The data quality measure to query. Common values include:
bytes, cardinality, custom, freshness, max, mean, min,
nullness, percent_negative, percent_zero, row_count, stddev,
sum, uniqueness. Additional values may be supported.
monitor_optionsMonitor configuration options for data quality queries.
crontab_overrideCrontab expression to override the default schedule.
custom_sqlCustom SQL query for the monitor.
custom_whereCustom WHERE clause for the query.
group_by_columnsColumns to group results by.
model_configurationTuning options for the anomaly detection model used by the monitor.
auto_resolve_daysNumber of days after which an open alert is automatically resolved. When unset, alerts stay open until the measure returns within bounds.
enable_flatline_detectionWhether to alert when the measure stops changing entirely.
Defaults to true.
functionFunction applied to the measure before it is compared against the predicted bounds.
DIFF, DIFF_PERCENTmin_lower_bound_sizeMinimum distance between the predicted value and the lower bound. Widening the lower bound to at least this size suppresses alerts on small downward deviations. When unset, no minimum is enforced.
min_upper_bound_sizeMinimum distance between the predicted value and the upper bound. Widening the upper bound to at least this size suppresses alerts on small upward deviations. When unset, no minimum is enforced.
model_bounds_overrideRestricts which predicted bound the monitor alerts on. UPPER_ONLY alerts only when
the measure rises above the upper bound, LOWER_ONLY only when it falls below the
lower bound. When unset, the monitor alerts on both.
UPPER_ONLY, LOWER_ONLYmodel_type_overrideOverride for the model type used in anomaly detection.
freshness, percentage, anysensitivitySensitivity of the anomaly detection model, expressed as a multiplier on the width
of the predicted bounds. Higher values widen the bounds and produce fewer alerts;
lower values tighten them and produce more alerts. Defaults to 3.0.
source_to_target_configConfiguration for a source to target monitor, which compares the same measure across two data entities and alerts on the difference between them.
diff_type [required]How the difference between the source and target measures is computed.
absolute subtracts the two values, diff_percent expresses the difference
as a percentage of the source value.
absolute, diff_percententity_type [required]Type of the data entities being compared.
source [required]Measure configuration for one side of a source to target comparison.
custom_sqlCustom SQL query used to compute the measure for this entity.
custom_whereCustom WHERE clause applied when computing the measure for this entity.
entity_id [required]Identifier of the data entity to measure.
entity_type [required]Type of the data entity to measure.
group_by_columnsColumns to group results by when computing the measure for this entity.
target [required]Measure configuration for one side of a source to target comparison.
custom_sqlCustom SQL query used to compute the measure for this entity.
custom_whereCustom WHERE clause applied when computing the measure for this entity.
entity_id [required]Identifier of the data entity to measure.
entity_type [required]Type of the data entity to measure.
group_by_columnsColumns to group results by when computing the measure for this entity.
name [required]Name of the query for use in formulas.
schema_versionSchema version for the data quality query.
scopeOptional scoping expression to further filter metrics. Uses metrics filter syntax. This is useful when an entity has been configured to emit metrics with additional tags.
Object 4A formula and functions data jobs query.
job_type [required]The type of job being monitored. Valid values include:
databricks.job, spark.application, airflow.dag,
dbt.job, dbt.model, dbt.test, glue.job.
Custom job types are supported with the custom.ol. prefix.
jobs_query [required]Filter expression used to select the jobs to monitor.
name [required]Name of the query for use in formulas. Must be run_query.
query_dialect [required]Query dialect for data jobs queries. Currently only metric is supported.
Object 5A formula and functions aggregate augmented query. Used to enrich base query results with data from a reference table.
augment_query [required]Augment query for aggregate augmented queries. Can be an events query or a reference table query.
Object 1A formula and functions events query.
compute [required]Compute options.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgintervalA time interval in milliseconds.
metricMeasurable attribute to compute.
nameThe name assigned to this aggregation, when multiple aggregations are defined for a query.
sourceSource reference for composite query payloads.
data_source [required]Data source for event platform-based queries.
rum, ci_pipelines, ci_tests, audit, events, logs, spans, database_queries, network, network_pathgroup_byGroup by options.
facet [required]Event facet.
limitNumber of groups to return.
sortOptions for sorting group by results.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgmetricMetric used for sorting group by results.
orderDirection of sort.
descasc, descsourceSource reference for composite query payloads.
indexesAn array of index names to query in the stream. Omit or use [] to query all indexes at once.
name [required]Name of the query for use in formulas.
searchSearch options.
query [required]Events search string.
<data_source=reference_table>A reference table query for use in aggregate queries.
columnsList of columns to retrieve from the reference table.
aliasOptional alias for the column.
name [required]Name of the column.
data_source [required]Data source for reference table queries.
reference_tablenameName of the query.
query_filterOptional filter expression for the reference table query.
table_name [required]Name of the reference table.
base_query [required]Base query for aggregate queries. Can be an events query or a metrics query.
Object 1A formula and functions events query.
compute [required]Compute options.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgintervalA time interval in milliseconds.
metricMeasurable attribute to compute.
nameThe name assigned to this aggregation, when multiple aggregations are defined for a query.
sourceSource reference for composite query payloads.
data_source [required]Data source for event platform-based queries.
rum, ci_pipelines, ci_tests, audit, events, logs, spans, database_queries, network, network_pathgroup_byGroup by options.
facet [required]Event facet.
limitNumber of groups to return.
sortOptions for sorting group by results.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgmetricMetric used for sorting group by results.
orderDirection of sort.
descasc, descsourceSource reference for composite query payloads.
indexesAn array of index names to query in the stream. Omit or use [] to query all indexes at once.
name [required]Name of the query for use in formulas.
searchSearch options.
query [required]Events search string.
Object 2A formula and functions metrics query for use in aggregate queries.
aggregatorAggregator for metrics queries.
avg, min, max, sum, last, mean, area, l2norm, percentile, stddevShow 1 more
count_uniquedata_source [required]Data source for metrics queries.
metrics, cloud_cost, datadog_usagenameName of the query for use in formulas.
query [required]The metrics query definition.
compute [required]Compute options for the query.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgintervalA time interval in milliseconds.
metricMeasurable attribute to compute.
nameThe name assigned to this aggregation, when multiple aggregations are defined for a query.
sourceSource reference for composite query payloads.
data_source [required]Data source for aggregate augmented queries.
aggregate_augmented_querygroup_by [required]Group by options for the query.
facet [required]Event facet.
limitNumber of groups to return.
sortOptions for sorting group by results.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgmetricMetric used for sorting group by results.
orderDirection of sort.
descasc, descsourceSource reference for composite query payloads.
join_condition [required]Join condition for aggregate augmented queries.
augment_attribute [required]Attribute from the augment query to join on.
base_attribute [required]Attribute from the base query to join on.
join_type [required]Join type for aggregate query join conditions.
inner, leftnameName of the query for use in formulas.
Object 6A formula and functions aggregate filtered query. Used to filter base query results using data from another source.
base_query [required]Base query for aggregate queries. Can be an events query or a metrics query.
Object 1A formula and functions events query.
compute [required]Compute options.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgintervalA time interval in milliseconds.
metricMeasurable attribute to compute.
nameThe name assigned to this aggregation, when multiple aggregations are defined for a query.
sourceSource reference for composite query payloads.
data_source [required]Data source for event platform-based queries.
rum, ci_pipelines, ci_tests, audit, events, logs, spans, database_queries, network, network_pathgroup_byGroup by options.
facet [required]Event facet.
limitNumber of groups to return.
sortOptions for sorting group by results.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgmetricMetric used for sorting group by results.
orderDirection of sort.
descasc, descsourceSource reference for composite query payloads.
indexesAn array of index names to query in the stream. Omit or use [] to query all indexes at once.
name [required]Name of the query for use in formulas.
searchSearch options.
query [required]Events search string.
Object 2A formula and functions metrics query for use in aggregate queries.
aggregatorAggregator for metrics queries.
avg, min, max, sum, last, mean, area, l2norm, percentile, stddevShow 1 more
count_uniquedata_source [required]Data source for metrics queries.
metrics, cloud_cost, datadog_usagenameName of the query for use in formulas.
query [required]The metrics query definition.
computeCompute options for the query.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgintervalA time interval in milliseconds.
metricMeasurable attribute to compute.
nameThe name assigned to this aggregation, when multiple aggregations are defined for a query.
sourceSource reference for composite query payloads.
data_source [required]Data source for aggregate filtered queries.
aggregate_filtered_queryfilter_query [required]Filter query for aggregate filtered queries. Can be an events query or a reference table query.
Object 1A formula and functions events query.
compute [required]Compute options.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgintervalA time interval in milliseconds.
metricMeasurable attribute to compute.
nameThe name assigned to this aggregation, when multiple aggregations are defined for a query.
sourceSource reference for composite query payloads.
data_source [required]Data source for event platform-based queries.
rum, ci_pipelines, ci_tests, audit, events, logs, spans, database_queries, network, network_pathgroup_byGroup by options.
facet [required]Event facet.
limitNumber of groups to return.
sortOptions for sorting group by results.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgmetricMetric used for sorting group by results.
orderDirection of sort.
descasc, descsourceSource reference for composite query payloads.
indexesAn array of index names to query in the stream. Omit or use [] to query all indexes at once.
name [required]Name of the query for use in formulas.
searchSearch options.
query [required]Events search string.
<data_source=reference_table>A reference table query for use in aggregate queries.
columnsList of columns to retrieve from the reference table.
aliasOptional alias for the column.
name [required]Name of the column.
data_source [required]Data source for reference table queries.
reference_tablenameName of the query.
query_filterOptional filter expression for the reference table query.
table_name [required]Name of the reference table.
filters [required]Filter conditions for the query.
base_attribute [required]Attribute from the base query to filter on.
excludeWhether to exclude matching records instead of including them.
falsefilter_attribute [required]Attribute from the filter query to match against.
group_byGroup by options for the query.
facet [required]Event facet.
limitNumber of groups to return.
sortOptions for sorting group by results.
aggregation [required]Aggregation methods for event platform queries.
count, cardinality, median, pc75, pc90, pc95, pc98, pc99, sum, minShow 2 more
max, avgmetricMetric used for sorting group by results.
orderDirection of sort.
descasc, descsourceSource reference for composite query payloads.
nameName of the query for use in formulas.
overall_stateThe different states your monitor can be in.
Alert, Ignored, No Data, OK, Skipped, Unknown, WarnpriorityInteger from 1 (high) to 5 (low) indicating alert severity.
query [required]The monitor query.
restricted_rolesA list of unique role identifiers to define which roles are allowed to edit the monitor. The unique identifiers for all roles can be pulled from the Roles API and are located in the data.id field. Editing a monitor includes any updates to the monitor configuration, monitor deletion, and muting of the monitor for any amount of time. You can use the Restriction Policies API to manage write authorization for individual monitors by teams and users, in addition to roles.
stateWrapper object with the different monitor states.
groupsDictionary where the keys are groups (comma separated lists of tags) and the values are the list of groups your monitor is broken down on.
<any-key>Monitor state for a single group.
last_nodata_tsLatest timestamp the monitor was in NO_DATA state.
last_notified_tsLatest timestamp of the notification sent for this monitor group.
last_resolved_tsLatest timestamp the monitor group was resolved.
last_triggered_tsLatest timestamp the monitor group triggered.
nameThe name of the monitor.
statusThe different states your monitor can be in.
Alert, Ignored, No Data, OK, Skipped, Unknown, WarntagsTags associated to your monitor.
type [required]The type of the monitor. For more information about type, see the monitor options docs.
composite, event alert, log alert, metric alert, process alert, query alert, rum alert, service check, synthetics alert, trace-analytics alertShow 13 more
slo alert, event-v2 alert, audit alert, ci-pipelines alert, ci-tests alert, error-tracking alert, database-monitoring alert, network-performance alert, cost alert, data-quality alert, network-path alert, data-jobs alert, llm-observability alert{
"assets": [
{
"category": "runbook",
"name": "Monitor Runbook",
"resource_key": "12345",
"resource_type": "string",
"url": "/notebooks/12345"
}
],
"created": "2019-09-19T10:00:00.000Z",
"creator": {
"email": "string",
"handle": "string",
"name": "string"
},
"deleted": "2019-09-19T10:00:00.000Z",
"draft_status": "string",
"id": "integer",
"matching_downtimes": [
{
"end": 1412792983,
"id": 1625,
"scope": [
"env:staging"
],
"start": 1412792983
}
],
"message": "string",
"modified": "2019-09-19T10:00:00.000Z",
"multi": false,
"name": "My monitor",
"options": {
"aggregation": {
"group_by": "host",
"metric": "metrics.name",
"type": "count"
},
"device_ids": [],
"enable_logs_sample": false,
"enable_samples": false,
"escalation_message": "string",
"evaluation_delay": "integer",
"group_retention_duration": "string",
"groupby_simple_monitor": false,
"include_tags": false,
"locked": false,
"min_failure_duration": "integer",
"min_location_failed": "integer",
"new_group_delay": "integer",
"new_host_delay": "integer",
"no_data_timeframe": "integer",
"notification_preset_name": "string",
"notify_audit": false,
"notify_by": [],
"notify_no_data": false,
"on_missing_data": "string",
"renotify_interval": "integer",
"renotify_occurrences": "integer",
"renotify_statuses": [],
"require_full_window": false,
"scheduling_options": {
"custom_schedule": {
"recurrences": [
{
"rrule": "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR",
"start": "2023-08-31T16:30:00",
"timezone": "Europe/Paris"
}
]
},
"evaluation_window": {
"day_starts": "04:00",
"hour_starts": 0,
"month_starts": 1,
"timezone": "Europe/Paris"
}
},
"silenced": {
"<any-key>": "integer"
},
"synthetics_check_id": "string",
"threshold_windows": {
"recovery_window": "string",
"trigger_window": "string"
},
"thresholds": {
"critical": "number",
"critical_query": "formula(\"2 * query1\").rollup(\"avg\").last(\"6mo\")",
"critical_recovery": "number",
"critical_recovery_query": "formula(\"1.5 * query1\").rollup(\"avg\").last(\"3mo\")",
"ok": "number",
"unknown": "number",
"warning": "number",
"warning_recovery": "number"
},
"timeout_h": "integer",
"variables": [
{
"compute": {
"aggregation": "avg",
"interval": 60000,
"metric": "@duration",
"name": "compute_result",
"source": "filter_query"
},
"data_source": "rum",
"group_by": [
{
"facet": "status",
"limit": 10,
"sort": {
"aggregation": "avg",
"metric": "string",
"order": "asc"
},
"source": "filter_query"
}
],
"indexes": [
"days-3",
"days-7"
],
"name": "query_errors",
"search": {
"query": "service:query"
}
}
]
},
"overall_state": "string",
"priority": "integer",
"query": "avg(last_5m):sum:system.net.bytes_rcvd{host:host0} > 100",
"restricted_roles": [],
"state": {
"groups": {
"<any-key>": {
"last_nodata_ts": "integer",
"last_notified_ts": "integer",
"last_resolved_ts": "integer",
"last_triggered_ts": "integer",
"name": "string",
"status": "string"
}
}
},
"tags": [],
"type": "query alert"
}Bad Request
Error response object.
errors [required]Array of errors returned by the API.
{
"errors": [
"Bad Request"
]
}Forbidden
Error response object.
errors [required]Array of errors returned by the API.
{
"errors": [
"Bad Request"
]
}Too many requests
Error response object.
errors [required]Array of errors returned by the API.
{
"errors": [
"Bad Request"
]
}Exemple de code
Create a Cost Monitor 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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example Monitor",
"type": "cost alert",
"query": "formula(\"exclude_null(query1)\").last(\"7d\").anomaly(direction=\"above\", threshold=10) >= 5",
"message": "some message Notify: @hipchat-channel",
"tags": [
"test:examplemonitor",
"env:ci"
],
"priority": 3,
"options": {
"thresholds": {
"critical": 5,
"warning": 3
},
"variables": [
{
"data_source": "cloud_cost",
"query": "sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)",
"name": "query1",
"aggregator": "sum"
}
],
"include_tags": true
}
}
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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example Monitor",
"type": "cost alert",
"query": "formula(\"exclude_null(query1)\").last(\"7d\").anomaly(direction=\"above\", threshold=10) >= 5",
"message": "some message Notify: @hipchat-channel",
"tags": [
"test:examplemonitor",
"env:ci"
],
"priority": 3,
"options": {
"thresholds": {
"critical": 5,
"warning": 3
},
"variables": [
{
"data_source": "cloud_cost",
"query": "sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)",
"name": "query1",
"aggregator": "sum"
}
],
"include_tags": true
}
}
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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example Monitor",
"type": "cost alert",
"query": "formula(\"exclude_null(query1)\").last(\"7d\").anomaly(direction=\"above\", threshold=10) >= 5",
"message": "some message Notify: @hipchat-channel",
"tags": [
"test:examplemonitor",
"env:ci"
],
"priority": 3,
"options": {
"thresholds": {
"critical": 5,
"warning": 3
},
"variables": [
{
"data_source": "cloud_cost",
"query": "sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)",
"name": "query1",
"aggregator": "sum"
}
],
"include_tags": true
}
}
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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example Monitor",
"type": "cost alert",
"query": "formula(\"exclude_null(query1)\").last(\"7d\").anomaly(direction=\"above\", threshold=10) >= 5",
"message": "some message Notify: @hipchat-channel",
"tags": [
"test:examplemonitor",
"env:ci"
],
"priority": 3,
"options": {
"thresholds": {
"critical": 5,
"warning": 3
},
"variables": [
{
"data_source": "cloud_cost",
"query": "sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)",
"name": "query1",
"aggregator": "sum"
}
],
"include_tags": true
}
}
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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example Monitor",
"type": "cost alert",
"query": "formula(\"exclude_null(query1)\").last(\"7d\").anomaly(direction=\"above\", threshold=10) >= 5",
"message": "some message Notify: @hipchat-channel",
"tags": [
"test:examplemonitor",
"env:ci"
],
"priority": 3,
"options": {
"thresholds": {
"critical": 5,
"warning": 3
},
"variables": [
{
"data_source": "cloud_cost",
"query": "sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)",
"name": "query1",
"aggregator": "sum"
}
],
"include_tags": true
}
}
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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example Monitor",
"type": "cost alert",
"query": "formula(\"exclude_null(query1)\").last(\"7d\").anomaly(direction=\"above\", threshold=10) >= 5",
"message": "some message Notify: @hipchat-channel",
"tags": [
"test:examplemonitor",
"env:ci"
],
"priority": 3,
"options": {
"thresholds": {
"critical": 5,
"warning": 3
},
"variables": [
{
"data_source": "cloud_cost",
"query": "sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)",
"name": "query1",
"aggregator": "sum"
}
],
"include_tags": true
}
}
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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example Monitor",
"type": "cost alert",
"query": "formula(\"exclude_null(query1)\").last(\"7d\").anomaly(direction=\"above\", threshold=10) >= 5",
"message": "some message Notify: @hipchat-channel",
"tags": [
"test:examplemonitor",
"env:ci"
],
"priority": 3,
"options": {
"thresholds": {
"critical": 5,
"warning": 3
},
"variables": [
{
"data_source": "cloud_cost",
"query": "sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)",
"name": "query1",
"aggregator": "sum"
}
],
"include_tags": true
}
}
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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example Monitor",
"type": "cost alert",
"query": "formula(\"exclude_null(query1)\").last(\"7d\").anomaly(direction=\"above\", threshold=10) >= 5",
"message": "some message Notify: @hipchat-channel",
"tags": [
"test:examplemonitor",
"env:ci"
],
"priority": 3,
"options": {
"thresholds": {
"critical": 5,
"warning": 3
},
"variables": [
{
"data_source": "cloud_cost",
"query": "sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)",
"name": "query1",
"aggregator": "sum"
}
],
"include_tags": true
}
}
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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example Monitor",
"type": "cost alert",
"query": "formula(\"exclude_null(query1)\").last(\"7d\").anomaly(direction=\"above\", threshold=10) >= 5",
"message": "some message Notify: @hipchat-channel",
"tags": [
"test:examplemonitor",
"env:ci"
],
"priority": 3,
"options": {
"thresholds": {
"critical": 5,
"warning": 3
},
"variables": [
{
"data_source": "cloud_cost",
"query": "sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)",
"name": "query1",
"aggregator": "sum"
}
],
"include_tags": true
}
}
EOFCreate a Data Jobs monitor 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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example-Monitor",
"type": "data-jobs alert",
"query": "formula(\"failed_runs(run_query)\").by(job_name,workspace_name).last(10d) > 0",
"message": "Data jobs alert triggered",
"tags": [
"test:examplemonitor",
"env:ci"
],
"options": {
"thresholds": {
"critical": 0
},
"variables": [
{
"name": "run_query",
"jobs_query": "job_name:*",
"job_type": "databricks.job",
"query_dialect": "metric"
}
]
}
}
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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example-Monitor",
"type": "data-jobs alert",
"query": "formula(\"failed_runs(run_query)\").by(job_name,workspace_name).last(10d) > 0",
"message": "Data jobs alert triggered",
"tags": [
"test:examplemonitor",
"env:ci"
],
"options": {
"thresholds": {
"critical": 0
},
"variables": [
{
"name": "run_query",
"jobs_query": "job_name:*",
"job_type": "databricks.job",
"query_dialect": "metric"
}
]
}
}
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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example-Monitor",
"type": "data-jobs alert",
"query": "formula(\"failed_runs(run_query)\").by(job_name,workspace_name).last(10d) > 0",
"message": "Data jobs alert triggered",
"tags": [
"test:examplemonitor",
"env:ci"
],
"options": {
"thresholds": {
"critical": 0
},
"variables": [
{
"name": "run_query",
"jobs_query": "job_name:*",
"job_type": "databricks.job",
"query_dialect": "metric"
}
]
}
}
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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example-Monitor",
"type": "data-jobs alert",
"query": "formula(\"failed_runs(run_query)\").by(job_name,workspace_name).last(10d) > 0",
"message": "Data jobs alert triggered",
"tags": [
"test:examplemonitor",
"env:ci"
],
"options": {
"thresholds": {
"critical": 0
},
"variables": [
{
"name": "run_query",
"jobs_query": "job_name:*",
"job_type": "databricks.job",
"query_dialect": "metric"
}
]
}
}
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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example-Monitor",
"type": "data-jobs alert",
"query": "formula(\"failed_runs(run_query)\").by(job_name,workspace_name).last(10d) > 0",
"message": "Data jobs alert triggered",
"tags": [
"test:examplemonitor",
"env:ci"
],
"options": {
"thresholds": {
"critical": 0
},
"variables": [
{
"name": "run_query",
"jobs_query": "job_name:*",
"job_type": "databricks.job",
"query_dialect": "metric"
}
]
}
}
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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example-Monitor",
"type": "data-jobs alert",
"query": "formula(\"failed_runs(run_query)\").by(job_name,workspace_name).last(10d) > 0",
"message": "Data jobs alert triggered",
"tags": [
"test:examplemonitor",
"env:ci"
],
"options": {
"thresholds": {
"critical": 0
},
"variables": [
{
"name": "run_query",
"jobs_query": "job_name:*",
"job_type": "databricks.job",
"query_dialect": "metric"
}
]
}
}
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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example-Monitor",
"type": "data-jobs alert",
"query": "formula(\"failed_runs(run_query)\").by(job_name,workspace_name).last(10d) > 0",
"message": "Data jobs alert triggered",
"tags": [
"test:examplemonitor",
"env:ci"
],
"options": {
"thresholds": {
"critical": 0
},
"variables": [
{
"name": "run_query",
"jobs_query": "job_name:*",
"job_type": "databricks.job",
"query_dialect": "metric"
}
]
}
}
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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example-Monitor",
"type": "data-jobs alert",
"query": "formula(\"failed_runs(run_query)\").by(job_name,workspace_name).last(10d) > 0",
"message": "Data jobs alert triggered",
"tags": [
"test:examplemonitor",
"env:ci"
],
"options": {
"thresholds": {
"critical": 0
},
"variables": [
{
"name": "run_query",
"jobs_query": "job_name:*",
"job_type": "databricks.job",
"query_dialect": "metric"
}
]
}
}
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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example-Monitor",
"type": "data-jobs alert",
"query": "formula(\"failed_runs(run_query)\").by(job_name,workspace_name).last(10d) > 0",
"message": "Data jobs alert triggered",
"tags": [
"test:examplemonitor",
"env:ci"
],
"options": {
"thresholds": {
"critical": 0
},
"variables": [
{
"name": "run_query",
"jobs_query": "job_name:*",
"job_type": "databricks.job",
"query_dialect": "metric"
}
]
}
}
EOFCreate a Data Quality monitor 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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example-Monitor",
"type": "data-quality alert",
"query": "formula(\"query1\").last(\"5m\") > 100",
"message": "Data quality alert triggered",
"tags": [
"test:examplemonitor",
"env:ci"
],
"priority": 3,
"options": {
"thresholds": {
"critical": 100
},
"variables": [
{
"name": "query1",
"data_source": "data_quality_metrics",
"measure": "row_count",
"filter": "search for column where `database:production AND table:users`",
"group_by": [
"entity_id"
]
}
]
}
}
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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example-Monitor",
"type": "data-quality alert",
"query": "formula(\"query1\").last(\"5m\") > 100",
"message": "Data quality alert triggered",
"tags": [
"test:examplemonitor",
"env:ci"
],
"priority": 3,
"options": {
"thresholds": {
"critical": 100
},
"variables": [
{
"name": "query1",
"data_source": "data_quality_metrics",
"measure": "row_count",
"filter": "search for column where `database:production AND table:users`",
"group_by": [
"entity_id"
]
}
]
}
}
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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example-Monitor",
"type": "data-quality alert",
"query": "formula(\"query1\").last(\"5m\") > 100",
"message": "Data quality alert triggered",
"tags": [
"test:examplemonitor",
"env:ci"
],
"priority": 3,
"options": {
"thresholds": {
"critical": 100
},
"variables": [
{
"name": "query1",
"data_source": "data_quality_metrics",
"measure": "row_count",
"filter": "search for column where `database:production AND table:users`",
"group_by": [
"entity_id"
]
}
]
}
}
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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example-Monitor",
"type": "data-quality alert",
"query": "formula(\"query1\").last(\"5m\") > 100",
"message": "Data quality alert triggered",
"tags": [
"test:examplemonitor",
"env:ci"
],
"priority": 3,
"options": {
"thresholds": {
"critical": 100
},
"variables": [
{
"name": "query1",
"data_source": "data_quality_metrics",
"measure": "row_count",
"filter": "search for column where `database:production AND table:users`",
"group_by": [
"entity_id"
]
}
]
}
}
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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example-Monitor",
"type": "data-quality alert",
"query": "formula(\"query1\").last(\"5m\") > 100",
"message": "Data quality alert triggered",
"tags": [
"test:examplemonitor",
"env:ci"
],
"priority": 3,
"options": {
"thresholds": {
"critical": 100
},
"variables": [
{
"name": "query1",
"data_source": "data_quality_metrics",
"measure": "row_count",
"filter": "search for column where `database:production AND table:users`",
"group_by": [
"entity_id"
]
}
]
}
}
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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example-Monitor",
"type": "data-quality alert",
"query": "formula(\"query1\").last(\"5m\") > 100",
"message": "Data quality alert triggered",
"tags": [
"test:examplemonitor",
"env:ci"
],
"priority": 3,
"options": {
"thresholds": {
"critical": 100
},
"variables": [
{
"name": "query1",
"data_source": "data_quality_metrics",
"measure": "row_count",
"filter": "search for column where `database:production AND table:users`",
"group_by": [
"entity_id"
]
}
]
}
}
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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example-Monitor",
"type": "data-quality alert",
"query": "formula(\"query1\").last(\"5m\") > 100",
"message": "Data quality alert triggered",
"tags": [
"test:examplemonitor",
"env:ci"
],
"priority": 3,
"options": {
"thresholds": {
"critical": 100
},
"variables": [
{
"name": "query1",
"data_source": "data_quality_metrics",
"measure": "row_count",
"filter": "search for column where `database:production AND table:users`",
"group_by": [
"entity_id"
]
}
]
}
}
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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example-Monitor",
"type": "data-quality alert",
"query": "formula(\"query1\").last(\"5m\") > 100",
"message": "Data quality alert triggered",
"tags": [
"test:examplemonitor",
"env:ci"
],
"priority": 3,
"options": {
"thresholds": {
"critical": 100
},
"variables": [
{
"name": "query1",
"data_source": "data_quality_metrics",
"measure": "row_count",
"filter": "search for column where `database:production AND table:users`",
"group_by": [
"entity_id"
]
}
]
}
}
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/v1/monitor" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"name": "Example-Monitor",
"type": "data-quality alert",
"query": "formula(\"query1\").last(\"5m\") > 100",
"message": "Data quality alert triggered",
"tags": [
"test:examplemonitor",
"env:ci"
],
"priority": 3,
"options": {
"thresholds": {
"critical": 100
},
"variables": [
{
"name": "query1",
"data_source": "data_quality_metrics",
"measure": "row_count",
"filter": "search for column where `database:production AND table:users`",
"group_by": [
"entity_id"
]
}
]
}
}
EOFCreate a Cost Monitor returns "OK" response
// Create a Cost Monitor 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/datadogV1"
)
func main() {
body := datadogV1.Monitor{
Name: datadog.PtrString("Example Monitor"),
Type: datadogV1.MONITORTYPE_COST_ALERT,
Query: `formula("exclude_null(query1)").last("7d").anomaly(direction="above", threshold=10) >= 5`,
Message: datadog.PtrString("some message Notify: @hipchat-channel"),
Tags: []string{
"test:examplemonitor",
"env:ci",
},
Priority: *datadog.NewNullableInt64(datadog.PtrInt64(3)),
Options: &datadogV1.MonitorOptions{
Thresholds: &datadogV1.MonitorThresholds{
Critical: datadog.PtrFloat64(5),
Warning: *datadog.NewNullableFloat64(datadog.PtrFloat64(3)),
},
Variables: []datadogV1.MonitorFormulaAndFunctionQueryDefinition{
datadogV1.MonitorFormulaAndFunctionQueryDefinition{
MonitorFormulaAndFunctionCostQueryDefinition: &datadogV1.MonitorFormulaAndFunctionCostQueryDefinition{
DataSource: datadogV1.MONITORFORMULAANDFUNCTIONCOSTDATASOURCE_CLOUD_COST,
Query: "sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)",
Name: "query1",
Aggregator: datadogV1.MONITORFORMULAANDFUNCTIONCOSTAGGREGATOR_SUM.Ptr(),
}},
},
IncludeTags: datadog.PtrBool(true),
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewMonitorsApi(apiClient)
resp, r, err := api.CreateMonitor(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `MonitorsApi.CreateMonitor`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `MonitorsApi.CreateMonitor`:\n%s\n", responseContent)
}
Create a Data Jobs monitor returns "OK" response
// Create a Data Jobs monitor 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/datadogV1"
)
func main() {
body := datadogV1.Monitor{
Name: datadog.PtrString("Example-Monitor"),
Type: datadogV1.MONITORTYPE_DATA_JOBS_ALERT,
Query: `formula("failed_runs(run_query)").by(job_name,workspace_name).last(10d) > 0`,
Message: datadog.PtrString("Data jobs alert triggered"),
Tags: []string{
"test:examplemonitor",
"env:ci",
},
Options: &datadogV1.MonitorOptions{
Thresholds: &datadogV1.MonitorThresholds{
Critical: datadog.PtrFloat64(0),
},
Variables: []datadogV1.MonitorFormulaAndFunctionQueryDefinition{
datadogV1.MonitorFormulaAndFunctionQueryDefinition{
MonitorFormulaAndFunctionDataJobsQueryDefinition: &datadogV1.MonitorFormulaAndFunctionDataJobsQueryDefinition{
Name: "run_query",
JobsQuery: "job_name:*",
JobType: "databricks.job",
QueryDialect: "metric",
}},
},
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewMonitorsApi(apiClient)
resp, r, err := api.CreateMonitor(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `MonitorsApi.CreateMonitor`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `MonitorsApi.CreateMonitor`:\n%s\n", responseContent)
}
Create a Data Quality monitor returns "OK" response
// Create a Data Quality monitor 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/datadogV1"
)
func main() {
body := datadogV1.Monitor{
Name: datadog.PtrString("Example-Monitor"),
Type: datadogV1.MONITORTYPE_DATA_QUALITY_ALERT,
Query: `formula("query1").last("5m") > 100`,
Message: datadog.PtrString("Data quality alert triggered"),
Tags: []string{
"test:examplemonitor",
"env:ci",
},
Priority: *datadog.NewNullableInt64(datadog.PtrInt64(3)),
Options: &datadogV1.MonitorOptions{
Thresholds: &datadogV1.MonitorThresholds{
Critical: datadog.PtrFloat64(100),
},
Variables: []datadogV1.MonitorFormulaAndFunctionQueryDefinition{
datadogV1.MonitorFormulaAndFunctionQueryDefinition{
MonitorFormulaAndFunctionDataQualityQueryDefinition: &datadogV1.MonitorFormulaAndFunctionDataQualityQueryDefinition{
Name: "query1",
DataSource: datadogV1.MONITORFORMULAANDFUNCTIONDATAQUALITYDATASOURCE_DATA_QUALITY_METRICS,
Measure: "row_count",
Filter: `search for column where ` + "`" + `database:production AND table:users` + "`",
GroupBy: []string{
"entity_id",
},
}},
},
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewMonitorsApi(apiClient)
resp, r, err := api.CreateMonitor(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `MonitorsApi.CreateMonitor`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `MonitorsApi.CreateMonitor`:\n%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"Create a Cost Monitor returns "OK" response
// Create a Cost Monitor returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.MonitorsApi;
import com.datadog.api.client.v1.model.Monitor;
import com.datadog.api.client.v1.model.MonitorFormulaAndFunctionCostAggregator;
import com.datadog.api.client.v1.model.MonitorFormulaAndFunctionCostDataSource;
import com.datadog.api.client.v1.model.MonitorFormulaAndFunctionCostQueryDefinition;
import com.datadog.api.client.v1.model.MonitorFormulaAndFunctionQueryDefinition;
import com.datadog.api.client.v1.model.MonitorOptions;
import com.datadog.api.client.v1.model.MonitorThresholds;
import com.datadog.api.client.v1.model.MonitorType;
import java.util.Arrays;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
MonitorsApi apiInstance = new MonitorsApi(defaultClient);
Monitor body =
new Monitor()
.name("Example Monitor")
.type(MonitorType.COST_ALERT)
.query(
"""
formula("exclude_null(query1)").last("7d").anomaly(direction="above", threshold=10) >= 5
""")
.message("some message Notify: @hipchat-channel")
.tags(Arrays.asList("test:examplemonitor", "env:ci"))
.priority(3L)
.options(
new MonitorOptions()
.thresholds(new MonitorThresholds().critical(5.0).warning(3.0))
.variables(
Collections.singletonList(
new MonitorFormulaAndFunctionQueryDefinition(
new MonitorFormulaAndFunctionCostQueryDefinition()
.dataSource(MonitorFormulaAndFunctionCostDataSource.CLOUD_COST)
.query(
"sum:aws.cost.net.amortized.shared.resources.allocated{aws_product"
+ " IN (amplify ,athena, backup, bedrock ) } by"
+ " {aws_product}.rollup(sum, 86400)")
.name("query1")
.aggregator(MonitorFormulaAndFunctionCostAggregator.SUM))))
.includeTags(true));
try {
Monitor result = apiInstance.createMonitor(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MonitorsApi#createMonitor");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Create a Data Jobs monitor returns "OK" response
// Create a Data Jobs monitor returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.MonitorsApi;
import com.datadog.api.client.v1.model.Monitor;
import com.datadog.api.client.v1.model.MonitorFormulaAndFunctionDataJobsQueryDefinition;
import com.datadog.api.client.v1.model.MonitorFormulaAndFunctionQueryDefinition;
import com.datadog.api.client.v1.model.MonitorOptions;
import com.datadog.api.client.v1.model.MonitorThresholds;
import com.datadog.api.client.v1.model.MonitorType;
import java.util.Arrays;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
MonitorsApi apiInstance = new MonitorsApi(defaultClient);
Monitor body =
new Monitor()
.name("Example-Monitor")
.type(MonitorType.DATA_JOBS_ALERT)
.query(
"""
formula("failed_runs(run_query)").by(job_name,workspace_name).last(10d) > 0
""")
.message("Data jobs alert triggered")
.tags(Arrays.asList("test:examplemonitor", "env:ci"))
.options(
new MonitorOptions()
.thresholds(new MonitorThresholds())
.variables(
Collections.singletonList(
new MonitorFormulaAndFunctionQueryDefinition(
new MonitorFormulaAndFunctionDataJobsQueryDefinition()
.name("run_query")
.jobsQuery("job_name:*")
.jobType("databricks.job")
.queryDialect("metric")))));
try {
Monitor result = apiInstance.createMonitor(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MonitorsApi#createMonitor");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Create a Data Quality monitor returns "OK" response
// Create a Data Quality monitor returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.MonitorsApi;
import com.datadog.api.client.v1.model.Monitor;
import com.datadog.api.client.v1.model.MonitorFormulaAndFunctionDataQualityDataSource;
import com.datadog.api.client.v1.model.MonitorFormulaAndFunctionDataQualityQueryDefinition;
import com.datadog.api.client.v1.model.MonitorFormulaAndFunctionQueryDefinition;
import com.datadog.api.client.v1.model.MonitorOptions;
import com.datadog.api.client.v1.model.MonitorThresholds;
import com.datadog.api.client.v1.model.MonitorType;
import java.util.Arrays;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
MonitorsApi apiInstance = new MonitorsApi(defaultClient);
Monitor body =
new Monitor()
.name("Example-Monitor")
.type(MonitorType.DATA_QUALITY_ALERT)
.query("""
formula("query1").last("5m") > 100
""")
.message("Data quality alert triggered")
.tags(Arrays.asList("test:examplemonitor", "env:ci"))
.priority(3L)
.options(
new MonitorOptions()
.thresholds(new MonitorThresholds().critical(100.0))
.variables(
Collections.singletonList(
new MonitorFormulaAndFunctionQueryDefinition(
new MonitorFormulaAndFunctionDataQualityQueryDefinition()
.name("query1")
.dataSource(
MonitorFormulaAndFunctionDataQualityDataSource
.DATA_QUALITY_METRICS)
.measure("row_count")
.filter(
"search for column where `database:production AND"
+ " table:users`")
.groupBy(Collections.singletonList("entity_id"))))));
try {
Monitor result = apiInstance.createMonitor(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MonitorsApi#createMonitor");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
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"Create a Cost Monitor returns "OK" response
"""
Create a Cost Monitor returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.monitors_api import MonitorsApi
from datadog_api_client.v1.model.monitor import Monitor
from datadog_api_client.v1.model.monitor_formula_and_function_cost_aggregator import (
MonitorFormulaAndFunctionCostAggregator,
)
from datadog_api_client.v1.model.monitor_formula_and_function_cost_data_source import (
MonitorFormulaAndFunctionCostDataSource,
)
from datadog_api_client.v1.model.monitor_formula_and_function_cost_query_definition import (
MonitorFormulaAndFunctionCostQueryDefinition,
)
from datadog_api_client.v1.model.monitor_options import MonitorOptions
from datadog_api_client.v1.model.monitor_thresholds import MonitorThresholds
from datadog_api_client.v1.model.monitor_type import MonitorType
body = Monitor(
name="Example Monitor",
type=MonitorType.COST_ALERT,
query='formula("exclude_null(query1)").last("7d").anomaly(direction="above", threshold=10) >= 5',
message="some message Notify: @hipchat-channel",
tags=[
"test:examplemonitor",
"env:ci",
],
priority=3,
options=MonitorOptions(
thresholds=MonitorThresholds(
critical=5.0,
warning=3.0,
),
variables=[
MonitorFormulaAndFunctionCostQueryDefinition(
data_source=MonitorFormulaAndFunctionCostDataSource.CLOUD_COST,
query="sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)",
name="query1",
aggregator=MonitorFormulaAndFunctionCostAggregator.SUM,
),
],
include_tags=True,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = MonitorsApi(api_client)
response = api_instance.create_monitor(body=body)
print(response)
Create a Data Jobs monitor returns "OK" response
"""
Create a Data Jobs monitor returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.monitors_api import MonitorsApi
from datadog_api_client.v1.model.monitor import Monitor
from datadog_api_client.v1.model.monitor_formula_and_function_data_jobs_query_definition import (
MonitorFormulaAndFunctionDataJobsQueryDefinition,
)
from datadog_api_client.v1.model.monitor_options import MonitorOptions
from datadog_api_client.v1.model.monitor_thresholds import MonitorThresholds
from datadog_api_client.v1.model.monitor_type import MonitorType
body = Monitor(
name="Example-Monitor",
type=MonitorType.DATA_JOBS_ALERT,
query='formula("failed_runs(run_query)").by(job_name,workspace_name).last(10d) > 0',
message="Data jobs alert triggered",
tags=[
"test:examplemonitor",
"env:ci",
],
options=MonitorOptions(
thresholds=MonitorThresholds(
critical=0.0,
),
variables=[
MonitorFormulaAndFunctionDataJobsQueryDefinition(
name="run_query",
jobs_query="job_name:*",
job_type="databricks.job",
query_dialect="metric",
),
],
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = MonitorsApi(api_client)
response = api_instance.create_monitor(body=body)
print(response)
Create a Data Quality monitor returns "OK" response
"""
Create a Data Quality monitor returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.monitors_api import MonitorsApi
from datadog_api_client.v1.model.monitor import Monitor
from datadog_api_client.v1.model.monitor_formula_and_function_data_quality_data_source import (
MonitorFormulaAndFunctionDataQualityDataSource,
)
from datadog_api_client.v1.model.monitor_formula_and_function_data_quality_query_definition import (
MonitorFormulaAndFunctionDataQualityQueryDefinition,
)
from datadog_api_client.v1.model.monitor_options import MonitorOptions
from datadog_api_client.v1.model.monitor_thresholds import MonitorThresholds
from datadog_api_client.v1.model.monitor_type import MonitorType
body = Monitor(
name="Example-Monitor",
type=MonitorType.DATA_QUALITY_ALERT,
query='formula("query1").last("5m") > 100',
message="Data quality alert triggered",
tags=[
"test:examplemonitor",
"env:ci",
],
priority=3,
options=MonitorOptions(
thresholds=MonitorThresholds(
critical=100.0,
),
variables=[
MonitorFormulaAndFunctionDataQualityQueryDefinition(
name="query1",
data_source=MonitorFormulaAndFunctionDataQualityDataSource.DATA_QUALITY_METRICS,
measure="row_count",
filter="search for column where `database:production AND table:users`",
group_by=[
"entity_id",
],
),
],
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = MonitorsApi(api_client)
response = api_instance.create_monitor(body=body)
print(response)
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"Create a Cost Monitor returns "OK" response
# Create a Cost Monitor returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V1::MonitorsAPI.new
body = DatadogAPIClient::V1::Monitor.new({
name: "Example Monitor",
type: DatadogAPIClient::V1::MonitorType::COST_ALERT,
query: 'formula("exclude_null(query1)").last("7d").anomaly(direction="above", threshold=10) >= 5',
message: "some message Notify: @hipchat-channel",
tags: [
"test:examplemonitor",
"env:ci",
],
priority: 3,
options: DatadogAPIClient::V1::MonitorOptions.new({
thresholds: DatadogAPIClient::V1::MonitorThresholds.new({
critical: 5,
warning: 3,
}),
variables: [
DatadogAPIClient::V1::MonitorFormulaAndFunctionCostQueryDefinition.new({
data_source: DatadogAPIClient::V1::MonitorFormulaAndFunctionCostDataSource::CLOUD_COST,
query: "sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)",
name: "query1",
aggregator: DatadogAPIClient::V1::MonitorFormulaAndFunctionCostAggregator::SUM,
}),
],
include_tags: true,
}),
})
p api_instance.create_monitor(body)
Create a Data Jobs monitor returns "OK" response
# Create a Data Jobs monitor returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V1::MonitorsAPI.new
body = DatadogAPIClient::V1::Monitor.new({
name: "Example-Monitor",
type: DatadogAPIClient::V1::MonitorType::DATA_JOBS_ALERT,
query: 'formula("failed_runs(run_query)").by(job_name,workspace_name).last(10d) > 0',
message: "Data jobs alert triggered",
tags: [
"test:examplemonitor",
"env:ci",
],
options: DatadogAPIClient::V1::MonitorOptions.new({
thresholds: DatadogAPIClient::V1::MonitorThresholds.new({
critical: 0,
}),
variables: [
DatadogAPIClient::V1::MonitorFormulaAndFunctionDataJobsQueryDefinition.new({
name: "run_query",
jobs_query: "job_name:*",
job_type: "databricks.job",
query_dialect: "metric",
}),
],
}),
})
p api_instance.create_monitor(body)
Create a Data Quality monitor returns "OK" response
# Create a Data Quality monitor returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V1::MonitorsAPI.new
body = DatadogAPIClient::V1::Monitor.new({
name: "Example-Monitor",
type: DatadogAPIClient::V1::MonitorType::DATA_QUALITY_ALERT,
query: 'formula("query1").last("5m") > 100',
message: "Data quality alert triggered",
tags: [
"test:examplemonitor",
"env:ci",
],
priority: 3,
options: DatadogAPIClient::V1::MonitorOptions.new({
thresholds: DatadogAPIClient::V1::MonitorThresholds.new({
critical: 100,
}),
variables: [
DatadogAPIClient::V1::MonitorFormulaAndFunctionDataQualityQueryDefinition.new({
name: "query1",
data_source: DatadogAPIClient::V1::MonitorFormulaAndFunctionDataQualityDataSource::DATA_QUALITY_METRICS,
measure: "row_count",
filter: "search for column where `database:production AND table:users`",
group_by: [
"entity_id",
],
}),
],
}),
})
p api_instance.create_monitor(body)
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"Create a Cost Monitor returns "OK" response
// Create a Cost Monitor returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_monitors::MonitorsAPI;
use datadog_api_client::datadogV1::model::Monitor;
use datadog_api_client::datadogV1::model::MonitorFormulaAndFunctionCostAggregator;
use datadog_api_client::datadogV1::model::MonitorFormulaAndFunctionCostDataSource;
use datadog_api_client::datadogV1::model::MonitorFormulaAndFunctionCostQueryDefinition;
use datadog_api_client::datadogV1::model::MonitorFormulaAndFunctionQueryDefinition;
use datadog_api_client::datadogV1::model::MonitorOptions;
use datadog_api_client::datadogV1::model::MonitorThresholds;
use datadog_api_client::datadogV1::model::MonitorType;
#[tokio::main]
async fn main() {
let body =
Monitor::new(
r#"formula("exclude_null(query1)").last("7d").anomaly(direction="above", threshold=10) >= 5"#.to_string(),
MonitorType::COST_ALERT,
)
.message("some message Notify: @hipchat-channel".to_string())
.name("Example Monitor".to_string())
.options(
MonitorOptions::new()
.include_tags(true)
.thresholds(MonitorThresholds::new().critical(5.0 as f64).warning(Some(3.0 as f64)))
.variables(
vec![
MonitorFormulaAndFunctionQueryDefinition::MonitorFormulaAndFunctionCostQueryDefinition(
Box::new(
MonitorFormulaAndFunctionCostQueryDefinition::new(
MonitorFormulaAndFunctionCostDataSource::CLOUD_COST,
"query1".to_string(),
"sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)".to_string(),
).aggregator(MonitorFormulaAndFunctionCostAggregator::SUM),
),
)
],
),
)
.priority(Some(3))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Create a Data Jobs monitor returns "OK" response
// Create a Data Jobs monitor returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_monitors::MonitorsAPI;
use datadog_api_client::datadogV1::model::Monitor;
use datadog_api_client::datadogV1::model::MonitorFormulaAndFunctionDataJobsQueryDefinition;
use datadog_api_client::datadogV1::model::MonitorFormulaAndFunctionQueryDefinition;
use datadog_api_client::datadogV1::model::MonitorOptions;
use datadog_api_client::datadogV1::model::MonitorThresholds;
use datadog_api_client::datadogV1::model::MonitorType;
#[tokio::main]
async fn main() {
let body =
Monitor::new(
r#"formula("failed_runs(run_query)").by(job_name,workspace_name).last(10d) > 0"#.to_string(),
MonitorType::DATA_JOBS_ALERT,
)
.message("Data jobs alert triggered".to_string())
.name("Example-Monitor".to_string())
.options(
MonitorOptions::new()
.thresholds(MonitorThresholds::new().critical(0.0 as f64))
.variables(
vec![
MonitorFormulaAndFunctionQueryDefinition::MonitorFormulaAndFunctionDataJobsQueryDefinition(
Box::new(
MonitorFormulaAndFunctionDataJobsQueryDefinition::new(
"databricks.job".to_string(),
"job_name:*".to_string(),
"run_query".to_string(),
"metric".to_string(),
),
),
)
],
),
)
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Create a Data Quality monitor returns "OK" response
// Create a Data Quality monitor returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_monitors::MonitorsAPI;
use datadog_api_client::datadogV1::model::Monitor;
use datadog_api_client::datadogV1::model::MonitorFormulaAndFunctionDataQualityDataSource;
use datadog_api_client::datadogV1::model::MonitorFormulaAndFunctionDataQualityQueryDefinition;
use datadog_api_client::datadogV1::model::MonitorFormulaAndFunctionQueryDefinition;
use datadog_api_client::datadogV1::model::MonitorOptions;
use datadog_api_client::datadogV1::model::MonitorThresholds;
use datadog_api_client::datadogV1::model::MonitorType;
#[tokio::main]
async fn main() {
let body =
Monitor::new(r#"formula("query1").last("5m") > 100"#.to_string(), MonitorType::DATA_QUALITY_ALERT)
.message("Data quality alert triggered".to_string())
.name("Example-Monitor".to_string())
.options(
MonitorOptions::new()
.thresholds(MonitorThresholds::new().critical(100.0 as f64))
.variables(
vec![
MonitorFormulaAndFunctionQueryDefinition
::MonitorFormulaAndFunctionDataQualityQueryDefinition(
Box::new(
MonitorFormulaAndFunctionDataQualityQueryDefinition::new(
MonitorFormulaAndFunctionDataQualityDataSource::DATA_QUALITY_METRICS,
r#"search for column where `database:production AND table:users`"#.to_string(),
"row_count".to_string(),
"query1".to_string(),
).group_by(vec!["entity_id".to_string()]),
),
)
],
),
)
.priority(Some(3))
.tags(vec!["test:examplemonitor".to_string(), "env:ci".to_string()]);
let configuration = datadog::Configuration::new();
let api = MonitorsAPI::with_config(configuration);
let resp = api.create_monitor(body).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 runCreate a Cost Monitor returns "OK" response
/**
* Create a Cost Monitor returns "OK" response
*/
import { client, v1 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
const apiInstance = new v1.MonitorsApi(configuration);
const params: v1.MonitorsApiCreateMonitorRequest = {
body: {
name: "Example Monitor",
type: "cost alert",
query: `formula("exclude_null(query1)").last("7d").anomaly(direction="above", threshold=10) >= 5`,
message: "some message Notify: @hipchat-channel",
tags: ["test:examplemonitor", "env:ci"],
priority: 3,
options: {
thresholds: {
critical: 5,
warning: 3,
},
variables: [
{
dataSource: "cloud_cost",
query:
"sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)",
name: "query1",
aggregator: "sum",
},
],
includeTags: true,
},
},
};
apiInstance
.createMonitor(params)
.then((data: v1.Monitor) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Create a Data Jobs monitor returns "OK" response
/**
* Create a Data Jobs monitor returns "OK" response
*/
import { client, v1 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
const apiInstance = new v1.MonitorsApi(configuration);
const params: v1.MonitorsApiCreateMonitorRequest = {
body: {
name: "Example-Monitor",
type: "data-jobs alert",
query: `formula("failed_runs(run_query)").by(job_name,workspace_name).last(10d) > 0`,
message: "Data jobs alert triggered",
tags: ["test:examplemonitor", "env:ci"],
options: {
thresholds: {
critical: 0,
},
variables: [
{
name: "run_query",
jobsQuery: "job_name:*",
jobType: "databricks.job",
queryDialect: "metric",
},
],
},
},
};
apiInstance
.createMonitor(params)
.then((data: v1.Monitor) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Create a Data Quality monitor returns "OK" response
/**
* Create a Data Quality monitor returns "OK" response
*/
import { client, v1 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
const apiInstance = new v1.MonitorsApi(configuration);
const params: v1.MonitorsApiCreateMonitorRequest = {
body: {
name: "Example-Monitor",
type: "data-quality alert",
query: `formula("query1").last("5m") > 100`,
message: "Data quality alert triggered",
tags: ["test:examplemonitor", "env:ci"],
priority: 3,
options: {
thresholds: {
critical: 100,
},
variables: [
{
name: "query1",
dataSource: "data_quality_metrics",
measure: "row_count",
filter:
`search for column where ` +
"`" +
`database:production AND table:users` +
"`",
groupBy: ["entity_id"],
},
],
},
},
};
apiInstance
.createMonitor(params)
.then((data: v1.Monitor) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => 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"from datadog import initialize, api
options = {
'api_key': '<DATADOG_API_KEY>',
'app_key': '<DATADOG_APPLICATION_KEY>'
}
initialize(**options)
# Create a new monitor
monitor_options = {
"notify_no_data": True,
"no_data_timeframe": 20
}
tags = ["app:webserver", "frontend"]
api.Monitor.create(
type="query alert",
query="avg(last_5m):sum:system.net.bytes_rcvd{host:host0} > 100",
name="Bytes received on host0",
message="We may need to add web hosts if this is consistently high.",
tags=tags,
options=monitor_options
)
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_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"DD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"DD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"DD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"DD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"DD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"DD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"DD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"DD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"require 'dogapi'
api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'
dog = Dogapi::Client.new(api_key, app_key)
# Create a new monitor
options = {
'notify_no_data' => true,
'no_data_timeframe' => 20
}
tags = ['app:webserver', 'frontend']
dog.monitor(
'query alert',
'avg(last_5m):sum:system.net.bytes_rcvd{host:host0} > 100',
name: 'Bytes received on host0',
message: 'We may need to add web hosts if this is consistently high.',
tags: tags,
options: options
)
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_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"DD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"DD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"