The type of aggregation to use.
Allowed enum values: count,distribution
include_percentiles
boolean
Toggle to include or exclude percentile aggregations for distribution metrics.
Only present when the aggregation_type is distribution.
path
string
The path to the value the log-based metric will aggregate on (only used if the aggregation type is a "distribution").
filter
object
The log-based metric filter. Logs matching this filter will be aggregated in this metric.
query
string
The search query - following the log search syntax.
group_by
[object]
The rules for the group by.
path
string
The path to the value the log-based metric will be aggregated over.
tag_name
string
Eventual name of the tag that gets created. By default, the path attribute is used as the tag name.
id
string
The name of the log-based metric.
type
enum
The type of the resource. The value should always be logs_metrics.
Allowed enum values: logs_metrics
default: logs_metrics
{"data":[{"attributes":{"compute":{"aggregation_type":"distribution","include_percentiles":true,"path":"@duration"},"filter":{"query":"service:web* AND @http.status_code:[200 TO 299]"},"group_by":[{"path":"@http.status_code","tag_name":"status_code"}]},"id":"logs.page.load.count","type":"logs_metrics"}]}
"""
Get all log-based metrics returns "OK" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.logs_metrics_apiimportLogsMetricsApiconfiguration=Configuration()withApiClient(configuration)asapi_client:api_instance=LogsMetricsApi(api_client)response=api_instance.list_logs_metrics()print(response)
# Get all log-based metrics returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::LogsMetricsAPI.newpapi_instance.list_logs_metrics()
// Get all log-based metrics returns "OK" response
packagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewLogsMetricsApi(apiClient)resp,r,err:=api.ListLogsMetrics(ctx)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `LogsMetricsApi.ListLogsMetrics`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `LogsMetricsApi.ListLogsMetrics`:\n%s\n",responseContent)}
// Get all log-based metrics returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_logs_metrics::LogsMetricsAPI;#[tokio::main]asyncfnmain(){letconfiguration=datadog::Configuration::new();letapi=LogsMetricsAPI::with_config(configuration);letresp=api.list_logs_metrics().await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<API-KEY>"DD_APP_KEY="<APP-KEY>"cargo run
/**
* Get all log-based metrics returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.LogsMetricsApi(configuration);apiInstance.listLogsMetrics().then((data: v2.LogsMetricsResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
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.
This endpoint requires the logs_generate_metrics permission.
The type of aggregation to use.
Allowed enum values: count,distribution
include_percentiles
boolean
Toggle to include or exclude percentile aggregations for distribution metrics.
Only present when the aggregation_type is distribution.
path
string
The path to the value the log-based metric will aggregate on (only used if the aggregation type is a "distribution").
filter
object
The log-based metric filter. Logs matching this filter will be aggregated in this metric.
query
string
The search query - following the log search syntax.
group_by
[object]
The rules for the group by.
path
string
The path to the value the log-based metric will be aggregated over.
tag_name
string
Eventual name of the tag that gets created. By default, the path attribute is used as the tag name.
id
string
The name of the log-based metric.
type
enum
The type of the resource. The value should always be logs_metrics.
Allowed enum values: logs_metrics
default: logs_metrics
{"data":{"attributes":{"compute":{"aggregation_type":"distribution","include_percentiles":true,"path":"@duration"},"filter":{"query":"service:web* AND @http.status_code:[200 TO 299]"},"group_by":[{"path":"@http.status_code","tag_name":"status_code"}]},"id":"logs.page.load.count","type":"logs_metrics"}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<API-KEY>"DD_APP_KEY="<APP-KEY>"cargo run
/**
* Create a log-based metric returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.LogsMetricsApi(configuration);constparams: v2.LogsMetricsApiCreateLogsMetricRequest={body:{data:{id:"ExampleLogsMetric",type:"logs_metrics",attributes:{compute:{aggregationType:"distribution",includePercentiles: true,path:"@duration",},},},},};apiInstance.createLogsMetric(params).then((data: v2.LogsMetricResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
The type of aggregation to use.
Allowed enum values: count,distribution
include_percentiles
boolean
Toggle to include or exclude percentile aggregations for distribution metrics.
Only present when the aggregation_type is distribution.
path
string
The path to the value the log-based metric will aggregate on (only used if the aggregation type is a "distribution").
filter
object
The log-based metric filter. Logs matching this filter will be aggregated in this metric.
query
string
The search query - following the log search syntax.
group_by
[object]
The rules for the group by.
path
string
The path to the value the log-based metric will be aggregated over.
tag_name
string
Eventual name of the tag that gets created. By default, the path attribute is used as the tag name.
id
string
The name of the log-based metric.
type
enum
The type of the resource. The value should always be logs_metrics.
Allowed enum values: logs_metrics
default: logs_metrics
{"data":{"attributes":{"compute":{"aggregation_type":"distribution","include_percentiles":true,"path":"@duration"},"filter":{"query":"service:web* AND @http.status_code:[200 TO 299]"},"group_by":[{"path":"@http.status_code","tag_name":"status_code"}]},"id":"logs.page.load.count","type":"logs_metrics"}}
"""
Get a log-based metric returns "OK" response
"""fromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.logs_metrics_apiimportLogsMetricsApi# there is a valid "logs_metric" in the systemLOGS_METRIC_DATA_ID=environ["LOGS_METRIC_DATA_ID"]configuration=Configuration()withApiClient(configuration)asapi_client:api_instance=LogsMetricsApi(api_client)response=api_instance.get_logs_metric(metric_id=LOGS_METRIC_DATA_ID,)print(response)
# Get a log-based metric returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::LogsMetricsAPI.new# there is a valid "logs_metric" in the systemLOGS_METRIC_DATA_ID=ENV["LOGS_METRIC_DATA_ID"]papi_instance.get_logs_metric(LOGS_METRIC_DATA_ID)
// Get a log-based metric returns "OK" response
packagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){// there is a valid "logs_metric" in the system
LogsMetricDataID:=os.Getenv("LOGS_METRIC_DATA_ID")ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewLogsMetricsApi(apiClient)resp,r,err:=api.GetLogsMetric(ctx,LogsMetricDataID)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `LogsMetricsApi.GetLogsMetric`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `LogsMetricsApi.GetLogsMetric`:\n%s\n",responseContent)}
// Get a log-based metric returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.LogsMetricsApi;importcom.datadog.api.client.v2.model.LogsMetricResponse;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();LogsMetricsApiapiInstance=newLogsMetricsApi(defaultClient);// there is a valid "logs_metric" in the systemStringLOGS_METRIC_DATA_ID=System.getenv("LOGS_METRIC_DATA_ID");try{LogsMetricResponseresult=apiInstance.getLogsMetric(LOGS_METRIC_DATA_ID);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling LogsMetricsApi#getLogsMetric");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// Get a log-based metric returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_logs_metrics::LogsMetricsAPI;#[tokio::main]asyncfnmain(){// there is a valid "logs_metric" in the system
letlogs_metric_data_id=std::env::var("LOGS_METRIC_DATA_ID").unwrap();letconfiguration=datadog::Configuration::new();letapi=LogsMetricsAPI::with_config(configuration);letresp=api.get_logs_metric(logs_metric_data_id.clone()).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<API-KEY>"DD_APP_KEY="<APP-KEY>"cargo run
/**
* Get a log-based metric returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.LogsMetricsApi(configuration);// there is a valid "logs_metric" in the system
constLOGS_METRIC_DATA_ID=process.env.LOGS_METRIC_DATA_IDasstring;constparams: v2.LogsMetricsApiGetLogsMetricRequest={metricId: LOGS_METRIC_DATA_ID,};apiInstance.getLogsMetric(params).then((data: v2.LogsMetricResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
Update a specific log-based metric from your organization.
Returns the log-based metric object from the request body when the request is successful.
This endpoint requires the logs_generate_metrics permission.
The type of aggregation to use.
Allowed enum values: count,distribution
include_percentiles
boolean
Toggle to include or exclude percentile aggregations for distribution metrics.
Only present when the aggregation_type is distribution.
path
string
The path to the value the log-based metric will aggregate on (only used if the aggregation type is a "distribution").
filter
object
The log-based metric filter. Logs matching this filter will be aggregated in this metric.
query
string
The search query - following the log search syntax.
group_by
[object]
The rules for the group by.
path
string
The path to the value the log-based metric will be aggregated over.
tag_name
string
Eventual name of the tag that gets created. By default, the path attribute is used as the tag name.
id
string
The name of the log-based metric.
type
enum
The type of the resource. The value should always be logs_metrics.
Allowed enum values: logs_metrics
default: logs_metrics
{"data":{"attributes":{"compute":{"aggregation_type":"distribution","include_percentiles":true,"path":"@duration"},"filter":{"query":"service:web* AND @http.status_code:[200 TO 299]"},"group_by":[{"path":"@http.status_code","tag_name":"status_code"}]},"id":"logs.page.load.count","type":"logs_metrics"}}
// Update a log-based metric returns "OK" response
packagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){// there is a valid "logs_metric" in the system
LogsMetricDataID:=os.Getenv("LOGS_METRIC_DATA_ID")body:=datadogV2.LogsMetricUpdateRequest{Data:datadogV2.LogsMetricUpdateData{Type:datadogV2.LOGSMETRICTYPE_LOGS_METRICS,Attributes:datadogV2.LogsMetricUpdateAttributes{Filter:&datadogV2.LogsMetricFilter{Query:datadog.PtrString("service:web* AND @http.status_code:[200 TO 299]-updated"),},},},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewLogsMetricsApi(apiClient)resp,r,err:=api.UpdateLogsMetric(ctx,LogsMetricDataID,body)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `LogsMetricsApi.UpdateLogsMetric`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `LogsMetricsApi.UpdateLogsMetric`:\n%s\n",responseContent)}
// Update a log-based metric with include_percentiles field returns "OK" response
packagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){// there is a valid "logs_metric_percentile" in the system
LogsMetricPercentileDataID:=os.Getenv("LOGS_METRIC_PERCENTILE_DATA_ID")body:=datadogV2.LogsMetricUpdateRequest{Data:datadogV2.LogsMetricUpdateData{Type:datadogV2.LOGSMETRICTYPE_LOGS_METRICS,Attributes:datadogV2.LogsMetricUpdateAttributes{Compute:&datadogV2.LogsMetricUpdateCompute{IncludePercentiles:datadog.PtrBool(false),},},},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewLogsMetricsApi(apiClient)resp,r,err:=api.UpdateLogsMetric(ctx,LogsMetricPercentileDataID,body)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `LogsMetricsApi.UpdateLogsMetric`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `LogsMetricsApi.UpdateLogsMetric`:\n%s\n",responseContent)}
// Update a log-based metric returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.LogsMetricsApi;importcom.datadog.api.client.v2.model.LogsMetricFilter;importcom.datadog.api.client.v2.model.LogsMetricResponse;importcom.datadog.api.client.v2.model.LogsMetricType;importcom.datadog.api.client.v2.model.LogsMetricUpdateAttributes;importcom.datadog.api.client.v2.model.LogsMetricUpdateData;importcom.datadog.api.client.v2.model.LogsMetricUpdateRequest;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();LogsMetricsApiapiInstance=newLogsMetricsApi(defaultClient);// there is a valid "logs_metric" in the systemStringLOGS_METRIC_DATA_ATTRIBUTES_FILTER_QUERY=System.getenv("LOGS_METRIC_DATA_ATTRIBUTES_FILTER_QUERY");StringLOGS_METRIC_DATA_ID=System.getenv("LOGS_METRIC_DATA_ID");LogsMetricUpdateRequestbody=newLogsMetricUpdateRequest().data(newLogsMetricUpdateData().type(LogsMetricType.LOGS_METRICS).attributes(newLogsMetricUpdateAttributes().filter(newLogsMetricFilter().query("service:web* AND @http.status_code:[200 TO"+" 299]-updated"))));try{LogsMetricResponseresult=apiInstance.updateLogsMetric(LOGS_METRIC_DATA_ID,body);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling LogsMetricsApi#updateLogsMetric");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// Update a log-based metric with include_percentiles field returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.LogsMetricsApi;importcom.datadog.api.client.v2.model.LogsMetricResponse;importcom.datadog.api.client.v2.model.LogsMetricType;importcom.datadog.api.client.v2.model.LogsMetricUpdateAttributes;importcom.datadog.api.client.v2.model.LogsMetricUpdateCompute;importcom.datadog.api.client.v2.model.LogsMetricUpdateData;importcom.datadog.api.client.v2.model.LogsMetricUpdateRequest;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();LogsMetricsApiapiInstance=newLogsMetricsApi(defaultClient);// there is a valid "logs_metric_percentile" in the systemStringLOGS_METRIC_PERCENTILE_DATA_ID=System.getenv("LOGS_METRIC_PERCENTILE_DATA_ID");LogsMetricUpdateRequestbody=newLogsMetricUpdateRequest().data(newLogsMetricUpdateData().type(LogsMetricType.LOGS_METRICS).attributes(newLogsMetricUpdateAttributes().compute(newLogsMetricUpdateCompute().includePercentiles(false))));try{LogsMetricResponseresult=apiInstance.updateLogsMetric(LOGS_METRIC_PERCENTILE_DATA_ID,body);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling LogsMetricsApi#updateLogsMetric");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
"""
Update a log-based metric returns "OK" response
"""fromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.logs_metrics_apiimportLogsMetricsApifromdatadog_api_client.v2.model.logs_metric_filterimportLogsMetricFilterfromdatadog_api_client.v2.model.logs_metric_typeimportLogsMetricTypefromdatadog_api_client.v2.model.logs_metric_update_attributesimportLogsMetricUpdateAttributesfromdatadog_api_client.v2.model.logs_metric_update_dataimportLogsMetricUpdateDatafromdatadog_api_client.v2.model.logs_metric_update_requestimportLogsMetricUpdateRequest# there is a valid "logs_metric" in the systemLOGS_METRIC_DATA_ATTRIBUTES_FILTER_QUERY=environ["LOGS_METRIC_DATA_ATTRIBUTES_FILTER_QUERY"]LOGS_METRIC_DATA_ID=environ["LOGS_METRIC_DATA_ID"]body=LogsMetricUpdateRequest(data=LogsMetricUpdateData(type=LogsMetricType.LOGS_METRICS,attributes=LogsMetricUpdateAttributes(filter=LogsMetricFilter(query="service:web* AND @http.status_code:[200 TO 299]-updated",),),),)configuration=Configuration()withApiClient(configuration)asapi_client:api_instance=LogsMetricsApi(api_client)response=api_instance.update_logs_metric(metric_id=LOGS_METRIC_DATA_ID,body=body)print(response)
"""
Update a log-based metric with include_percentiles field returns "OK" response
"""fromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.logs_metrics_apiimportLogsMetricsApifromdatadog_api_client.v2.model.logs_metric_typeimportLogsMetricTypefromdatadog_api_client.v2.model.logs_metric_update_attributesimportLogsMetricUpdateAttributesfromdatadog_api_client.v2.model.logs_metric_update_computeimportLogsMetricUpdateComputefromdatadog_api_client.v2.model.logs_metric_update_dataimportLogsMetricUpdateDatafromdatadog_api_client.v2.model.logs_metric_update_requestimportLogsMetricUpdateRequest# there is a valid "logs_metric_percentile" in the systemLOGS_METRIC_PERCENTILE_DATA_ID=environ["LOGS_METRIC_PERCENTILE_DATA_ID"]body=LogsMetricUpdateRequest(data=LogsMetricUpdateData(type=LogsMetricType.LOGS_METRICS,attributes=LogsMetricUpdateAttributes(compute=LogsMetricUpdateCompute(include_percentiles=False,),),),)configuration=Configuration()withApiClient(configuration)asapi_client:api_instance=LogsMetricsApi(api_client)response=api_instance.update_logs_metric(metric_id=LOGS_METRIC_PERCENTILE_DATA_ID,body=body)print(response)
# Update a log-based metric returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::LogsMetricsAPI.new# there is a valid "logs_metric" in the systemLOGS_METRIC_DATA_ATTRIBUTES_FILTER_QUERY=ENV["LOGS_METRIC_DATA_ATTRIBUTES_FILTER_QUERY"]LOGS_METRIC_DATA_ID=ENV["LOGS_METRIC_DATA_ID"]body=DatadogAPIClient::V2::LogsMetricUpdateRequest.new({data:DatadogAPIClient::V2::LogsMetricUpdateData.new({type:DatadogAPIClient::V2::LogsMetricType::LOGS_METRICS,attributes:DatadogAPIClient::V2::LogsMetricUpdateAttributes.new({filter:DatadogAPIClient::V2::LogsMetricFilter.new({query:"service:web* AND @http.status_code:[200 TO 299]-updated",}),}),}),})papi_instance.update_logs_metric(LOGS_METRIC_DATA_ID,body)
# Update a log-based metric with include_percentiles field returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::LogsMetricsAPI.new# there is a valid "logs_metric_percentile" in the systemLOGS_METRIC_PERCENTILE_DATA_ID=ENV["LOGS_METRIC_PERCENTILE_DATA_ID"]body=DatadogAPIClient::V2::LogsMetricUpdateRequest.new({data:DatadogAPIClient::V2::LogsMetricUpdateData.new({type:DatadogAPIClient::V2::LogsMetricType::LOGS_METRICS,attributes:DatadogAPIClient::V2::LogsMetricUpdateAttributes.new({compute:DatadogAPIClient::V2::LogsMetricUpdateCompute.new({include_percentiles:false,}),}),}),})papi_instance.update_logs_metric(LOGS_METRIC_PERCENTILE_DATA_ID,body)
// Update a log-based metric returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_logs_metrics::LogsMetricsAPI;usedatadog_api_client::datadogV2::model::LogsMetricFilter;usedatadog_api_client::datadogV2::model::LogsMetricType;usedatadog_api_client::datadogV2::model::LogsMetricUpdateAttributes;usedatadog_api_client::datadogV2::model::LogsMetricUpdateData;usedatadog_api_client::datadogV2::model::LogsMetricUpdateRequest;#[tokio::main]asyncfnmain(){// there is a valid "logs_metric" in the system
letlogs_metric_data_id=std::env::var("LOGS_METRIC_DATA_ID").unwrap();letbody=LogsMetricUpdateRequest::new(LogsMetricUpdateData::new(LogsMetricUpdateAttributes::new().filter(LogsMetricFilter::new().query("service:web* AND @http.status_code:[200 TO 299]-updated".to_string()),),LogsMetricType::LOGS_METRICS,));letconfiguration=datadog::Configuration::new();letapi=LogsMetricsAPI::with_config(configuration);letresp=api.update_logs_metric(logs_metric_data_id.clone(),body).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
// Update a log-based metric with include_percentiles field returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_logs_metrics::LogsMetricsAPI;usedatadog_api_client::datadogV2::model::LogsMetricType;usedatadog_api_client::datadogV2::model::LogsMetricUpdateAttributes;usedatadog_api_client::datadogV2::model::LogsMetricUpdateCompute;usedatadog_api_client::datadogV2::model::LogsMetricUpdateData;usedatadog_api_client::datadogV2::model::LogsMetricUpdateRequest;#[tokio::main]asyncfnmain(){// there is a valid "logs_metric_percentile" in the system
letlogs_metric_percentile_data_id=std::env::var("LOGS_METRIC_PERCENTILE_DATA_ID").unwrap();letbody=LogsMetricUpdateRequest::new(LogsMetricUpdateData::new(LogsMetricUpdateAttributes::new().compute(LogsMetricUpdateCompute::new().include_percentiles(false)),LogsMetricType::LOGS_METRICS,));letconfiguration=datadog::Configuration::new();letapi=LogsMetricsAPI::with_config(configuration);letresp=api.update_logs_metric(logs_metric_percentile_data_id.clone(),body).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<API-KEY>"DD_APP_KEY="<APP-KEY>"cargo run
/**
* Update a log-based metric returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.LogsMetricsApi(configuration);// there is a valid "logs_metric" in the system
constLOGS_METRIC_DATA_ID=process.env.LOGS_METRIC_DATA_IDasstring;constparams: v2.LogsMetricsApiUpdateLogsMetricRequest={body:{data:{type:"logs_metrics",attributes:{filter:{query:"service:web* AND @http.status_code:[200 TO 299]-updated",},},},},metricId: LOGS_METRIC_DATA_ID,};apiInstance.updateLogsMetric(params).then((data: v2.LogsMetricResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
/**
* Update a log-based metric with include_percentiles field returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.LogsMetricsApi(configuration);// there is a valid "logs_metric_percentile" in the system
constLOGS_METRIC_PERCENTILE_DATA_ID=process.env.LOGS_METRIC_PERCENTILE_DATA_IDasstring;constparams: v2.LogsMetricsApiUpdateLogsMetricRequest={body:{data:{type:"logs_metrics",attributes:{compute:{includePercentiles: false,},},},},metricId: LOGS_METRIC_PERCENTILE_DATA_ID,};apiInstance.updateLogsMetric(params).then((data: v2.LogsMetricResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
"""
Delete a log-based metric returns "OK" response
"""fromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.logs_metrics_apiimportLogsMetricsApi# there is a valid "logs_metric" in the systemLOGS_METRIC_DATA_ID=environ["LOGS_METRIC_DATA_ID"]configuration=Configuration()withApiClient(configuration)asapi_client:api_instance=LogsMetricsApi(api_client)api_instance.delete_logs_metric(metric_id=LOGS_METRIC_DATA_ID,)
# Delete a log-based metric returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::LogsMetricsAPI.new# there is a valid "logs_metric" in the systemLOGS_METRIC_DATA_ID=ENV["LOGS_METRIC_DATA_ID"]api_instance.delete_logs_metric(LOGS_METRIC_DATA_ID)
// Delete a log-based metric returns "OK" response
packagemainimport("context""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){// there is a valid "logs_metric" in the system
LogsMetricDataID:=os.Getenv("LOGS_METRIC_DATA_ID")ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewLogsMetricsApi(apiClient)r,err:=api.DeleteLogsMetric(ctx,LogsMetricDataID)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `LogsMetricsApi.DeleteLogsMetric`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}}
// Delete a log-based metric returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.LogsMetricsApi;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();LogsMetricsApiapiInstance=newLogsMetricsApi(defaultClient);// there is a valid "logs_metric" in the systemStringLOGS_METRIC_DATA_ID=System.getenv("LOGS_METRIC_DATA_ID");try{apiInstance.deleteLogsMetric(LOGS_METRIC_DATA_ID);}catch(ApiExceptione){System.err.println("Exception when calling LogsMetricsApi#deleteLogsMetric");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// Delete a log-based metric returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_logs_metrics::LogsMetricsAPI;#[tokio::main]asyncfnmain(){// there is a valid "logs_metric" in the system
letlogs_metric_data_id=std::env::var("LOGS_METRIC_DATA_ID").unwrap();letconfiguration=datadog::Configuration::new();letapi=LogsMetricsAPI::with_config(configuration);letresp=api.delete_logs_metric(logs_metric_data_id.clone()).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com"DD_API_KEY="<API-KEY>"DD_APP_KEY="<APP-KEY>"cargo run
/**
* Delete a log-based metric returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.LogsMetricsApi(configuration);// there is a valid "logs_metric" in the system
constLOGS_METRIC_DATA_ID=process.env.LOGS_METRIC_DATA_IDasstring;constparams: v2.LogsMetricsApiDeleteLogsMetricRequest={metricId: LOGS_METRIC_DATA_ID,};apiInstance.deleteLogsMetric(params).then((data: any)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));