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. (logs_metrics) (default: logs_metrics, example: logs_metrics)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_logs_metricselectmetric_idGet a specific log-based metric from your organization.
list_logs_metricsselectGet the list of configured log-based metrics with their definitions.
create_logs_metricinsertdataCreate a metric based on your ingested logs in your organization.<br />Returns the log-based metric object from the request body when the request is successful.
update_logs_metricupdatemetric_id, dataUpdate a specific log-based metric from your organization.<br />Returns the log-based metric object from the request body when the request is successful.
delete_logs_metricdeletemetric_idDelete 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.
sitestringThe Datadog site (region) for your organization, for example datadoghq.com, us3.datadoghq.com, us5.datadoghq.com, ap1.datadoghq.com, ap2.datadoghq.com, datadoghq.eu, ddog-gov.com. Resolved from the DD_SITE environment variable when set. Optional: defaults to datadoghq.com, or the value of the DD_SITE environment variable when set; a WHERE value overrides both.

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
;

INSERT examples

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

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

UPDATE examples

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

UPDATE datadog.logs.metrics
SET
data = '{{ data }}'
WHERE
metric_id = '{{ metric_id }}' --required
AND 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
;