#how am i able to see old logs?
9 messages · Page 1 of 1 (latest)
Hi @worn dew. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
To see old logs in a Convex production environment, you have a few options:
By default, Convex only keeps a limited number of recent logs, which can be viewed in the dashboard or CLI. However, for historical logs in production, you'll need to set up log streaming.
Log Streaming for Historical Logs
Convex provides log streaming capabilities that allow you to send your logs to third-party services where they can be stored for longer periods and analyzed more effectively:
"Log streaming to a third-party destination like Axiom or Datadog enables storing historical logs, more powerful querying and data visualization, and integrations with other tools (e.g. PagerDuty, Slack)." Log Streams
Currently supported log stream destinations include:
- Axiom
- Datadog
- Custom webhook
Setting up log streaming requires a Convex Pro plan and is configured in the Convex dashboard.
Why You Need Log Streaming
The built-in Convex logging has limitations for production use:
"Convex backend currently only preserves a limited number of logs, and logs can be erased at any time when the Convex team performs internal maintenance and upgrades. You should therefore set up log streaming and error reporting integrations to enable your team easy access to historical logs..." Debugging
Benefits of Dedicated Observability Platforms
When you set up log streaming to services like Axiom, you get:
"Infinite history of older logs, enriched with metadata from Convex" Observing your app in production
You can also extract metrics from logs and create dashboards to visualize function performance, error rates, and other important metrics.
To get started with log streaming, follow the configuration instructions in the Log Streams documentation.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@worn dew Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@patent onyx is there any log emitter function? like able to call webhook on log trigger?
Let me check the knowledge base for you again. One moment! :books:
Based on the knowledge sources, Convex offers several ways to handle logs and trigger actions based on them:
Log Streaming with Webhooks
Yes, Convex provides a webhook option for log streaming that can send logs to any custom URL you configure:
"A webhook log stream is the simplest and most generic stream, allowing piping logs via POST requests to any URL you configure. The only parameter required to set up this stream is the desired webhook URL." Log Streams
This webhook sends a JSON array of log events to your specified endpoint, allowing you to process logs programmatically.
Custom HTTP Actions for Webhooks
You can also create custom HTTP actions in Convex that can be triggered by external services. While not specifically for logs, this pattern allows you to receive webhook events and process them:
// convex/http.ts
import { httpRouter } from "convex/server";
import { httpAction } from "./_generated/server";
const http = httpRouter();
http.route({
path: "/your-webhook-path",
method: "POST",
handler: httpAction(async (ctx, request) => {
// Process webhook payload
const body = await request.json();
// You could log information or trigger other Convex functions
return new Response(null, { status: 200 });
}),
});
export default http;
Triggers for Database Changes
If you're looking to trigger actions based on database changes rather than logs, Convex offers database triggers through the convex-helpers package:
"Triggers automatically run code whenever data in a table changes. A library in the
convex-helpersnpm package allows you to attach trigger functions to your Convex database." Database Triggers
This allows you to execute code automatically when data changes, which could include sending webhooks or logging information.