-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Persistent logs initial documentation #16824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 8 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
0098710
Persistent logs initial documentation
daisyfaithauma fcd0cc6
Changed header
daisyfaithauma af0e807
Renamed persistent logs to logging
daisyfaithauma ce6722f
Added collect log code example
daisyfaithauma d12caab
Update logging.mdx
kathayl 3e74fb7
Renamed page to analytics
daisyfaithauma b75c638
Ordering costs
daisyfaithauma 5b8b21e
Update logging.mdx
kathayl c63cba8
Added logging folder
daisyfaithauma a2d8884
Update index.mdx
kathayl 627fca2
Removed costs note
daisyfaithauma db75d6d
Removed costs note
daisyfaithauma 1bc4b49
Update src/content/docs/ai-gateway/observability/logging/index.mdx
daisyfaithauma 4ae98b3
Update src/content/docs/ai-gateway/observability/logging/index.mdx
daisyfaithauma 259c7cb
Update src/content/docs/ai-gateway/observability/logging/index.mdx
daisyfaithauma 73ebee3
Update src/content/docs/ai-gateway/observability/logging/index.mdx
daisyfaithauma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| --- | ||
| pcx_content_type: reference | ||
| title: Logging | ||
| sidebar: | ||
| badge: | ||
| text: Beta | ||
| --- | ||
|
|
||
| import { Render } from "~/components"; | ||
|
|
||
| Logging is a fundamental building block for application development. Logging provides insights during the early stages of development and is often critical to understanding issues occurring in production. | ||
|
|
||
| Your AI Gateway dashboard shows logs of individual requests, including the user prompt, model response, provider, timestamp, request status, token usage, cost, and duration. These logs persist, giving you the flexibility to store them for your preferred duration and do more with valuable request data. You can store up to 10 million logs per gateway. | ||
|
|
||
| When you are nearing your plan limit, an alert will be displayed in the dashboard. If your limit is reached, new logs will stop being saved. To continue saving logs, you must delete older logs to free up space for new logs. | ||
|
|
||
| To learn more about your plan limits, refer to the [Pricing](/ai-gateway/pricing/) page. | ||
|
|
||
| ## Default configuration | ||
|
|
||
| Logs, which include metrics as well as request and response data are enabled by default for each gateway. If you are concerned about privacy or compliance and want to turn log collection off, you can go to settings and opt out of logs or set logging behavior on a per-request basis. | ||
|
|
||
| <Render file="logging" /> | ||
|
|
||
| This logging behavior will be uniformly applied to all requests in the gateway. If you need to modify the logging settings for specific requests, you can override this setting on a per-request basis. | ||
|
|
||
| :::note[Note] | ||
|
|
||
| To export logs using Logpush, you must have logs turned on for the gateway or have overridden the gateway settings by using the `cf-aig-collect-log` request header. | ||
|
|
||
| ::: | ||
|
|
||
| ## Per-request logging | ||
|
|
||
| To override the default logging behavior set in the settings tab, you can define headers on a per-request basis. | ||
|
|
||
| ## Collect logs (cf-aig-collect-log) | ||
|
|
||
| The `cf-aig-collect-log` header allows you to bypass the default log setting for the gateway. If the gateway is configured to save logs, the header will exclude the log for that specific request. Conversely, if logging is disabled at the gateway level, this header will save the log for that request. | ||
|
|
||
| In this example, the gateway is configured to save logs, however we do not want this specific request saved. | ||
|
|
||
| ```bash | ||
| curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/openai/chat/completions \ | ||
| --header 'Authorization: Bearer $TOKEN' \ | ||
| --header 'Content-Type: application/json' \ | ||
| --header 'cf-aig-collect-log: false \ | ||
| --data ' { | ||
| "model": "gpt-4o-mini", | ||
| "messages": [ | ||
| { | ||
| "role": "user", | ||
| "content": "What is the email address and phone number of user123?" | ||
| } | ||
| ] | ||
| } | ||
| ' | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| --- | ||
| {} | ||
| --- | ||
|
|
||
| To change the default log configuration in the dashboard: | ||
|
|
||
| 1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com/) and select your account. | ||
| 2. Go to **AI** > **AI Gateway**. | ||
| 3. Select **Settings**. | ||
| 4. Change the **Logs** setting to your preference. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we link "limit" to the limits page