根据 Dynatrace 官方文档,Dynatrace 并没有针对特定工作负载的默认配置。但是,Dynatrace 提供了自定义配置选项来更好地适应不同的工作负载。
以下是一个用于自定义配置的 Python 代码示例,可作为求助支持团队时提供的参考信息:
import requests
import json
dtTenantURL = 'https://<tenantID>.live.dynatrace.com/api/v1/'
dtAPIToken = '<yourAPIToken>'
dtAppID = '<yourApplicationID>'
headers = {'Content-Type': 'application/json', 'Authorization': 'Api-Token '+dtAPIToken}
# Get application detection rules
url = dtTenantURL + 'configuration/applications/' + dtAppID + '/detectionRules'
response = requests.get(url, headers=headers)
response.raise_for_status()
detectionRules = response.json()
# Add custom detection rule
customDetection = {
"order" : 10000,
"enabled" : True,
"type" : "PROCESS_GROUP_NAME",
"valueFormat" : "${ProcessGroup:Description}",
"propagationTypes" : [ "SERVICE_TO_PROCESS_GROUP", "PROCESS_TO_PROCESS_GROUP" ]
}
detectionRules['detectionRules'].append(customDetection)
# Update the application detection rules
url = dtTenantURL + 'configuration/applications/' + dtAppID + '/detectionRules'
response = requests.put(url, headers=headers, data=json.dumps(detectionRules))
response.raise_for_status()
在此示例中,我们获取了应用程序的检测规则,并添加了一个自定义检测规则。最后,我们使用 Dynatrace API 更新应用程序检测规则。这是其中一种方法,可以根据自己的需求编写自定义配置脚本。