Skip to content
Start here

Create an account or zone dataset

client.Logs.LogExplorer.Datasets.New(ctx, params) (*Dataset, error)
POST/{accounts_or_zones}/{account_or_zone_id}/logs/explorer/datasets

Create a new Log Explorer dataset for the account or zone.

Use the /account or zones/{account or zone_id}/logs/explorer/datasets/available endpoint to list dataset types you can create along with their available fields.

The fields property is optional. If not specified, all available fields will be enabled.

For zone-level datasets use the zone-scoped endpoint: POST /zones/{zone_id}/logs/explorer/datasets

For dataset field definitions, see: https://developers.cloudflare.com/logs/logpush/logpush-job/datasets/

Security

API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
Accepted Permissions (at least one required)
Logs Write
ParametersExpand Collapse
params LogExplorerDatasetNewParams
CreateRequest param.Field[CreateRequest]

Body param

AccountID param.Field[string]Optional

Path param: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.

ZoneID param.Field[string]Optional

Path param: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.

ReturnsExpand Collapse
type Dataset struct{…}

A Log Explorer dataset summary. List endpoints return this type and omit field configuration; use the single-dataset endpoint to retrieve it.

CreatedAt Time

RFC3339 timestamp recording when the API created this dataset.

formatdate-time
Dataset string

Dataset type name (e.g. http_requests).

DatasetID string

Unique dataset ID.

Enabled bool

Whether log ingest is currently active for this dataset.

ObjectID string

Public ID of the account or zone that owns this dataset.

ObjectType DatasetObjectType

Whether this dataset belongs to an account or a zone.

One of the following:
const DatasetObjectTypeAccount DatasetObjectType = "account"
const DatasetObjectTypeZone DatasetObjectType = "zone"
UpdatedAt Time

RFC3339 timestamp recording when the API last updated this dataset.

formatdate-time
Fields []DatasetFieldOptional

The field configuration for this dataset.

Enabled bool

Whether the API includes this field in log ingest.

Name string

Field name in lowercase.

Create an account or zone dataset

package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/cloudflare-go"
  "github.com/stainless-sdks/cloudflare-go/logs"
  "github.com/stainless-sdks/cloudflare-go/option"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  dataset, err := client.Logs.LogExplorer.Datasets.New(context.TODO(), logs.LogExplorerDatasetNewParams{
    CreateRequest: logs.CreateRequestParam{
      Dataset: cloudflare.F("dataset"),
    },
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", dataset.DatasetID)
}
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "success": true,
  "result": {
    "created_at": "2019-12-27T18:11:19.117Z",
    "dataset": "dataset",
    "dataset_id": "dataset_id",
    "enabled": true,
    "object_id": "object_id",
    "object_type": "account",
    "updated_at": "2019-12-27T18:11:19.117Z",
    "fields": [
      {
        "enabled": true,
        "name": "name"
      }
    ]
  }
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "success": true,
  "result": {
    "created_at": "2019-12-27T18:11:19.117Z",
    "dataset": "dataset",
    "dataset_id": "dataset_id",
    "enabled": true,
    "object_id": "object_id",
    "object_type": "account",
    "updated_at": "2019-12-27T18:11:19.117Z",
    "fields": [
      {
        "enabled": true,
        "name": "name"
      }
    ]
  }
}