Save query
Persist query for later use.
Security
API Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
X-Auth-Email: user@example.comThe previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYYUser Service Key
Used when interacting with the Origin CA certificates API. View/change your key.
X-Auth-User-Service-Key: v1.0-144c9defac04969c7bfad8ef-631a41d003a32d25fe878081ef365c49503f7fada600da935e2851a1c7326084b85cbf6429c4b859de8475731dc92a9c329631e6d59e6c73da7b198497172b4cefe071d90d0f5d2719Accepted Permissions (at least one required)
Workers Observability WriteParametersExpand Collapse
params ObservabilityQueryNewParams
Parameters param.Field[ObservabilityQueryNewParamsParameters]Body param
Body param
Calculations []ObservabilityQueryNewParamsParametersCalculationOptionalCreate Calculations to compute as part of the query.
Create Calculations to compute as part of the query.
Operator ObservabilityQueryNewParamsParametersCalculationsOperator
KeyType ObservabilityQueryNewParamsParametersCalculationsKeyTypeOptional
FilterCombination ObservabilityQueryNewParamsParametersFilterCombinationOptionalSet a Flag to describe how to combine the filters on the query.
Set a Flag to describe how to combine the filters on the query.
Filters []ObservabilityQueryNewParamsParametersFilterOptionalConfigure the Filters to apply to the query. Supports nested groups via kind: ‘group’.
Configure the Filters to apply to the query. Supports nested groups via kind: ‘group’.
type ObservabilityQueryNewParamsParametersFiltersObject struct{…}
FilterCombination ObservabilityQueryNewParamsParametersFiltersObjectFilterCombination
type ObservabilityQueryNewParamsParametersFiltersWorkersObservabilityFilterLeaf struct{…}A filter condition applied to query results. Use the keys and values endpoints to discover available fields and their values before constructing filters.
A filter condition applied to query results. Use the keys and values endpoints to discover available fields and their values before constructing filters.
Filter field name. Use verified keys from previous query results or the keys endpoint. Common keys include $metadata.service, $metadata.origin, $metadata.trigger, $metadata.message, and $metadata.error.
Operation ObservabilityQueryNewParamsParametersFiltersWorkersObservabilityFilterLeafOperationComparison operator. String operators: includes, not_includes, starts_with, ends_with, regex. Existence: exists, is_null. Set membership: in, not_in (comma-separated values). Numeric: eq, neq, gt, gte, lt, lte.
Comparison operator. String operators: includes, not_includes, starts_with, ends_with, regex. Existence: exists, is_null. Set membership: in, not_in (comma-separated values). Numeric: eq, neq, gt, gte, lt, lte.
Type ObservabilityQueryNewParamsParametersFiltersWorkersObservabilityFilterLeafTypeData type of the filter field. Must match the actual type of the key being filtered.
Data type of the filter field. Must match the actual type of the key being filtered.
Discriminator for leaf filter nodes. Always ‘filter’ when present; may be omitted.
Value ObservabilityQueryNewParamsParametersFiltersWorkersObservabilityFilterLeafValueUnionOptionalComparison value. Must match actual values in your data — verify with the values endpoint. Ensure the value type (string/number/boolean) matches the field type. String comparisons are case-sensitive. Regex uses RE2 syntax (no lookaheads/lookbehinds).
Comparison value. Must match actual values in your data — verify with the values endpoint. Ensure the value type (string/number/boolean) matches the field type. String comparisons are case-sensitive. Regex uses RE2 syntax (no lookaheads/lookbehinds).
GroupBys []ObservabilityQueryNewParamsParametersGroupByOptionalDefine how to group the results of the query.
Define how to group the results of the query.
Type ObservabilityQueryNewParamsParametersGroupBysType
Havings []ObservabilityQueryNewParamsParametersHavingOptionalConfigure the Having clauses that filter on calculations in the query result.
Configure the Having clauses that filter on calculations in the query result.
Operation ObservabilityQueryNewParamsParametersHavingsOperation
Set a limit on the number of results / records returned by the query
Needle ObservabilityQueryNewParamsParametersNeedleOptionalDefine an expression to search using full-text search.
Define an expression to search using full-text search.
ReturnsExpand Collapse
type ObservabilityQueryNewResponse struct{…}
Parameters ObservabilityQueryNewResponseParameters
Calculations []ObservabilityQueryNewResponseParametersCalculationOptionalCreate Calculations to compute as part of the query.
Create Calculations to compute as part of the query.
Operator ObservabilityQueryNewResponseParametersCalculationsOperator
KeyType ObservabilityQueryNewResponseParametersCalculationsKeyTypeOptional
FilterCombination ObservabilityQueryNewResponseParametersFilterCombinationOptionalSet a Flag to describe how to combine the filters on the query.
Set a Flag to describe how to combine the filters on the query.
Filters []ObservabilityQueryNewResponseParametersFilterOptionalConfigure the Filters to apply to the query. Supports nested groups via kind: ‘group’.
Configure the Filters to apply to the query. Supports nested groups via kind: ‘group’.
type ObservabilityQueryNewResponseParametersFiltersObject struct{…}
FilterCombination ObservabilityQueryNewResponseParametersFiltersObjectFilterCombination
type ObservabilityQueryNewResponseParametersFiltersWorkersObservabilityFilterLeaf struct{…}A filter condition applied to query results. Use the keys and values endpoints to discover available fields and their values before constructing filters.
A filter condition applied to query results. Use the keys and values endpoints to discover available fields and their values before constructing filters.
Filter field name. Use verified keys from previous query results or the keys endpoint. Common keys include $metadata.service, $metadata.origin, $metadata.trigger, $metadata.message, and $metadata.error.
Operation ObservabilityQueryNewResponseParametersFiltersWorkersObservabilityFilterLeafOperationComparison operator. String operators: includes, not_includes, starts_with, ends_with, regex. Existence: exists, is_null. Set membership: in, not_in (comma-separated values). Numeric: eq, neq, gt, gte, lt, lte.
Comparison operator. String operators: includes, not_includes, starts_with, ends_with, regex. Existence: exists, is_null. Set membership: in, not_in (comma-separated values). Numeric: eq, neq, gt, gte, lt, lte.
Type ObservabilityQueryNewResponseParametersFiltersWorkersObservabilityFilterLeafTypeData type of the filter field. Must match the actual type of the key being filtered.
Data type of the filter field. Must match the actual type of the key being filtered.
Discriminator for leaf filter nodes. Always ‘filter’ when present; may be omitted.
Value ObservabilityQueryNewResponseParametersFiltersWorkersObservabilityFilterLeafValueUnionOptionalComparison value. Must match actual values in your data — verify with the values endpoint. Ensure the value type (string/number/boolean) matches the field type. String comparisons are case-sensitive. Regex uses RE2 syntax (no lookaheads/lookbehinds).
Comparison value. Must match actual values in your data — verify with the values endpoint. Ensure the value type (string/number/boolean) matches the field type. String comparisons are case-sensitive. Regex uses RE2 syntax (no lookaheads/lookbehinds).
GroupBys []ObservabilityQueryNewResponseParametersGroupByOptionalDefine how to group the results of the query.
Define how to group the results of the query.
Type ObservabilityQueryNewResponseParametersGroupBysType
Havings []ObservabilityQueryNewResponseParametersHavingOptionalConfigure the Having clauses that filter on calculations in the query result.
Configure the Having clauses that filter on calculations in the query result.
Operation ObservabilityQueryNewResponseParametersHavingsOperation
Set a limit on the number of results / records returned by the query
Needle ObservabilityQueryNewResponseParametersNeedleOptionalDefine an expression to search using full-text search.
Define an expression to search using full-text search.
Save query
package main
import (
"context"
"fmt"
"github.com/stainless-sdks/cloudflare-go"
"github.com/stainless-sdks/cloudflare-go/option"
"github.com/stainless-sdks/cloudflare-go/workers"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
option.WithAPIEmail("user@example.com"),
)
query, err := client.Workers.Observability.Queries.New(context.TODO(), workers.ObservabilityQueryNewParams{
AccountID: cloudflare.F("account_id"),
Description: cloudflare.F("Query description"),
Name: cloudflare.F("x"),
Parameters: cloudflare.F(workers.ObservabilityQueryNewParamsParameters{
}),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", query.ID)
}
{
"errors": [
{
"message": "message"
}
],
"messages": [
{
"message": "Successful request"
}
],
"result": {
"id": "id",
"adhoc": true,
"created": "created",
"createdBy": "createdBy",
"description": "Query description",
"name": "x",
"parameters": {
"calculations": [
{
"operator": "uniq",
"alias": "alias",
"key": "key",
"keyType": "string"
}
],
"datasets": [
"string"
],
"filterCombination": "and",
"filters": [
{
"filterCombination": "and",
"filters": [
{}
],
"kind": "group"
}
],
"groupBys": [
{
"type": "string",
"value": "value"
}
],
"havings": [
{
"key": "key",
"operation": "eq",
"value": 0
}
],
"limit": 0,
"needle": {
"value": "string",
"isRegex": true,
"matchCase": true
},
"orderBy": {
"value": "value",
"order": "asc"
}
},
"updated": "updated",
"updatedBy": "updatedBy"
},
"success": true
}Returns Examples
{
"errors": [
{
"message": "message"
}
],
"messages": [
{
"message": "Successful request"
}
],
"result": {
"id": "id",
"adhoc": true,
"created": "created",
"createdBy": "createdBy",
"description": "Query description",
"name": "x",
"parameters": {
"calculations": [
{
"operator": "uniq",
"alias": "alias",
"key": "key",
"keyType": "string"
}
],
"datasets": [
"string"
],
"filterCombination": "and",
"filters": [
{
"filterCombination": "and",
"filters": [
{}
],
"kind": "group"
}
],
"groupBys": [
{
"type": "string",
"value": "value"
}
],
"havings": [
{
"key": "key",
"operation": "eq",
"value": 0
}
],
"limit": 0,
"needle": {
"value": "string",
"isRegex": true,
"matchCase": true
},
"orderBy": {
"value": "value",
"order": "asc"
}
},
"updated": "updated",
"updatedBy": "updatedBy"
},
"success": true
}