Skip to content
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/content/docs/ai-gateway/observability/analytics.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Analytics and logging
title: Analytics
pcx_content_type: reference
---

Expand Down Expand Up @@ -47,7 +47,3 @@ curl https://api.cloudflare.com/client/v4/graphql \

The cost metric is an estimation based on the number of tokens sent and received in requests. While this metric can help you monitor and predict cost trends, refer to your provider’s dashboard for the most accurate cost details.
:::

## Logging

Your AI Gateway dashboard also shows real-time logs of individual requests, such as the prompt, response, provider, timestamps, and whether the request was successful, cached, or if there was an error. These logs now persist and can store up to 10,000 logs per gateway for better observability and analysis.
7 changes: 2 additions & 5 deletions src/content/docs/ai-gateway/observability/costs.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
title: Costs
pcx_content_type: reference
sidebar:
order: 2
---


## Supported Providers

AI Gateway currently supports cost metrics from the following providers:
Expand All @@ -28,7 +29,6 @@ The cost metric is an **estimation** based on the number of tokens sent and rece

:::caution[Caution]


Providers may introduce new models or change their pricing. If you notice outdated cost data or are using a model not yet supported by our cost tracking, please [submit a request](https://forms.gle/8kRa73wRnvq7bxL48)

:::
Expand All @@ -37,6 +37,3 @@ Providers may introduce new models or change their pricing. If you notice outdat

AI Gateway allows users to set custom costs when operating under special pricing agreements or negotiated rates. Custom costs can be applied at the request level, and when applied, they will override the default or public model costs.
For more information on configuration of custom costs, please visit the [Custom Costs](/ai-gateway/configuration/custom-costs/) configuration page.



58 changes: 58 additions & 0 deletions src/content/docs/ai-gateway/observability/logging.mdx
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.
Copy link
Contributor

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


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?"
}
]
}
'
```
10 changes: 10 additions & 0 deletions src/content/partials/ai-gateway/logging.mdx
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.
Loading