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
ReturnsExpand Collapse
SharedQueryGetResponse { run, statistics, agents, 6 more } 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: Run { id, accountId, dry, 8 more } Represents 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: Query { id, adhoc, created, 6 more } A saved query definition with its parameters, metadata, and ownership information.
A saved query definition with its parameters, metadata, and ownership information.
parameters: Parameters { calculations, datasets, filterCombination, 6 more }
calculations?: Array<UnionMember0 { operator, alias, key, keyType } | UnionMember1 { key, operator, alias, keyType } >Create Calculations to compute as part of the query.
Create Calculations to compute as part of the query.
filterCombination?: "and" | "or" | "AND" | "OR"Set 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?: Array<UnionMember0 { filterCombination, filters, kind } | WorkersObservabilityFilterLeaf { key, operation, type, 2 more } >Configure 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’.
WorkersObservabilityFilterLeaf { key, operation, type, 2 more } 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: "includes" | "not_includes" | "starts_with" | 27 moreComparison 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: "string" | "number" | "boolean"Data 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.
havings?: Array<Having>Configure the Having clauses that filter on calculations in the query result.
Configure the Having clauses that filter on calculations in the query result.
Set a limit on the number of results / records returned by the query
statistics: Statistics { bytes_read, elapsed, rows_read, abr_level } Query 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?: Array<Agent>Agent run summaries. Present when the query view is ‘agents’. Each entry represents one trace containing at least one agent invocation.
Agent run summaries. Present when the query view is ‘agents’. Each entry represents one trace containing at least one agent invocation.
calculations?: Array<Calculation>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.
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?: Array<Compare>Comparison 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.
distribution?: Distribution { bins, bucketBoundaries, bucketMode, 2 more } Bucketed 2D histogram of a numeric field over time. Present when chartType is ‘distribution’.
Bucketed 2D histogram of a numeric field over time. Present when chartType is ‘distribution’.
events?: Events { count, events, fields, series } Individual 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?: Array<Event>List of individual telemetry events matching the query.
List of individual telemetry events matching the query.
"$metadata": Metadata { id, account, cloudService, 29 more } Structured 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.
source: string | Record<string, unknown>Raw 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"?: UnionMember0 { eventType, requestId, scriptName, 10 more } | UnionMember1 { cpuTimeMs, eventType, outcome, 14 more } Cloudflare 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.
fields?: Array<Field>List 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?: Record<string, Array<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.
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": Metadata { id, account, cloudService, 29 more } Structured 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.
source: string | Record<string, unknown>Raw 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"?: UnionMember0 { eventType, requestId, scriptName, 10 more } | UnionMember1 { cpuTimeMs, eventType, outcome, 14 more } Cloudflare 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.
View a query that has been shared
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiEmail: process.env['CLOUDFLARE_EMAIL'], // This is the default and can be omitted
apiKey: process.env['CLOUDFLARE_API_KEY'], // This is the default and can be omitted
});
const sharedQuery = await client.workers.observability.sharedQueries.get('id', {
account_id: 'account_id',
});
console.log(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": "count",
"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": [
{
"id": "id",
"errors": [
"string"
],
"models": [
"string"
],
"providers": [
"string"
],
"services": [
"string"
],
"spans": 0,
"status": "completed",
"traceDurationMs": 0,
"traceEndMs": 0,
"traceId": "traceId",
"traceStartMs": 0,
"agentId": "agentId",
"agentName": "agentName",
"conversationId": "conversationId",
"inputTokens": 0,
"outputTokens": 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"
}
],
"distribution": {
"bins": [
"string"
],
"bucketBoundaries": [
0
],
"bucketMode": "log",
"buckets": [
"string"
],
"matrix": [
[
0
]
]
},
"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",
"rayId": "rayId",
"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",
"rayId": "rayId",
"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": "count",
"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": [
{
"id": "id",
"errors": [
"string"
],
"models": [
"string"
],
"providers": [
"string"
],
"services": [
"string"
],
"spans": 0,
"status": "completed",
"traceDurationMs": 0,
"traceEndMs": 0,
"traceId": "traceId",
"traceStartMs": 0,
"agentId": "agentId",
"agentName": "agentName",
"conversationId": "conversationId",
"inputTokens": 0,
"outputTokens": 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"
}
],
"distribution": {
"bins": [
"string"
],
"bucketBoundaries": [
0
],
"bucketMode": "log",
"buckets": [
"string"
],
"matrix": [
[
0
]
]
},
"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",
"rayId": "rayId",
"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",
"rayId": "rayId",
"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
}