# Logs # Log Explorer # Query ## Run a log query `client.Logs.LogExplorer.Query.Sql(ctx, params) (*SinglePage[LogExplorerQuerySqlResponse], error)` **post** `/{accounts_or_zones}/{account_or_zone_id}/logs/explorer/query/sql` Run a SQL query against account or zone-level datasets. Timestamp fields are RFC3339 strings. Filter with: WHERE {timestamp_field} >= now() - INTERVAL '30' DAY WHERE {timestamp_field} >= '2026-04-01T00:00:00Z' WHERE {timestamp_field} BETWEEN '2026-04-01T00:00:00Z' AND '2026-04-30T23:59:59Z' Check /account or zones/{account or zone_id}/logs/explorer/datasets to see enabled account or zone level datasets. Zone-level datasets will not appear here. Check /account or zones/{account or zone_id}/logs/explorer/datasets/available for the schemas, and the name of the timestamp fields. For zone-level datasets use the zone-scoped endpoint: POST /zones/{zone_id}/logs/explorer/query/sql For more information about the datasets, and the meaning of each field, check out https://edgetunnel-b2h.pages.dev/logs/logpush/logpush-job/datasets/ ### Parameters - `params LogExplorerQuerySqlParams` - `Body param.Field[Reader]` Body param: SQL query to execute. - `AccountID param.Field[string]` Path param: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - `ZoneID param.Field[string]` Path param: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. ### Returns - `type LogExplorerQuerySqlResponse map[string, unknown]` ### Example ```go package main import ( "bytes" "context" "fmt" "io" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/logs" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.Logs.LogExplorer.Query.Sql(context.TODO(), logs.LogExplorerQuerySqlParams{ Body: io.Reader(bytes.NewBuffer([]byte("Example data"))), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "success": true, "result": [ { "foo": "bar" } ] } ``` # Datasets ## List account or zone datasets `client.Logs.LogExplorer.Datasets.List(ctx, params) (*SinglePage[DatasetSummary], error)` **get** `/{accounts_or_zones}/{account_or_zone_id}/logs/explorer/datasets` Returns all Log Explorer datasets configured for the account or zone. Pass `include_zones=true` to also include zone-level datasets that belong to this account or zone. List responses omit the `fields` property; use the single-dataset endpoint to retrieve field configuration. ### Parameters - `params LogExplorerDatasetListParams` - `AccountID param.Field[string]` Path param: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - `ZoneID param.Field[string]` Path param: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - `IncludeZones param.Field[bool]` Query param: Set to true to include zone-scoped datasets belonging to this account. ### Returns - `type DatasetSummary 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. - `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 DatasetSummaryObjectType` Whether this dataset belongs to an account or a zone. - `const DatasetSummaryObjectTypeAccount DatasetSummaryObjectType = "account"` - `const DatasetSummaryObjectTypeZone DatasetSummaryObjectType = "zone"` - `UpdatedAt Time` RFC3339 timestamp recording when the API last updated this dataset. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/logs" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.Logs.LogExplorer.Datasets.List(context.TODO(), logs.LogExplorerDatasetListParams{ }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "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" } ] } ``` ## Get an account or zone dataset `client.Logs.LogExplorer.Datasets.Get(ctx, datasetID, query) (*Dataset, error)` **get** `/{accounts_or_zones}/{account_or_zone_id}/logs/explorer/datasets/{dataset_id}` Retrieve a single Log Explorer dataset by ID for the account or zone. ### Parameters - `datasetID string` - `query LogExplorerDatasetGetParams` - `AccountID param.Field[string]` The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - `ZoneID param.Field[string]` The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. ### Returns - `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. - `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. - `const DatasetObjectTypeAccount DatasetObjectType = "account"` - `const DatasetObjectTypeZone DatasetObjectType = "zone"` - `UpdatedAt Time` RFC3339 timestamp recording when the API last updated this dataset. - `Fields []DatasetField` The field configuration for this dataset. - `Enabled bool` Whether the API includes this field in log ingest. - `Name string` Field name in lowercase. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/logs" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) dataset, err := client.Logs.LogExplorer.Datasets.Get( context.TODO(), "dataset_id", logs.LogExplorerDatasetGetParams{ }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", dataset.DatasetID) } ``` #### Response ```json { "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" } ] } } ``` ## 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://edgetunnel-b2h.pages.dev/logs/logpush/logpush-job/datasets/ ### Parameters - `params LogExplorerDatasetNewParams` - `CreateRequest param.Field[CreateRequest]` Body param - `AccountID param.Field[string]` Path param: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - `ZoneID param.Field[string]` Path param: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. ### Returns - `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. - `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. - `const DatasetObjectTypeAccount DatasetObjectType = "account"` - `const DatasetObjectTypeZone DatasetObjectType = "zone"` - `UpdatedAt Time` RFC3339 timestamp recording when the API last updated this dataset. - `Fields []DatasetField` The field configuration for this dataset. - `Enabled bool` Whether the API includes this field in log ingest. - `Name string` Field name in lowercase. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/logs" "github.com/cloudflare/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) } ``` #### Response ```json { "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" } ] } } ``` ## Update an account or zone dataset `client.Logs.LogExplorer.Datasets.Update(ctx, datasetID, params) (*Dataset, error)` **put** `/{accounts_or_zones}/{account_or_zone_id}/logs/explorer/datasets/{dataset_id}` Updates the enabled state and/or field configuration of an account or zone dataset. ### Parameters - `datasetID string` - `params LogExplorerDatasetUpdateParams` - `UpdateRequest param.Field[UpdateRequest]` Body param - `AccountID param.Field[string]` Path param: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - `ZoneID param.Field[string]` Path param: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. ### Returns - `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. - `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. - `const DatasetObjectTypeAccount DatasetObjectType = "account"` - `const DatasetObjectTypeZone DatasetObjectType = "zone"` - `UpdatedAt Time` RFC3339 timestamp recording when the API last updated this dataset. - `Fields []DatasetField` The field configuration for this dataset. - `Enabled bool` Whether the API includes this field in log ingest. - `Name string` Field name in lowercase. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/logs" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) dataset, err := client.Logs.LogExplorer.Datasets.Update( context.TODO(), "dataset_id", logs.LogExplorerDatasetUpdateParams{ UpdateRequest: logs.UpdateRequestParam{ Enabled: cloudflare.F(true), }, }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", dataset.DatasetID) } ``` #### Response ```json { "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" } ] } } ``` ## Domain Types ### Create Request - `type CreateRequest struct{…}` - `Dataset string` Dataset type name to create (e.g. `http_requests`). - `Fields []CreateRequestField` Controls which fields the API ingests. Defaults to all available fields when absent. - `Enabled bool` Whether the API includes this field in log ingest. - `Name string` Field name in lowercase. ### Dataset - `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. - `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. - `const DatasetObjectTypeAccount DatasetObjectType = "account"` - `const DatasetObjectTypeZone DatasetObjectType = "zone"` - `UpdatedAt Time` RFC3339 timestamp recording when the API last updated this dataset. - `Fields []DatasetField` The field configuration for this dataset. - `Enabled bool` Whether the API includes this field in log ingest. - `Name string` Field name in lowercase. ### Dataset Summary - `type DatasetSummary 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. - `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 DatasetSummaryObjectType` Whether this dataset belongs to an account or a zone. - `const DatasetSummaryObjectTypeAccount DatasetSummaryObjectType = "account"` - `const DatasetSummaryObjectTypeZone DatasetSummaryObjectType = "zone"` - `UpdatedAt Time` RFC3339 timestamp recording when the API last updated this dataset. ### Update Request - `type UpdateRequest struct{…}` - `Enabled bool` Whether to enable or disable log ingest for this dataset. - `Fields []UpdateRequestField` Controls which fields the API ingests after the update. Defaults to all available fields when absent. - `Enabled bool` Whether the API includes this field in log ingest. - `Name string` Field name in lowercase. # Available ## List available account or zone datasets `client.Logs.LogExplorer.Datasets.Available.List(ctx, query) (*SinglePage[AvailableDataset], error)` **get** `/{accounts_or_zones}/{account_or_zone_id}/logs/explorer/datasets/available` Returns all dataset types that this account or zone can create. Each entry includes the dataset schema and timestamp field. The schema shows all possible fields for a dataset. However, not all fields may be available for your account or zone. When creating or updating a dataset, only fields available to your account or zone can be enabled. If you request a field that is not available, you will receive an error. ### Parameters - `query LogExplorerDatasetAvailableListParams` - `AccountID param.Field[string]` The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - `ZoneID param.Field[string]` The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. ### Returns - `type AvailableDataset struct{…}` A dataset type that the account or zone can create. - `Dataset string` Dataset type name (e.g. `http_requests`). - `ObjectType AvailableDatasetObjectType` Whether this dataset type is account-scoped or zone-scoped. - `const AvailableDatasetObjectTypeAccount AvailableDatasetObjectType = "account"` - `const AvailableDatasetObjectTypeZone AvailableDatasetObjectType = "zone"` - `Schema AvailableDatasetSchema` JSON Schema that describes the fields this dataset exposes. - `Properties map[string, unknown]` - `Required []string` - `Type AvailableDatasetSchemaType` - `const AvailableDatasetSchemaTypeObject AvailableDatasetSchemaType = "object"` - `TimestampField string` The primary timestamp field name for this dataset. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/logs" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.Logs.LogExplorer.Datasets.Available.List(context.TODO(), logs.LogExplorerDatasetAvailableListParams{ }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "success": true, "result": [ { "dataset": "dataset", "object_type": "account", "schema": { "properties": { "foo": "bar" }, "required": [ "string" ], "type": "object" }, "timestamp_field": "timestamp_field" } ] } ``` ## Domain Types ### Available Dataset - `type AvailableDataset struct{…}` A dataset type that the account or zone can create. - `Dataset string` Dataset type name (e.g. `http_requests`). - `ObjectType AvailableDatasetObjectType` Whether this dataset type is account-scoped or zone-scoped. - `const AvailableDatasetObjectTypeAccount AvailableDatasetObjectType = "account"` - `const AvailableDatasetObjectTypeZone AvailableDatasetObjectType = "zone"` - `Schema AvailableDatasetSchema` JSON Schema that describes the fields this dataset exposes. - `Properties map[string, unknown]` - `Required []string` - `Type AvailableDatasetSchemaType` - `const AvailableDatasetSchemaTypeObject AvailableDatasetSchemaType = "object"` - `TimestampField string` The primary timestamp field name for this dataset. ### Available List - `type AvailableList struct{…}` - `Errors []ResponseInfo` - `Code int64` - `Message string` - `DocumentationURL string` - `Source ResponseInfoSource` - `Pointer string` - `Messages []string` - `Success bool` - `Result []AvailableDataset` - `Dataset string` Dataset type name (e.g. `http_requests`). - `ObjectType AvailableDatasetObjectType` Whether this dataset type is account-scoped or zone-scoped. - `const AvailableDatasetObjectTypeAccount AvailableDatasetObjectType = "account"` - `const AvailableDatasetObjectTypeZone AvailableDatasetObjectType = "zone"` - `Schema AvailableDatasetSchema` JSON Schema that describes the fields this dataset exposes. - `Properties map[string, unknown]` - `Required []string` - `Type AvailableDatasetSchemaType` - `const AvailableDatasetSchemaTypeObject AvailableDatasetSchemaType = "object"` - `TimestampField string` The primary timestamp field name for this dataset. # Control # Retention ## Get log retention flag `client.Logs.Control.Retention.Get(ctx, query) (*ControlRetentionGetResponse, error)` **get** `/zones/{zone_id}/logs/control/retention/flag` Gets log retention flag for Logpull API. ### Parameters - `query ControlRetentionGetParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type ControlRetentionGetResponse struct{…}` - `Flag bool` The log retention flag for Logpull API. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/logs" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) retention, err := client.Logs.Control.Retention.Get(context.TODO(), logs.ControlRetentionGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", retention.Flag) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "flag": true } } ``` ## Update log retention flag `client.Logs.Control.Retention.New(ctx, params) (*ControlRetentionNewResponse, error)` **post** `/zones/{zone_id}/logs/control/retention/flag` Updates log retention flag for Logpull API. ### Parameters - `params ControlRetentionNewParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Flag param.Field[bool]` Body param: The log retention flag for Logpull API. ### Returns - `type ControlRetentionNewResponse struct{…}` - `Flag bool` The log retention flag for Logpull API. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/logs" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) retention, err := client.Logs.Control.Retention.New(context.TODO(), logs.ControlRetentionNewParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", retention.Flag) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "flag": true } } ``` # Cmb # Config ## Get CMB config `client.Logs.Control.Cmb.Config.Get(ctx, query) (*CmbConfig, error)` **get** `/accounts/{account_id}/logs/control/cmb/config` Gets CMB config. ### Parameters - `query ControlCmbConfigGetParams` - `AccountID param.Field[string]` Identifier. ### Returns - `type CmbConfig struct{…}` - `AllowOutOfRegionAccess bool` Allow out of region access - `Regions string` Name of the region. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/logs" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) cmbConfig, err := client.Logs.Control.Cmb.Config.Get(context.TODO(), logs.ControlCmbConfigGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", cmbConfig.AllowOutOfRegionAccess) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "allow_out_of_region_access": false, "regions": "eu" } } ``` ## Update CMB config `client.Logs.Control.Cmb.Config.New(ctx, params) (*CmbConfig, error)` **post** `/accounts/{account_id}/logs/control/cmb/config` Updates CMB config. ### Parameters - `params ControlCmbConfigNewParams` - `AccountID param.Field[string]` Path param: Identifier. - `CmbConfig param.Field[CmbConfig]` Body param ### Returns - `type CmbConfig struct{…}` - `AllowOutOfRegionAccess bool` Allow out of region access - `Regions string` Name of the region. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/logs" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) cmbConfig, err := client.Logs.Control.Cmb.Config.New(context.TODO(), logs.ControlCmbConfigNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), CmbConfig: logs.CmbConfigParam{ }, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", cmbConfig.AllowOutOfRegionAccess) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "allow_out_of_region_access": false, "regions": "eu" } } ``` ## Delete CMB config `client.Logs.Control.Cmb.Config.Delete(ctx, body) (*ControlCmbConfigDeleteResponse, error)` **delete** `/accounts/{account_id}/logs/control/cmb/config` Deletes CMB config. ### Parameters - `body ControlCmbConfigDeleteParams` - `AccountID param.Field[string]` Identifier. ### Returns - `type ControlCmbConfigDeleteResponse interface{…}` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/logs" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) config, err := client.Logs.Control.Cmb.Config.Delete(context.TODO(), logs.ControlCmbConfigDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", config) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": {} } ``` ## Domain Types ### Cmb Config - `type CmbConfig struct{…}` - `AllowOutOfRegionAccess bool` Allow out of region access - `Regions string` Name of the region. # RayID ## Get logs RayIDs `client.Logs.RayID.Get(ctx, RayID, params) (*unknown, error)` **get** `/zones/{zone_id}/logs/rayids/{ray_id}` The `/rayids` api route allows lookups by specific rayid. The rayids route will return zero, one, or more records (ray ids are not unique). ### Parameters - `RayID string` Ray identifier. - `params RayIDGetParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Fields param.Field[string]` Query param: The `/received` route by default returns a limited set of fields, and allows customers to override the default field set by specifying individual fields. The reasons for this are: 1. Most customers require only a small subset of fields, but that subset varies from customer to customer; 2. Flat schema is much easier to work with downstream (importing into BigTable etc); 3. Performance (time to process, file size). If `?fields=` is not specified, default field set is returned. This default field set may change at any time. When `?fields=` is provided, each record is returned with the specified fields. `fields` must be specified as a comma separated list without any whitespaces, and all fields must exist. The order in which fields are specified does not matter, and the order of fields in the response is not specified. - `Timestamps param.Field[RayIDGetParamsTimestamps]` Query param: By default, timestamps in responses are returned as Unix nanosecond integers. The `?timestamps=` argument can be set to change the format in which response timestamps are returned. Possible values are: `unix`, `unixnano`, `rfc3339`. Note that `unix` and `unixnano` return timestamps as integers; `rfc3339` returns timestamps as strings. - `const RayIDGetParamsTimestampsUnix RayIDGetParamsTimestamps = "unix"` - `const RayIDGetParamsTimestampsUnixnano RayIDGetParamsTimestamps = "unixnano"` - `const RayIDGetParamsTimestampsRfc3339 RayIDGetParamsTimestamps = "rfc3339"` ### Returns - `type RayIDGetResponse interface{…}` - `unknown` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/logs" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) RayID, err := client.Logs.RayID.Get( context.TODO(), "41ddf1740f67442d", logs.RayIDGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", RayID) } ``` #### Response ```json "{\"ClientIP\":\"192.0.2.1\",\"RayID\":\"41ddf1740f67442d\",\"EdgeStartTimestamp\":1526810289280000000}\n{\"ClientIP\":\"192.0.2.1\",\"RayID\":\"41ddf1740f67442d\",\"EdgeStartTimestamp\":1526810289280000000}\n{\"ClientIP\":\"192.0.2.1\",\"RayID\":\"41ddf1740f67442d\",\"EdgeStartTimestamp\":1526810289280000000}" ``` # Received ## Get logs received `client.Logs.Received.Get(ctx, params) (*unknown, error)` **get** `/zones/{zone_id}/logs/received` The `/received` api route allows customers to retrieve their edge HTTP logs. The basic access pattern is "give me all the logs for zone Z for minute M", where the minute M refers to the time records were received at Cloudflare's central data center. `start` is inclusive, and `end` is exclusive. Because of that, to get all data, at minutely cadence, starting at 10AM, the proper values are: `start=2018-05-20T10:00:00Z&end=2018-05-20T10:01:00Z`, then `start=2018-05-20T10:01:00Z&end=2018-05-20T10:02:00Z` and so on; the overlap will be handled properly. ### Parameters - `params ReceivedGetParams` - `ZoneID param.Field[string]` Path param: Identifier. - `End param.Field[ReceivedGetParamsEndUnion]` Query param: Sets the (exclusive) end of the requested time frame. This can be a unix timestamp (in seconds or nanoseconds), or an absolute timestamp that conforms to RFC 3339. `end` must be at least five minutes earlier than now and must be later than `start`. Difference between `start` and `end` must be not greater than one hour. - `UnionString` - `UnionInt` - `Count param.Field[int64]` Query param: When `?count=` is provided, the response will contain up to `count` results. Since results are not sorted, you are likely to get different data for repeated requests. `count` must be an integer > 0. - `Fields param.Field[string]` Query param: The `/received` route by default returns a limited set of fields, and allows customers to override the default field set by specifying individual fields. The reasons for this are: 1. Most customers require only a small subset of fields, but that subset varies from customer to customer; 2. Flat schema is much easier to work with downstream (importing into BigTable etc); 3. Performance (time to process, file size). If `?fields=` is not specified, default field set is returned. This default field set may change at any time. When `?fields=` is provided, each record is returned with the specified fields. `fields` must be specified as a comma separated list without any whitespaces, and all fields must exist. The order in which fields are specified does not matter, and the order of fields in the response is not specified. - `Sample param.Field[float64]` Query param: When `?sample=` is provided, a sample of matching records is returned. If `sample=0.1` then 10% of records will be returned. Sampling is random: repeated calls will not only return different records, but likely will also vary slightly in number of returned records. When `?count=` is also specified, `count` is applied to the number of returned records, not the sampled records. So, with `sample=0.05` and `count=7`, when there is a total of 100 records available, approximately five will be returned. When there are 1000 records, seven will be returned. When there are 10,000 records, seven will be returned. - `Start param.Field[ReceivedGetParamsStartUnion]` Query param: Sets the (inclusive) beginning of the requested time frame. This can be a unix timestamp (in seconds or nanoseconds), or an absolute timestamp that conforms to RFC 3339. At this point in time, it cannot exceed a time in the past greater than seven days. - `UnionString` - `UnionInt` - `Timestamps param.Field[ReceivedGetParamsTimestamps]` Query param: By default, timestamps in responses are returned as Unix nanosecond integers. The `?timestamps=` argument can be set to change the format in which response timestamps are returned. Possible values are: `unix`, `unixnano`, `rfc3339`. Note that `unix` and `unixnano` return timestamps as integers; `rfc3339` returns timestamps as strings. - `const ReceivedGetParamsTimestampsUnix ReceivedGetParamsTimestamps = "unix"` - `const ReceivedGetParamsTimestampsUnixnano ReceivedGetParamsTimestamps = "unixnano"` - `const ReceivedGetParamsTimestampsRfc3339 ReceivedGetParamsTimestamps = "rfc3339"` ### Returns - `type ReceivedGetResponse interface{…}` - `unknown` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/logs" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/shared" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) received, err := client.Logs.Received.Get(context.TODO(), logs.ReceivedGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), End: cloudflare.F[logs.ReceivedGetParamsEndUnion](shared.UnionString("2018-05-20T10:01:00Z")), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", received) } ``` #### Response ```json "{\"ClientIP\":\"192.0.2.1\",\"RayID\":\"41ddf1740f67442d\",\"EdgeStartTimestamp\":1526810289280000000}\n{\"ClientIP\":\"192.0.2.1\",\"RayID\":\"41ddf1740f67442d\",\"EdgeStartTimestamp\":1526810289280000000}\n{\"ClientIP\":\"192.0.2.1\",\"RayID\":\"41ddf1740f67442d\",\"EdgeStartTimestamp\":1526810289280000000}" ``` # Fields ## List fields `client.Logs.Received.Fields.Get(ctx, query) (*ReceivedFieldGetResponse, error)` **get** `/zones/{zone_id}/logs/received/fields` Lists all fields available. The response is json object with key-value pairs, where keys are field names, and values are descriptions. ### Parameters - `query ReceivedFieldGetParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type ReceivedFieldGetResponse struct{…}` - `Key string` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/logs" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) field, err := client.Logs.Received.Fields.Get(context.TODO(), logs.ReceivedFieldGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", field.Key) } ``` #### Response ```json { "key": "value" } ```