# Logs # Control # Retention ## Get log retention flag `client.logs.control.retention.get(RetentionGetParamsparams, RequestOptionsoptions?): RetentionGetResponse | null` **get** `/zones/{zone_id}/logs/control/retention/flag` Gets log retention flag for Logpull API. ### Parameters - `params: RetentionGetParams` - `zone_id: string` Identifier. ### Returns - `RetentionGetResponse` - `flag?: boolean` The log retention flag for Logpull API. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const retention = await client.logs.control.retention.get({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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.create(RetentionCreateParamsparams, RequestOptionsoptions?): RetentionCreateResponse | null` **post** `/zones/{zone_id}/logs/control/retention/flag` Updates log retention flag for Logpull API. ### Parameters - `params: RetentionCreateParams` - `zone_id: string` Path param: Identifier. - `flag?: boolean` Body param: The log retention flag for Logpull API. ### Returns - `RetentionCreateResponse` - `flag?: boolean` The log retention flag for Logpull API. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const retention = await client.logs.control.retention.create({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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 } } ``` ## Domain Types ### Retention Get Response - `RetentionGetResponse` - `flag?: boolean` The log retention flag for Logpull API. ### Retention Create Response - `RetentionCreateResponse` - `flag?: boolean` The log retention flag for Logpull API. # Cmb # Config ## Get CMB config `client.logs.control.cmb.config.get(ConfigGetParamsparams, RequestOptionsoptions?): CmbConfig | null` **get** `/accounts/{account_id}/logs/control/cmb/config` Gets CMB config. ### Parameters - `params: ConfigGetParams` - `account_id: string` Identifier. ### Returns - `CmbConfig | null` - `allow_out_of_region_access?: boolean` Allow out of region access - `regions?: string` Name of the region. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const cmbConfig = await client.logs.control.cmb.config.get({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(cmbConfig.allow_out_of_region_access); ``` #### 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.create(ConfigCreateParamsparams, RequestOptionsoptions?): CmbConfig | null` **post** `/accounts/{account_id}/logs/control/cmb/config` Updates CMB config. ### Parameters - `params: ConfigCreateParams` - `account_id: string` Path param: Identifier. - `allow_out_of_region_access?: boolean` Body param: Allow out of region access - `regions?: string` Body param: Name of the region. ### Returns - `CmbConfig | null` - `allow_out_of_region_access?: boolean` Allow out of region access - `regions?: string` Name of the region. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const cmbConfig = await client.logs.control.cmb.config.create({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(cmbConfig.allow_out_of_region_access); ``` #### 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(ConfigDeleteParamsparams, RequestOptionsoptions?): ConfigDeleteResponse | null` **delete** `/accounts/{account_id}/logs/control/cmb/config` Deletes CMB config. ### Parameters - `params: ConfigDeleteParams` - `account_id: string` Identifier. ### Returns - `ConfigDeleteResponse = unknown` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const config = await client.logs.control.cmb.config.delete({ account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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 - `CmbConfig` - `allow_out_of_region_access?: boolean` Allow out of region access - `regions?: string` Name of the region. ### Config Delete Response - `ConfigDeleteResponse = unknown` # RayID ## Get logs RayIDs `client.logs.RayID.get(stringRayID, RayIDGetParamsparams, RequestOptionsoptions?): RayIDGetResponse` **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` - `zone_id: string` Path param: Identifier. - `fields?: 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?: "unix" | "unixnano" | "rfc3339"` 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. - `"unix"` - `"unixnano"` - `"rfc3339"` ### Returns - `RayIDGetResponse = string | unknown` - `string` - `unknown` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const RayID = await client.logs.RayID.get('41ddf1740f67442d', { zone_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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}" ``` ## Domain Types ### RayID Get Response - `RayIDGetResponse = string | unknown` - `string` - `unknown` # Received ## Get logs received `client.logs.received.get(ReceivedGetParamsparams, RequestOptionsoptions?): ReceivedGetResponse` **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` - `zone_id: string` Path param: Identifier. - `end: string | number` 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. - `string` - `number` - `count?: number` 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?: 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?: number` 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?: string | number` 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. - `string` - `number` - `timestamps?: "unix" | "unixnano" | "rfc3339"` 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. - `"unix"` - `"unixnano"` - `"rfc3339"` ### Returns - `ReceivedGetResponse = string | unknown` - `string` - `unknown` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const received = await client.logs.received.get({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', end: '2018-05-20T10:01:00Z', }); console.log(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}" ``` ## Domain Types ### Received Get Response - `ReceivedGetResponse = string | unknown` - `string` - `unknown` # Fields ## List fields `client.logs.received.fields.get(FieldGetParamsparams, RequestOptionsoptions?): FieldGetResponse` **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 - `params: FieldGetParams` - `zone_id: string` Identifier. ### Returns - `FieldGetResponse` - `key?: string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const field = await client.logs.received.fields.get({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(field.key); ``` #### Response ```json { "key": "value" } ``` ## Domain Types ### Field Get Response - `FieldGetResponse` - `key?: string`