View a query that has been shared
Shared queries store the results of a previously run query, allowing you to share the results with others.
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 WriteWorkers Observability ReadParametersExpand Collapse
params ObservabilitySharedQueryGetParams
Query param: Select the view of the query result to return, defaults to events.
Query param: Select the view of the query result to return, defaults to events.
ReturnsExpand Collapse
type ObservabilitySharedQueryGetResponse struct{…}Complete results of a query run. The populated fields depend on the requested view type (events, calculations, invocations, traces, or agents).
Complete results of a query run. The populated fields depend on the requested view type (events, calculations, invocations, traces, or agents).
Run ObservabilitySharedQueryGetResponseRunRepresents a single execution of a query against Workers Observability data, including the query definition, execution status, and performance statistics.
Represents a single execution of a query against Workers Observability data, including the query definition, execution status, and performance statistics.
Number of time-series buckets used for the query. Higher values produce more detailed series data.
Query ObservabilitySharedQueryGetResponseRunQueryA saved query definition with its parameters, metadata, and ownership information.
A saved query definition with its parameters, metadata, and ownership information.
Parameters ObservabilitySharedQueryGetResponseRunQueryParameters
Calculations []ObservabilitySharedQueryGetResponseRunQueryParametersCalculationOptionalCreate Calculations to compute as part of the query.
Create Calculations to compute as part of the query.
Operator ObservabilitySharedQueryGetResponseRunQueryParametersCalculationsOperator
KeyType ObservabilitySharedQueryGetResponseRunQueryParametersCalculationsKeyTypeOptional
FilterCombination ObservabilitySharedQueryGetResponseRunQueryParametersFilterCombinationOptionalSet 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 []ObservabilitySharedQueryGetResponseRunQueryParametersFilterOptionalConfigure 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 ObservabilitySharedQueryGetResponseRunQueryParametersFiltersObject struct{…}
FilterCombination ObservabilitySharedQueryGetResponseRunQueryParametersFiltersObjectFilterCombination
type ObservabilitySharedQueryGetResponseRunQueryParametersFiltersWorkersObservabilityFilterLeaf 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 ObservabilitySharedQueryGetResponseRunQueryParametersFiltersWorkersObservabilityFilterLeafOperationComparison 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 ObservabilitySharedQueryGetResponseRunQueryParametersFiltersWorkersObservabilityFilterLeafTypeData 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 ObservabilitySharedQueryGetResponseRunQueryParametersFiltersWorkersObservabilityFilterLeafValueUnionOptionalComparison 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 []ObservabilitySharedQueryGetResponseRunQueryParametersGroupByOptionalDefine how to group the results of the query.
Define how to group the results of the query.
Type ObservabilitySharedQueryGetResponseRunQueryParametersGroupBysType
Havings []ObservabilitySharedQueryGetResponseRunQueryParametersHavingOptionalConfigure the Having clauses that filter on calculations in the query result.
Configure the Having clauses that filter on calculations in the query result.
Operation ObservabilitySharedQueryGetResponseRunQueryParametersHavingsOperation
Set a limit on the number of results / records returned by the query
Needle ObservabilitySharedQueryGetResponseRunQueryParametersNeedleOptionalDefine an expression to search using full-text search.
Define an expression to search using full-text search.
Statistics ObservabilitySharedQueryGetResponseStatisticsQuery performance statistics from the database. Includes execution time, rows scanned, and bytes read. Does not include network latency.
Query performance statistics from the database. Includes execution time, rows scanned, and bytes read. Does not include network latency.
Agents []ObservabilitySharedQueryGetResponseAgentOptionalDurable Object agent summaries. Present when the query view is ‘agents’. Each entry represents an agent with its event counts and status.
Durable Object agent summaries. Present when the query view is ‘agents’. Each entry represents an agent with its event counts and status.
Calculations []ObservabilitySharedQueryGetResponseCalculationOptionalAggregated calculation results. Present when the query view is ‘calculations’. Contains computed metrics (count, avg, p99, etc.) with optional group-by breakdowns and time-series data.
Aggregated calculation results. Present when the query view is ‘calculations’. Contains computed metrics (count, avg, p99, etc.) with optional group-by breakdowns and time-series data.
Compare []ObservabilitySharedQueryGetResponseCompareOptionalComparison calculation results from the previous time period. Present when the compare option is enabled. Same structure as calculations.
Comparison calculation results from the previous time period. Present when the compare option is enabled. Same structure as calculations.
Events ObservabilitySharedQueryGetResponseEventsOptionalIndividual event results. Present when the query view is ‘events’. Contains the matching log lines and their metadata.
Individual event results. Present when the query view is ‘events’. Contains the matching log lines and their metadata.
Total number of events matching the query (may exceed the number returned due to limits).
Events []ObservabilitySharedQueryGetResponseEventsEventOptionalList of individual telemetry events matching the query.
List of individual telemetry events matching the query.
Metadata ObservabilitySharedQueryGetResponseEventsEventsMetadataStructured metadata extracted from the event. These fields are indexed and available for filtering and aggregation.
Structured metadata extracted from the event. These fields are indexed and available for filtering and aggregation.
Templatized version of the error message used for grouping similar errors.
Templatized version of the log message used for grouping similar messages.
Source ObservabilitySharedQueryGetResponseEventsEventsSourceUnionRaw log payload. May be a string or a structured object depending on how the log was emitted.
Raw log payload. May be a string or a structured object depending on how the log was emitted.
Cloudflare Containers event information that enriches your logs for identifying and debugging issues.
Workers ObservabilitySharedQueryGetResponseEventsEventsWorkersOptionalCloudflare Workers event information that enriches your logs for identifying and debugging issues.
Cloudflare Workers event information that enriches your logs for identifying and debugging issues.
type ObservabilitySharedQueryGetResponseEventsEventsWorkersObject struct{…}
EventType ObservabilitySharedQueryGetResponseEventsEventsWorkersObjectEventType
ExecutionModel ObservabilitySharedQueryGetResponseEventsEventsWorkersObjectExecutionModelOptional
type ObservabilitySharedQueryGetResponseEventsEventsWorkersObject struct{…}
EventType ObservabilitySharedQueryGetResponseEventsEventsWorkersObjectEventType
DiagnosticsChannelEvents []ObservabilitySharedQueryGetResponseEventsEventsWorkersObjectDiagnosticsChannelEventOptional
ExecutionModel ObservabilitySharedQueryGetResponseEventsEventsWorkersObjectExecutionModelOptional
Fields []ObservabilitySharedQueryGetResponseEventsFieldOptionalList of fields discovered in the matched events. Useful for building dynamic UIs.
List of fields discovered in the matched events. Useful for building dynamic UIs.
Invocations map[string, []ObservabilitySharedQueryGetResponseInvocation]OptionalEvents grouped by invocation (request ID). Present when the query view is ‘invocations’. Each key is a request ID mapping to all events from that invocation.
Events grouped by invocation (request ID). Present when the query view is ‘invocations’. Each key is a request ID mapping to all events from that invocation.
Metadata ObservabilitySharedQueryGetResponseInvocationsMetadataStructured metadata extracted from the event. These fields are indexed and available for filtering and aggregation.
Structured metadata extracted from the event. These fields are indexed and available for filtering and aggregation.
Templatized version of the error message used for grouping similar errors.
Templatized version of the log message used for grouping similar messages.
Source ObservabilitySharedQueryGetResponseInvocationsSourceUnionRaw log payload. May be a string or a structured object depending on how the log was emitted.
Raw log payload. May be a string or a structured object depending on how the log was emitted.
Cloudflare Containers event information that enriches your logs for identifying and debugging issues.
Workers ObservabilitySharedQueryGetResponseInvocationsWorkersOptionalCloudflare Workers event information that enriches your logs for identifying and debugging issues.
Cloudflare Workers event information that enriches your logs for identifying and debugging issues.
type ObservabilitySharedQueryGetResponseInvocationsWorkersObject struct{…}
EventType ObservabilitySharedQueryGetResponseInvocationsWorkersObjectEventType
ExecutionModel ObservabilitySharedQueryGetResponseInvocationsWorkersObjectExecutionModelOptional
type ObservabilitySharedQueryGetResponseInvocationsWorkersObject struct{…}
EventType ObservabilitySharedQueryGetResponseInvocationsWorkersObjectEventType
DiagnosticsChannelEvents []ObservabilitySharedQueryGetResponseInvocationsWorkersObjectDiagnosticsChannelEventOptional
ExecutionModel ObservabilitySharedQueryGetResponseInvocationsWorkersObjectExecutionModelOptional
View a query that has been shared
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"),
)
sharedQuery, err := client.Workers.Observability.SharedQueries.Get(
context.TODO(),
"id",
workers.ObservabilitySharedQueryGetParams{
AccountID: cloudflare.F("account_id"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", sharedQuery.Run)
}
{
"errors": [
{
"message": "message"
}
],
"messages": [
{
"message": "Successful request"
}
],
"result": {
"run": {
"id": "id",
"accountId": "accountId",
"dry": true,
"granularity": 0,
"query": {
"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": {
"0": "s",
"1": "t",
"2": "r",
"3": "i",
"4": "n",
"5": "g"
},
"isRegex": true,
"matchCase": true
},
"orderBy": {
"value": "value",
"order": "asc"
}
},
"updated": "updated",
"updatedBy": "updatedBy"
},
"status": "STARTED",
"timeframe": {
"from": 0,
"to": 0
},
"userId": "userId",
"created": "created",
"statistics": {
"bytes_read": 0,
"elapsed": 0,
"rows_read": 0,
"abr_level": 0
},
"updated": "updated"
},
"statistics": {
"bytes_read": 0,
"elapsed": 0,
"rows_read": 0,
"abr_level": 0
},
"agents": [
{
"agentClass": "agentClass",
"eventTypeCounts": {
"foo": 0
},
"firstEventMs": 0,
"hasErrors": true,
"lastEventMs": 0,
"namespace": "namespace",
"service": "service",
"totalEvents": 0
}
],
"calculations": [
{
"aggregates": [
{
"count": 0,
"interval": 0,
"sampleInterval": 0,
"value": 0,
"groups": [
{
"key": "key",
"value": "string"
}
]
}
],
"calculation": "calculation",
"series": [
{
"data": [
{
"count": 0,
"interval": 0,
"sampleInterval": 0,
"value": 0,
"firstSeen": "firstSeen",
"groups": [
{
"key": "key",
"value": "string"
}
],
"lastSeen": "lastSeen"
}
],
"time": "time"
}
],
"alias": "alias"
}
],
"compare": [
{
"aggregates": [
{
"count": 0,
"interval": 0,
"sampleInterval": 0,
"value": 0,
"groups": [
{
"key": "key",
"value": "string"
}
]
}
],
"calculation": "calculation",
"series": [
{
"data": [
{
"count": 0,
"interval": 0,
"sampleInterval": 0,
"value": 0,
"firstSeen": "firstSeen",
"groups": [
{
"key": "key",
"value": "string"
}
],
"lastSeen": "lastSeen"
}
],
"time": "time"
}
],
"alias": "alias"
}
],
"events": {
"count": 0,
"events": [
{
"$metadata": {
"id": "id",
"account": "account",
"cloudService": "cloudService",
"coldStart": 1,
"cost": 1,
"duration": 1,
"endTime": 0,
"error": "error",
"errorTemplate": "errorTemplate",
"fingerprint": "fingerprint",
"level": "level",
"message": "message",
"messageTemplate": "messageTemplate",
"metricName": "metricName",
"origin": "origin",
"parentSpanId": "parentSpanId",
"provider": "provider",
"region": "region",
"requestId": "requestId",
"service": "service",
"spanId": "spanId",
"spanName": "spanName",
"stackId": "stackId",
"startTime": 0,
"statusCode": 1,
"traceDuration": 1,
"traceId": "traceId",
"transactionName": "transactionName",
"trigger": "trigger",
"type": "type",
"url": "url"
},
"dataset": "dataset",
"source": "string",
"timestamp": 0,
"$containers": {
"foo": "bar"
},
"$workers": {
"eventType": "fetch",
"requestId": "requestId",
"scriptName": "scriptName",
"durableObjectId": "durableObjectId",
"entrypoint": "entrypoint",
"event": {
"foo": "bar"
},
"executionModel": "durableObject",
"outcome": "outcome",
"preview": {
"id": "id",
"name": "name",
"slug": "slug"
},
"scriptVersion": {
"id": "id",
"message": "message",
"tag": "tag"
},
"spanId": "spanId",
"traceId": "traceId",
"truncated": true
}
}
],
"fields": [
{
"key": "key",
"type": "type"
}
],
"series": [
{
"data": [
{
"aggregates": {
"_count": 1,
"_interval": 1,
"_firstSeen": "_firstSeen",
"_lastSeen": "_lastSeen",
"bin": {}
},
"count": 0,
"interval": 0,
"sampleInterval": 0,
"errors": 0,
"groups": {
"foo": "string"
}
}
],
"time": "time"
}
]
},
"invocations": {
"foo": [
{
"$metadata": {
"id": "id",
"account": "account",
"cloudService": "cloudService",
"coldStart": 1,
"cost": 1,
"duration": 1,
"endTime": 0,
"error": "error",
"errorTemplate": "errorTemplate",
"fingerprint": "fingerprint",
"level": "level",
"message": "message",
"messageTemplate": "messageTemplate",
"metricName": "metricName",
"origin": "origin",
"parentSpanId": "parentSpanId",
"provider": "provider",
"region": "region",
"requestId": "requestId",
"service": "service",
"spanId": "spanId",
"spanName": "spanName",
"stackId": "stackId",
"startTime": 0,
"statusCode": 1,
"traceDuration": 1,
"traceId": "traceId",
"transactionName": "transactionName",
"trigger": "trigger",
"type": "type",
"url": "url"
},
"dataset": "dataset",
"source": "string",
"timestamp": 0,
"$containers": {
"foo": "bar"
},
"$workers": {
"eventType": "fetch",
"requestId": "requestId",
"scriptName": "scriptName",
"durableObjectId": "durableObjectId",
"entrypoint": "entrypoint",
"event": {
"foo": "bar"
},
"executionModel": "durableObject",
"outcome": "outcome",
"preview": {
"id": "id",
"name": "name",
"slug": "slug"
},
"scriptVersion": {
"id": "id",
"message": "message",
"tag": "tag"
},
"spanId": "spanId",
"traceId": "traceId",
"truncated": true
}
}
]
},
"traces": [
{
"rootSpanName": "rootSpanName",
"rootTransactionName": "rootTransactionName",
"service": [
"string"
],
"spans": 0,
"traceDurationMs": 0,
"traceEndMs": 0,
"traceId": "traceId",
"traceStartMs": 0,
"errors": [
"string"
]
}
]
},
"success": true
}Returns Examples
{
"errors": [
{
"message": "message"
}
],
"messages": [
{
"message": "Successful request"
}
],
"result": {
"run": {
"id": "id",
"accountId": "accountId",
"dry": true,
"granularity": 0,
"query": {
"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": {
"0": "s",
"1": "t",
"2": "r",
"3": "i",
"4": "n",
"5": "g"
},
"isRegex": true,
"matchCase": true
},
"orderBy": {
"value": "value",
"order": "asc"
}
},
"updated": "updated",
"updatedBy": "updatedBy"
},
"status": "STARTED",
"timeframe": {
"from": 0,
"to": 0
},
"userId": "userId",
"created": "created",
"statistics": {
"bytes_read": 0,
"elapsed": 0,
"rows_read": 0,
"abr_level": 0
},
"updated": "updated"
},
"statistics": {
"bytes_read": 0,
"elapsed": 0,
"rows_read": 0,
"abr_level": 0
},
"agents": [
{
"agentClass": "agentClass",
"eventTypeCounts": {
"foo": 0
},
"firstEventMs": 0,
"hasErrors": true,
"lastEventMs": 0,
"namespace": "namespace",
"service": "service",
"totalEvents": 0
}
],
"calculations": [
{
"aggregates": [
{
"count": 0,
"interval": 0,
"sampleInterval": 0,
"value": 0,
"groups": [
{
"key": "key",
"value": "string"
}
]
}
],
"calculation": "calculation",
"series": [
{
"data": [
{
"count": 0,
"interval": 0,
"sampleInterval": 0,
"value": 0,
"firstSeen": "firstSeen",
"groups": [
{
"key": "key",
"value": "string"
}
],
"lastSeen": "lastSeen"
}
],
"time": "time"
}
],
"alias": "alias"
}
],
"compare": [
{
"aggregates": [
{
"count": 0,
"interval": 0,
"sampleInterval": 0,
"value": 0,
"groups": [
{
"key": "key",
"value": "string"
}
]
}
],
"calculation": "calculation",
"series": [
{
"data": [
{
"count": 0,
"interval": 0,
"sampleInterval": 0,
"value": 0,
"firstSeen": "firstSeen",
"groups": [
{
"key": "key",
"value": "string"
}
],
"lastSeen": "lastSeen"
}
],
"time": "time"
}
],
"alias": "alias"
}
],
"events": {
"count": 0,
"events": [
{
"$metadata": {
"id": "id",
"account": "account",
"cloudService": "cloudService",
"coldStart": 1,
"cost": 1,
"duration": 1,
"endTime": 0,
"error": "error",
"errorTemplate": "errorTemplate",
"fingerprint": "fingerprint",
"level": "level",
"message": "message",
"messageTemplate": "messageTemplate",
"metricName": "metricName",
"origin": "origin",
"parentSpanId": "parentSpanId",
"provider": "provider",
"region": "region",
"requestId": "requestId",
"service": "service",
"spanId": "spanId",
"spanName": "spanName",
"stackId": "stackId",
"startTime": 0,
"statusCode": 1,
"traceDuration": 1,
"traceId": "traceId",
"transactionName": "transactionName",
"trigger": "trigger",
"type": "type",
"url": "url"
},
"dataset": "dataset",
"source": "string",
"timestamp": 0,
"$containers": {
"foo": "bar"
},
"$workers": {
"eventType": "fetch",
"requestId": "requestId",
"scriptName": "scriptName",
"durableObjectId": "durableObjectId",
"entrypoint": "entrypoint",
"event": {
"foo": "bar"
},
"executionModel": "durableObject",
"outcome": "outcome",
"preview": {
"id": "id",
"name": "name",
"slug": "slug"
},
"scriptVersion": {
"id": "id",
"message": "message",
"tag": "tag"
},
"spanId": "spanId",
"traceId": "traceId",
"truncated": true
}
}
],
"fields": [
{
"key": "key",
"type": "type"
}
],
"series": [
{
"data": [
{
"aggregates": {
"_count": 1,
"_interval": 1,
"_firstSeen": "_firstSeen",
"_lastSeen": "_lastSeen",
"bin": {}
},
"count": 0,
"interval": 0,
"sampleInterval": 0,
"errors": 0,
"groups": {
"foo": "string"
}
}
],
"time": "time"
}
]
},
"invocations": {
"foo": [
{
"$metadata": {
"id": "id",
"account": "account",
"cloudService": "cloudService",
"coldStart": 1,
"cost": 1,
"duration": 1,
"endTime": 0,
"error": "error",
"errorTemplate": "errorTemplate",
"fingerprint": "fingerprint",
"level": "level",
"message": "message",
"messageTemplate": "messageTemplate",
"metricName": "metricName",
"origin": "origin",
"parentSpanId": "parentSpanId",
"provider": "provider",
"region": "region",
"requestId": "requestId",
"service": "service",
"spanId": "spanId",
"spanName": "spanName",
"stackId": "stackId",
"startTime": 0,
"statusCode": 1,
"traceDuration": 1,
"traceId": "traceId",
"transactionName": "transactionName",
"trigger": "trigger",
"type": "type",
"url": "url"
},
"dataset": "dataset",
"source": "string",
"timestamp": 0,
"$containers": {
"foo": "bar"
},
"$workers": {
"eventType": "fetch",
"requestId": "requestId",
"scriptName": "scriptName",
"durableObjectId": "durableObjectId",
"entrypoint": "entrypoint",
"event": {
"foo": "bar"
},
"executionModel": "durableObject",
"outcome": "outcome",
"preview": {
"id": "id",
"name": "name",
"slug": "slug"
},
"scriptVersion": {
"id": "id",
"message": "message",
"tag": "tag"
},
"spanId": "spanId",
"traceId": "traceId",
"truncated": true
}
}
]
},
"traces": [
{
"rootSpanName": "rootSpanName",
"rootTransactionName": "rootTransactionName",
"service": [
"string"
],
"spans": 0,
"traceDurationMs": 0,
"traceEndMs": 0,
"traceId": "traceId",
"traceStartMs": 0,
"errors": [
"string"
]
}
]
},
"success": true
}