• Home
  • Dynatrace API
  • Configuration
  • Calculated metrics
  • Log Monitoring
  • PUT a metric

Log Monitoring metrics API - PUT a metric

Updates the descriptor of the specified calculated Log Monitoring metric.

The request consumes and produces an application/json payload.

PUTManagedDynatrace for Governmenthttps://{your-domain}/e/{your-environment-id}/api/config/v1/calculatedMetrics/log/{metricKey}
SaaShttps://{your-environment-id}.live.dynatrace.com/api/config/v1/calculatedMetrics/log/{metricKey}
Environment ActiveGatehttps://{your-activegate-domain}/e/{your-environment-id}/api/config/v1/calculatedMetrics/log/{metricKey}

Authentication

To execute this request, you need an access token with WriteConfig scope.

To learn how to obtain and use it, see Tokens and authentication.

Parameters

ParameterTypeDescriptionInRequired
metricKeystring

The required key of the custom log metric. The key must have the calc:log. prefix.

The key in the body of the request must match this key.

pathrequired
bodyLogMetricConfig

The JSON body of the request. Contains the definition of the custom log metric.

bodyoptional

Request body objects

The LogMetricConfig object

Custom log metric definition.

ElementTypeDescriptionRequired
metricKeystring

The unique key of the metric.

The key must have the calc:log. prefix.

required
activeboolean

The metric is enabled (true) or disabled (false).

optional
displayNamestring

The name of the metric, displayed in the UI.

required
unitstring

The unit of the metric.

The element can hold these values
  • BILLION
  • BIT
  • BIT_PER_HOUR
  • BIT_PER_MINUTE
  • BIT_PER_SECOND
  • BYTE
  • BYTE_PER_HOUR
  • BYTE_PER_MINUTE
  • BYTE_PER_SECOND
  • CORES
  • COUNT
  • DAY
  • DECIBEL_MILLI_WATT
  • GIBI_BYTE
  • GIBI_BYTE_PER_HOUR
  • GIBI_BYTE_PER_MINUTE
  • GIBI_BYTE_PER_SECOND
  • GIGA
  • GIGA_BYTE
  • GIGA_BYTE_PER_HOUR
  • GIGA_BYTE_PER_MINUTE
  • GIGA_BYTE_PER_SECOND
  • HOUR
  • KIBI_BYTE
  • KIBI_BYTE_PER_HOUR
  • KIBI_BYTE_PER_MINUTE
  • KIBI_BYTE_PER_SECOND
  • KILO
  • KILO_BYTE
  • KILO_BYTE_PER_HOUR
  • KILO_BYTE_PER_MINUTE
  • KILO_BYTE_PER_SECOND
  • KILO_METRE_PER_HOUR
  • MEBI_BYTE
  • MEBI_BYTE_PER_HOUR
  • MEBI_BYTE_PER_MINUTE
  • MEBI_BYTE_PER_SECOND
  • MEGA
  • MEGA_BYTE
  • MEGA_BYTE_PER_HOUR
  • MEGA_BYTE_PER_MINUTE
  • MEGA_BYTE_PER_SECOND
  • METRE_PER_HOUR
  • METRE_PER_SECOND
  • MICRO_SECOND
  • MILLION
  • MILLI_CORES
  • MILLI_SECOND
  • MILLI_SECOND_PER_MINUTE
  • MINUTE
  • MONTH
  • MSU
  • NANO_SECOND
  • NANO_SECOND_PER_MINUTE
  • NOT_APPLICABLE
  • PERCENT
  • PER_HOUR
  • PER_MINUTE
  • PER_SECOND
  • PIXEL
  • PROMILLE
  • RATIO
  • SECOND
  • STATE
  • TRILLION
  • UNSPECIFIED
  • WEEK
  • YEAR
required
unitDisplayNamestring

The display name of the unit.

Only applicable if the unit is set to UNSPECIFIED.

optional
searchStringstring

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.

required
metricValueTypestring

The type of the metric data points calculation. For now the only allowed value is OCCURRENCES.

The element can hold these values
  • FP_COLUMN_AVG
  • FP_COLUMN_COUNT
  • FP_COLUMN_MAX
  • FP_COLUMN_MIN
  • FP_COLUMN_SUM
  • FP_COLUMN_TOP_X_AVG
  • FP_COLUMN_TOP_X_COUNT
  • FP_COLUMN_TOP_X_MAX
  • FP_COLUMN_TOP_X_MIN
  • FP_COLUMN_TOP_X_SUM
  • INT_COLUMN_AVG
  • INT_COLUMN_COUNT
  • INT_COLUMN_MAX
  • INT_COLUMN_MIN
  • INT_COLUMN_SUM
  • INT_COLUMN_TOP_X_AVG
  • INT_COLUMN_TOP_X_COUNT
  • INT_COLUMN_TOP_X_MAX
  • INT_COLUMN_TOP_X_MIN
  • INT_COLUMN_TOP_X_SUM
  • OCCURRENCES
required
columnDefiningValueColumnDefinition

Definition of numeric column.

optional
logSourceFiltersLogSourceFilter[]

A list of filters to define the logs to look into.

If several filters are specified, the OR logic applies.

required

The ColumnDefinition object

Definition of numeric column.

ElementTypeDescriptionRequired
namestring-required
typestring

Defines the actual set of fields depending on the value. See one of the following objects:

  • CUSTOM -> CustomColumnDefinition
  • JSON -> JsonColumnDefinition
The element can hold these values
  • CUSTOM
  • JSON
required

The LogSourceFilter object

Configuration of the log filter for a custom log metric.

If several criteria are specified, the AND logic applies.

ElementTypeDescriptionRequired
pathDefinitionsPathDefinition[]

A list of filtering criteria for log path.

If several criteria are specified, the OR logic applies.

optional
sourceEntitiesstring[]

A list of Dynatrace entities, where the log can originate from. Specify Dynatrace entity IDs here.

Allowed types of entities are PROCESS_GROUP and PROCESS_GROUP_INSTANCE. You can't mix entity types.

If several entities are specified, the OR logic applies.

This field is mutually exclusive with the osTypes field.

optional
hostFiltersstring[]

A list of hosts, where the log can originate from. Specify Dynatrace entity IDs here.

If several hosts are specified, the OR logic applies.

optional
osTypesstring[]

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.

The element can hold these values
  • AIX
  • DARWIN
  • HPUX
  • LINUX
  • SOLARIS
  • WINDOWS
  • ZOS
optional

The PathDefinition object

A filtering criterion for log path.

ElementTypeDescriptionRequired
definitionstring

The path to the required log path.

If the type is set to WILDCARD, it may contain wildcard characters (*).

required
typestring

The type of the log path definition: fixed or an expression with wildcards.

The element can hold these values
  • FIXED
  • WILDCARD
required

Request body JSON model

This is a model of the request body, showing the possible elements. It has to be adjusted for usage in an actual request.

json
{ "metricKey": "calc:log.metric", "active": true, "displayName": "Sample metric", "unit": "HOUR", "unitDisplayName": "", "searchString": "\"memory fault\"", "metricValueType": "OCCURRENCES", "logSourceFilters": [ { "pathDefinitions": [ { "definition": "/var/log/sample.log", "type": "FIXED" } ], "sourceEntities": [ "PROCESS_GROUP_INSTANCE-63FC6E7C73DC893F" ], "hostFilters": [ "HOST-066703AD79C38DB5" ], "osTypes": [] } ] }

Response

Response codes

CodeTypeDescription
201EntityShortRepresentation

Success. The new metric definition has been created. The response body contains the key and the name of the new metric.

204

Success. The metric definition has been updated. Response doesn't have a body.

400ErrorEnvelope

Failed. The input is invalid.

Response body objects

The EntityShortRepresentation object

The short representation of a Dynatrace entity.

ElementTypeDescription
idstring

The ID of the Dynatrace entity.

namestring

The name of the Dynatrace entity.

descriptionstring

A short description of the Dynatrace entity.

Response body JSON model

json
{ "id": "6a98d7bc-abb9-44f8-ae6a-73e68e71812a", "name": "Dynatrace entity", "description": "Dynatrace entity for the REST API example" }

Validate payload

We recommend that you validate the payload before submitting it with an actual request. A response code of 204 indicates a valid payload.

The request consumes an application/json payload.

The request consumes an application/json payload.

POSTManagedDynatrace for Governmenthttps://{your-domain}/e/{your-environment-id}/api/config/v1/calculatedMetrics/log/{metricKey}/validator
SaaShttps://{your-environment-id}.live.dynatrace.com/api/config/v1/calculatedMetrics/log/{metricKey}/validator
Environment ActiveGatehttps://{your-activegate-domain}/e/{your-environment-id}/api/config/v1/calculatedMetrics/log/{metricKey}/validator

Authentication

To execute this request, you need an access token with WriteConfig scope.

To learn how to obtain and use it, see Tokens and authentication.

Response

Response codes

CodeTypeDescription
204

Validated. The submitted configuration is valid. Response doesn't have a body.

400ErrorEnvelope

Failed. See the response body for details

Example

In this example, the request creates a new custom log metric with the key of calc:log.unsecuredcall. The metric counts the occurrences of the phrase UNSECURED_SHARED_CALL in 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 API token is passed in the Authorization header.

Because the request body is lengthy, it is truncated in this example Curl section. See the full body in the Request body section. You can download or copy the example request body to try it out on your own. Before using it, make sure that you're using Dynatrace entity IDs that are available in your environment.

Curl

bash
curl -X PUT \ https://mySampleEnv.live.dynatrace.com/api/config/v1/calculatedMetrics/log/calc:log.unsecuredcall \ -H 'Authorization: Api-Token dt0c01.abc123.abcdefjhij1234567890' \ -H 'Content-Type: application/json' \ -d '{<truncated - see the Request body section >}'

Request URL

plaintext
https://mySampleEnv.live.dynatrace.com/api/config/v1/calculatedMetrics/log/calc:log.unsecuredcall

Request body

json
{ "metricKey": "calc:log.unsecuredcall", "active": true, "displayName": "Unsecured call", "unit": "COUNT", "searchString": "UNSECURED_SHARED_CALL", "metricValueType": "OCCURRENCES", "logSourceFilters": [ { "pathDefinitions": [], "sourceEntities": ["PROCESS_GROUP_INSTANCE-6CD96121AD8F5308"], "hostFilters": ["HOST-5AA1203365B14DBC"], "osTypes": [] } ] }

Response body

json
{ "id": "calc:log.unsecuredcall", "name": "Unsecured call" }

Response code

201

Related topics
  • Log Monitoring Classic

    Learn how to enable Log Monitoring, the insights that Log Monitoring can provide, and more.