Migrate from Log Monitoring API v1 to Log Classic API
Log Monitoring API v1 has been deprecated with Dynatrace version 1.284. Its replacement is Log Monitoring API. We recommend that you migrate to the new API at your earliest convenience.
The migration affects endpoint URLs, query parameters, and response/request body parameters, as well as the scope of the token for request authentication.
New features
Log Classic API offers you the following new features:
- You can search or export log data that match provided criteria in the global log storage (with up to 35 days of retention).
- The new version gets the aggregated log records that match the provided criteria.
- You can ingest log data using REST API.
Licensing
The ingestion of custom events consumes Davis Data Units (DDUs) from the logs pool.
Base URL
Log Classic API new
/api/v2/logs/aggregate
/api/v2/logs/export
/api/v2/logs/ingest
/api/v2/logs/search
Log Monitoring v1 old
/api/v1/entity/infrastructure/custom-devices
/api/v1/entity/infrastructure/hosts
/api/v1/entity/infrastructure/process-groups
Authentication token scope
Read logs (logs.read
)
Ingest logs (logs.ingest
)
List, get, analyse logs of custom devices, hosts or process groups (LogExport
)
Parameters
To learn about new query/body parameters, see the documentation of individual requests in Log Classic API.
Examples
Here are some examples of differences in API usage.
Retrieve host OS system log file names
Request URL
GET "https://mySampleEnv.live.dynatrace.com/api/v2/logs/aggregate?from=now-7d&to=now&query=dt.entity.process_group%20%3D%20%22process_group-09875e82e2fb98fd%22&timeBuckets=1&maxGroupValues=10&groupBy=log.source"
or
GET "'https://mySampleEnv.live.dynatrace.com/api/v2/logs/aggregate?from=now-7d&to=now&query=dt.process.name%3D%22windows%20system%22&timeBuckets=1&maxGroupValues=10&groupBy=log.source'"
Response body
{
"aggregationResult": {
"log.source": {
"1705331381355": {
"windows security log": 44,
"windows application log": 10
}
}
}
}
Request URL
GET "http://mySampleEnv.live.dynatrace.com/api/v1/entity/infrastructure/hosts/HOST-23606F6C8433070B/logs"
Response body
{
"contentAccess": true,
"logs": [{
"path": "Windows Application Log",
"size": 20975616,
"availableForAnalysis": true
}, {
"path": "Windows System Log",
"size": 20975616,
"availableForAnalysis": true
}, {
"path": "Windows Security Log",
"size": 20975616,
"availableForAnalysis": true
}
]
}
Find process group file log records for a given query
Request URL
GET 'https://mySampleEnv.live.dynatrace.com/api/v2/logs/search?from=now-6h&to=now&limit=1000&query=dt.entity.process_group%3D%22process_group-944a2cee87e6e3aa%22&sort=-timestamp'
Response body
{
"results": [
{
"timestamp": 1705667987673,
"content": "<![LOG[Non-AppUsage event got through, ignore this event.]LOG]!><time=\"13:38:30.0161567\" date=\"1-19-2024\" component=\"SensorFramework\" context=\"\" type=\"1\" thread=\"14\" file=\"\">",
"status": "NONE",
"eventType": "LOG",
"additionalColumns": {
"loglevel": [
"NONE"
],
"dt.entity.process_group": [
"PROCESS_GROUP-944A2CEE87E6E3AA"
],
"dt.source_entity": [
"PROCESS_GROUP_INSTANCE-C27914355E744AA8"
],
"process.technology": [
".NET",
"CLR"
],
"dt.process.name": [
"Microsoft.Management.Services.IntuneWindowsAgent.exe"
],
"dt.entity.process_group_instance": [
"PROCESS_GROUP_INSTANCE-C27914355E744AA8"
],
"log.source": [
"C:\\ProgramData\\Microsoft\\IntuneManagementExtension\\Logs\\Sensor.log"
],
"host.name": [
"CT-XYZ1234"
],
"dt.entity.host": [
"HOST-23606F6C8433070B"
]
}
},
]
}
Request URL
POST "http://mySampleEnv.live.dynatrace.com/api/v1/entity/infrastructure/process-groups/PROCESS_GROUP-95B000C1C3340CEB/logs/%2Fmy%2Fpath?query=my_query&hostFilter=HOST-23606F6C8433070B"
GET "http://mySampleEnv.live.dynatrace.com/api/v1/entity/infrastructure/process-groups/PROCESS_GROUP-95B000C1C3340CEB/logs/jobs/ac7cfb4c-7683-4ef0-b4e2-9b8b85da4864/records"
Request body
Response body
{"jobId":"ac7cfb4c-7683-4ef0-b4e2-9b8b85da4864"}
{
"records": [{
"timestamp": 1705408647765,
"logLevel": "INFO",
"hostId": "HOST-23606F6C8433070B",
"text": "2024-01-16 13:37:27,765 [79029245] INFO - My Log Line 1",
"customFields": {
"_host.name": "CT-XYZ1234",
"_process.technology": "Java",
"_Level": "INFO"
}
}]
}
Find number of occurrences of some fields of a process group file log records
Request URL
GET "https://mySampleEnv.live.dynatrace.com/api/v2/logs/aggregate?from=now-7d&to=now&query=log.source%3D%22c%3A%5C%5Cprogramdata%5C%5Cmicrosoft%5C%5Cintunemanagementextension%5C%5Clogs%5C%5Chealthscripts.log%22%20AND%20dt.process.name%3D%22microsoft.management.services.intunewindowsagent.exe%22&timeBuckets=1&maxGroupValues=10"
Response body
{
"aggregationResult": {
"dt.entity.process_group": {
"1705336941514": {
"process_group-944a2cee87e6e3aa": 1237
}
},
"dt.source_entity": {
"1705336941514": {
"process_group_instance-c27914355e744aa8": 1237
}
},
"process.technology": {
"1705336941514": {
".net": 1237,
"clr": 1237
}
},
"dt.process.name": {
"1705336941514": {
"microsoft.management.services.intunewindowsagent.exe": 1237
}
},
"loglevel": {
"1705336941514": {
"none": 1231,
"error": 3,
"info": 3
}
},
"event.type": {
"1705336941514": {
"log": 1237
}
},
"dt.entity.process_group_instance": {
"1705336941514": {
"process_group_instance-c27914355e744aa8": 1237
}
},
"log.source": {
"1705336941514": {
"c:\\programdata\\microsoft\\intunemanagementextension\\logs\\healthscripts.log": 1237
}
},
"host.name": {
"1705336941514": {
"my-host": 1237
}
},
"status": {
"1705336941514": {
"none": 1231,
"error": 3,
"info": 3
}
},
"dt.entity.host": {
"1705336941514": {
"host-23606f6c8433070b": 1237
}
}
}
}
Request URL
POST "http://mySampleEnv.live.dynatrace.com/api/v1/entity/infrastructure/process-groups/PROCESS_GROUP-95B000C1C3340CEB/logs/jobs/2268a2a3-edb3-47a1-8f2f-9341e8dad962/records/top"
BODY: {"filterQuery": "_Level = \"INFO\""}
Request body
{"filterQuery": "_Level = \"INFO\""}
Response body
{
"parsingFieldTopValues": [{
"fieldName": "_Level",
"occurrences": [{
"value": "INFO",
"count": 362
}
]
}, {
"fieldName": "_host.name",
"occurrences": [{
"value": "CT-XYZ1234",
"count": 362
}
]
}, {
"fieldName": "_process.technology",
"occurrences": [{
"value": "Java",
"count": 362
}
]
}
],
"valuesCount": 3
}