Cloudflare 中文文档
Analytics
Analytics
编辑这个页面
跳转官方原文档
Set theme to dark (⇧+D)

Querying Workers Metrics with GraphQL

In this example, we are going to use the GraphQL Analytics API to query for Workers Metrics over a specified time period. We can query up to one month of data for dates up to three months ago.

The following API call will request a Worker script’s metrics over a one day period, and output the requested fields. Be sure to replace <CLOUDFLARE_ACCOUNT_ID>, <EMAIL>, and <API_KEY> with your API credentials, and adjust the datetimeStart, datetimeEnd, and scriptName variables as needed.

​​ API Call

The results returned will be in JSON (as requested), so piping the output to jq will make them easier to read, like in the following example: