1 of 20
2 of 20
3 of 20
4 of 20
5 of 20
6 of 20
7 of 20
8 of 20
9 of 20
10 of 20
11 of 20
12 of 20
13 of 20
14 of 20
15 of 20
16 of 20
17 of 20
18 of 20
19 of 20
20 of 20

doc

Queries GraphQL API

Queries are the starting point to begin consulting information as you use a query to request information from a database. The GraphQL API relies on queries to fetch values and send the requested data as a response with a similar format in a JSON file.

The use of queries enables requesting and fetching specific data. This means you can get a response to your request even with a small query if you don’t want to see data that isn’t essential at that moment. Using queries also means you get faster responses, as the GraphQL API doesn’t need to fetch unnecessary amount of data.

Queries also make it easier for you to add or delete information from your request. For example, if you request data for httpMetrics:

query HttpQuery {
  httpMetrics(
    limit: 2
    filter: {
      tsRange: {begin:"2022-10-20T10:10:10", end:"2022-10-23T10:10:10"}
    }
  ) 
  {	
    ts
    sourceLocPop
    requests
  }
}

And decide you want to add idnsQueriesMetrics to your request, you can add a similar query, only changing the dataset you want to fetch, and run another request:

query IdnsQuery {
  idnsQueriesMetrics(
    limit: 2
    filter: {
      tsRange: {begin:"2022-10-20T10:10:10", end:"2022-10-23T10:10:10"}
    }
  ) 
  {	
    ts
    sourceLocPop
    requests
  }
}

By using queries, your requests and responses also become more organized. Due to GraphQL’s ability to adapt, you can make several calls to the API and still receive only the data you requested in an organized JSON result.

Using the GraphQL API and its features also improve your performance.


Operators

Operators are special keys that allow you to customize your query to perform from basic to more complex logical comparisons. You can use them for both the Metrics GraphQL and the Events GraphQL.

Depending on the operator you use, you’ll change the condition you’re querying for and receive different results. The following operators can be used with GraphQL:

Key Description GraphQL Operator
eq Consults data that are an exact match, equal, to the specified value. Eq
ne Consults data that are different, not equal, from the specified value. Ne
like Consults data that are like the specified value, with case-sensitive values. Like
ilike Consults data that are insensitive like the specified value, with case-insensitive values. Ilike
is_null Consults data that are null or aren’t null compared to the specified value, using true or false. IsNull
in Consults data contained in a given list, in, the specified value. In
not_in Consults data that aren’t in a given list, not in, the specified value. NotIn
lt Consults data with values smaller than, less than, the specified value. Lt
lte Consults data with values smaller or equal, less than or equal, to the specified value. Lte
gt Consults data with values larger, greater than, the specified value. Gt
gte Consults data with values larger or equal, greater than or equal, to the specified value. Gte
range Consults data that are part of the range of the specified values. Range

If you’re using the Like and Ilike operators, you must also pass the identifier % inside the field in the position you want to use:

Identifier position Description Example
End Any string that starts with the characters. “Braz%”
Beginning Any string that ends with the characters. “%ao Paulo”
End and beginning Any string that contains the characters. “%ttp%”

Here are a few examples of fields with an operator:

Operator Example Description
Eq upstreamCacheStatusEq: “HIT” Searches everything that matches exactly the HIT value in the upstreamCacheStatus field.
Ne geolocCountryNameNe: “Brazil” Searches everything that isn’t Brazil in the geolocCountryName field.
Like hostLike: “%mysite.com%” Searches everything for hosts with the particular mysite.com pattern and is case-sensitive.
Ilike hostIlike: “%mysite.com%” Searches everything for hosts with the particular mysite.com pattern and is case-insensitive.

Depending on the type of field of a dataset you’re querying for, you’ll get to use different operators:

Field type Possible operators
String Eq, Ne, Like, Ilike, In, NotIn, IsNull
Integer, Float, DateTime Eq, Lt, Lte, Gt, Gte, Ne, In, NotIn, IsNull, Range

Didn’t find what you were looking for? Open a support ticket.