DQL
Questions about Dynatrace Query Language
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DQL query syntax while using in API calls

harinhs
Visitor

I am trying to use this query to fetch remote environment data, but not working for remote environment through API call. But this works in local environment to get the host availability, 

fetch dt.entity.host
| filterOut isMonitoringCandidate == true or standalone == true
| lookup [
timeseries m1=max(dt.host.availability, rollup: sum),
filter: availability.state == "up",
by: {availability.state,dt.entity.host},
from: toTimestamp($dt_timeframe_from),
to: toTimestamp($dt_timeframe_to) - 2m
| parse replaceString(toString(m1),"null","0"), """'['ARRAY{ DOUBLE:i ', '}{1,10000}:m1Pop"""
| fieldsAdd intervalToMinutes = toLong(interval) / 60 / power(10, 9)
| fieldsAdd availability = toDouble(arraySum(m1Pop) / arraySize(m1Pop) * 100) / intervalToMinutes
], sourceField: id, lookupField: dt.entity.host, fields: {availability}
| fields id, availability = coalesce(availability, 0)
| summarize avg(availability)

 

 

How to parse this query in the API call section, I tried giving this like other queries but getting 400 Bad request error. 

const credentialId = "CREDENTIALS_VAULT-XXXXXXXX"; // Replace with your credential vault ID.
const url = "https://{environmentid}.apps.dynatrace.com/platform/storage/query/v1/query:execute"; // Replace with API URL.
const query = "<how to give the above DQL query as string here> "; // Replace with your query.

Could you please help? Thanks in advance. 

0 REPLIES 0

Featured Posts