Log Monitoring metrics API - GET a metric
Gets the descriptor of the specified calculated Log Monitoring metric.
The request produces an application/json
payload.
GET | ManagedDynatrace for Government | https://{your-domain}/e/{your-environment-id}/api/config/v1/calculatedMetrics/log/{metricKey} |
SaaS | https://{your-environment-id}.live.dynatrace.com/api/config/v1/calculatedMetrics/log/{metricKey} | |
Environment ActiveGate | https://{your-activegate-domain}:9999/e/{your-environment-id}/api/config/v1/calculatedMetrics/log/{metricKey} |
Authentication
To execute this request, you need an access token with ReadConfig
scope.
To learn how to obtain and use it, see Tokens and authentication.
Parameters
Parameter | Type | Description | In | Required |
---|---|---|---|---|
metricKey | string | The key of the required custom log metric. | path | required |
Response
Response codes
Code | Type | Description |
---|---|---|
200 | LogMetricConfig | Success |
400 | ErrorEnvelope | Failed. See the response body for details |
Response body objects
The LogMetricConfig
object
Custom log metric definition.
Element | Type | Description |
---|---|---|
active | boolean | The metric is enabled ( |
columnDefiningValue | ColumnDefinition | Definition of numeric column. |
displayName | string | The name of the metric, displayed in the UI. |
logSourceFilters | LogSourceFilter[] | A list of filters to define the logs to look into. If several filters are specified, the OR logic applies. |
metricKey | string | The unique key of the metric. The key must have the |
metricValueType | string | The type of the metric data points calculation. For now the only allowed value is
|
searchString | string | The pattern to look for in logs. Use the Dynatrace search query language to specify it. Quotes must be escaped. To return all results, leave the field blank. |
unit | string | The unit of the metric.
|
unitDisplayName | string | The display name of the unit. Only applicable if the unit is set to |
The ColumnDefinition
object
Definition of numeric column.
Element | Type | Description |
---|---|---|
name | string | - |
type | string | Defines the actual set of fields depending on the value. See one of the following objects:
|
The LogSourceFilter
object
Configuration of the log filter for a custom log metric.
If several criteria are specified, the AND logic applies.
Element | Type | Description |
---|---|---|
hostFilters | string[] | A list of hosts, where the log can originate from. Specify Dynatrace entity IDs here. If several hosts are specified, the OR logic applies. |
osTypes | string[] | A list of operating system types, where the log can originate from. If set, only OS logs are included in the result. If several OS are specified, the OR logic applies. This field is mutually exclusive with the sourceEntities field.
|
pathDefinitions | PathDefinition[] | A list of filtering criteria for log path. If several criteria are specified, the OR logic applies. |
sourceEntities | string[] | A list of Dynatrace entities, where the log can originate from. Specify Dynatrace entity IDs here. Allowed types of entities are If several entities are specified, the OR logic applies. This field is mutually exclusive with the osTypes field. |
The PathDefinition
object
A filtering criterion for log path.
Element | Type | Description |
---|---|---|
definition | string | The path to the required log path. If the type is set to |
type | string | The type of the log path definition: fixed or an expression with wildcards.
|
Response body JSON model
1{2 "active": true,3 "displayName": "Sample metric",4 "logSourceFilters": [5 {6 "hostFilters": [7 "HOST-066703AD79C38DB5"8 ],9 "osTypes": [],10 "pathDefinitions": [11 {12 "definition": "/var/log/sample.log",13 "type": "FIXED"14 }15 ],16 "sourceEntities": [17 "PROCESS_GROUP_INSTANCE-63FC6E7C73DC893F"18 ]19 }20 ],21 "metricKey": "calc:log.metric",22 "metricValueType": "OCCURRENCES",23 "searchString": "\"memory fault\"",24 "unit": "HOUR",25 "unitDisplayName": ""26}
Example
In this example, the request gets the definition of the Unknown parameter custom log metric.
The metric counts the occurrences of the phrase Unknown parameter in the following logs:
- All logs from the process with Dynatrace entity ID PROCESS_GROUP_INSTANCE-6CD96121AD8F5308 that runs on the host with Dynatrace entity ID HOST-5AA1203365B14DB.
- The /var/log/ansible.log from the process with Dynatrace entity ID PROCESS_GROUP_INSTANCE-7CD17F573CC3DA3F that runs on the host with Dynatrace entity ID HOST-E0D8F94D9065F24F.
The API token is passed in the Authorization header.
Curl
1curl -X GET \2 https://mySampleEnv.live.dynatrace.com/api/config/v1/calculatedMetrics/log/calc:log.runknownparameter \3 -H 'Authorization: Api-Token dt0c01.abc123.abcdefjhij1234567890'
Request URL
1https://mySampleEnv.live.dynatrace.com/api/config/v1/calculatedMetrics/log/calc:log.runknownparameter
Response body
1{2 "metricKey": "calc:log.runknownparameter",3 "active": true,4 "displayName": "Unknown parameter",5 "unit": "COUNT",6 "unitDisplayName": null,7 "searchString": "\"unknown parameter\"",8 "metricValueType": "OCCURRENCES",9 "logSourceFilters": [10 {11 "pathDefinitions": [],12 "sourceEntities": [13 "PROCESS_GROUP_INSTANCE-6CD96121AD8F5308"14 ],15 "hostFilters": [16 "HOST-5AA1203365B14DBC"17 ],18 "osTypes": []19 },20 {21 "pathDefinitions": [22 {23 "definition": "/var/log/ansible.log",24 "type": "FIXED"25 }26 ],27 "sourceEntities": [28 "PROCESS_GROUP_INSTANCE-7CD17F573CC3DA3F"29 ],30 "hostFilters": [31 "HOST-E0D8F94D9065F24F"32 ],33 "osTypes": []34 }35 ]36}
Response code
200