Dynatrace / snippets

This repository contains useful samples and snippets
Apache License 2.0
11 stars 19 forks source link

Error message during script execution #40

Open mackermann2 opened 3 years ago

mackermann2 commented 3 years ago

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"]):

TuomasMetsamaa commented 3 years ago

Hi @mackermann2 - are you able to attach the script with that exception added to it? Failed to add that "if not" myself.