Dynatrace / Dynatrace/snippets
Error message during script execution
- Dominant language
- Python
- Stars
- 15
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I got an error message during the execution of the script (dduConsumptionPerMZ.py). Example below :
```
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://joz54139.live.dynatrace.com/api/v2/metrics/query?metricSelector=builtin:billing.ddu.metrics.byEntity:splitBy()&entitySelector=mzId(4300920862641653399),type(SOFTWARE_COMPONENT)&pageSize=500&from=2021-02-01T12:00:00%2B02:00&to=2021-02-28T12:00:00%2B02:00
```
After executing this request manually, the full error message is as follows :
```
{
"error": {
"code": 400,
"message": "Constraints violated.",
"constraintViolations": [
{
"path": "entitySelector",
"message": "Predicate name mzId not applicable for type BOSH_DEPLOYMENT",
"parameterLocation": "QUERY",
"location": null
}
]
}
}
```
It seems that some types are not compatible with the "mzId" argument present for "entitySelector".
I had to adapt the script this way to exclude types that are not applicable with the predicate name "mzId":
`if not re.search(r'APM_SECURITY_GATEWAY|APPLICATION_METHOD|AZURE_REGION|BOSH_DEPLOYMENT|BROWSER|CINDER_VOLUME|CONTAINER_GROUP|DCRUM_SERVICE_INSTANCE|ENVIRONMENT|GCP_ZONE|GEOLOCATION|GEOLOC_SITE|HYPERVISOR_CLUSTER|NEUTRON_SUBNET|OPENSTACK_AVAILABILITY_ZONE|OPENSTACK_COMPUTE_NODE|OPENSTACK_PROJECT|OPENSTACK_REGION|OS|QUEUE|RUNTIME_COMPONENT|SOFTWARE_COMPONENT|SWIFT_CONTAINER|SYNTHETIC_LOCATION|VMWARE_DATACENTER', allEntityTypes[entityTypeIndex]["type"]):`
Contributor guide
Research direction
Start with dduConsumptionPerMZ.py and trace how entity types are used to build the Dynatrace metrics query, especially the entitySelector parameter. Reproduce the reported request and compare the API constraint violation for incompatible types; the work is done when the script no longer sends mzId for unsupported entity types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100