Skip to main content

metrics

Creates, updates, deletes, gets or lists a metrics resource.

Overview

Namemetrics
TypeResource
Iddatadog.logs.metrics

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringThe name of the log-based metric. (example: logs.page.load.count)
attributesobjectThe object describing a Datadog log-based metric.
typestringThe type of the resource. The value should always be logs_metrics. (default: logs_metrics, example: logs_metrics)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_logs_metricselectmetric_id, regionGet a specific log-based metric from your organization.
list_logs_metricsselectregionGet the list of configured log-based metrics with their definitions.
create_logs_metricinsertregion, data__dataCreate a metric based on your ingested logs in your organization.
Returns the log-based metric object from the request body when the request is successful.
update_logs_metricupdatemetric_id, region, data__dataUpdate a specific log-based metric from your organization.
Returns the log-based metric object from the request body when the request is successful.
delete_logs_metricdeletemetric_id, regionDelete a specific log-based metric from your organization.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
metric_idstringThe name of the log-based metric.
regionstring(default: datadoghq.com)

SELECT examples

Get a specific log-based metric from your organization.

SELECT
id,
attributes,
type
FROM datadog.logs.metrics
WHERE metric_id = '{{ metric_id }}' -- required
AND region = '{{ region }}' -- required
;

INSERT examples

Create a metric based on your ingested logs in your organization.
Returns the log-based metric object from the request body when the request is successful.

INSERT INTO datadog.logs.metrics (
data__data,
region
)
SELECT
'{{ data }}' /* required */,
'{{ region }}'
RETURNING
data
;

UPDATE examples

Update a specific log-based metric from your organization.
Returns the log-based metric object from the request body when the request is successful.

UPDATE datadog.logs.metrics
SET
data__data = '{{ data }}'
WHERE
metric_id = '{{ metric_id }}' --required
AND region = '{{ region }}' --required
AND data__data = '{{ data }}' --required
RETURNING
data;

DELETE examples

Delete a specific log-based metric from your organization.

DELETE FROM datadog.logs.metrics
WHERE metric_id = '{{ metric_id }}' --required
AND region = '{{ region }}' --required
;