Log monitoring metrics API - GET a metric

Gets the definition of the specified custom log metric.

The request produces an application/json payload.

This request is currently in preview and is subject to change. Changes may not be compatible with your current configuration.

GET
  • Managed https://{your-domain}/e/{your-environment-id}/api/config/v1/customMetric/log/{metricKey}
  • SaaS https://{your-environment-id}.live.dynatrace.com/api/config/v1/customMetric/log/{metricKey}

Parameters

Parameter Type Description In Required
metricKey string

The custom log metric key.

path required

Response format

The LogMetricConfig object

Log Analytics metric configuration.

Element Type Description
metricKey string

A unique metric key.

active boolean

Metric activity flag. Value 'false' means metric is ignored when detecting metric occurrences.

displayName string

The name of this subscribed metric. Should not be empty.

unit string

Metric unit.

unitDisplayName string

The unit display name. Taken into account if unit is 'UNSPECIFIED'.

searchString string

Text pattern to search in logs in form of Dynatrace Search Query Language. When blank every log entry is assumed as matching.

metricValueType string

Defines metric value i.e. how the value is calculated.

logSourceFilters LogSourceFilter[]

Defines list of filters on log source. Separate source filters from this collection are joined with OR operator.

The LogSourceFilter object

Defines filtering conditions on log source various attributes (filtering criteria). Various filtering criteria (e.g. pathDefinitions and sourceEntities) from this filter are joined with AND operator with exception of hostFilters and hostGroups that are joined with OR operator.

Element Type Description
pathDefinitions PathDefinition[]

List of filtering conditions on log path. Joined with OR operator if specified more than one.

sourceEntities string[]

List of Dynatrace entity IDs that log can originate from. Allowed types of entities: PROCESS_GROUP, PROCESS_GROUP_INSTANCE. Entity types cannot be mixed. Can be specified only alternatively to filtering criteria: osTypes.

hostFilters string[]

List of hosts as Dynatrace entity IDs that log can originate from. Can be specified only alternatively to filtering criteria: sourceTypes. Collection elements are joined with OR operator.

osTypes string[]

OS types as Dynatrace OS identifiers related to log file originating host. When specified, operating system logs are filtered. Can be specified only alternatively to filtering criteria: sourceEntities, sourceTypes.

The PathDefinition object

Defines filtering condition on log path.

Element Type Description
definition string

Log path. If type is WILDCARD, may contain '*' characters working as wildcards

type string

Specifies log path definition type: FIXED or WILDCARD.

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

curl -X GET \
  https://mySampleEnv.live.dynatrace.com/api/config/v1/customMetric/log/calc:log.runknownparameter \
  -H 'Authorization: Api-token abcdefjhij1234567890'

Request URL

https://mySampleEnv.live.dynatrace.com/api/config/v1/customMetric/log/calc:log.runknownparameter

Response body

{
  "metricKey": "calc:log.runknownparameter",
  "active": true,
  "displayName": "Unknown parameter",
  "unit": "COUNT",
  "unitDisplayName": null,
  "searchString": "\"unknown parameter\"",
  "metricValueType": "OCCURRENCES",
  "logSourceFilters": [
    {
      "pathDefinitions": [],
      "sourceEntities": [
        "PROCESS_GROUP_INSTANCE-6CD96121AD8F5308"
      ],
      "hostFilters": [
        "HOST-5AA1203365B14DBC"
      ],
      "osTypes": []
    },
    {
      "pathDefinitions": [
        {
          "definition": "/var/log/ansible.log",
          "type": "FIXED"
        }
      ],
      "sourceEntities": [
        "PROCESS_GROUP_INSTANCE-7CD17F573CC3DA3F"
      ],
      "hostFilters": [
        "HOST-E0D8F94D9065F24F"
      ],
      "osTypes": []
    }
  ]
}

Response code

200