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" responsepackagemainimport("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 systemLogsMetricDataID:=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.comap2.datadoghq.comddog-gov.comus2.ddog-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));