Axiom Logging & Analytics
CONA uses Axiom for centralized logging, observability, and analytics. This guide explains how our Axiom integration works, how to set up the MCP server for Cursor, and how to generate reports from Axiom data.Overview
Axiom provides centralized log aggregation and analysis for the CONA application. It collects logs from:- Webapp (
cona_webappdataset): Next.js application logs, server actions, API routes, and web vitals - Temporal Workers (
cona_temporal-workersdataset): Temporal workflow and activity logs
Integration Architecture
Server-Side Logging (Next.js)
Server-side logging uses the Axiom JavaScript SDK with Next.js formatters:Application Logger
The application uses a centralized logger function that automatically sends logs to Axiom:info: General informational messageswarning: Warning messages for expected issueserror: Error messages for failures and exceptions
Client-Side Logging
Client-side logs are sent through a proxy API route to keep tokens server-side:Temporal Workers Logging
Temporal workers use Pino with Axiom transport:Axiom MCP Server Setup
The Axiom MCP (Model Context Protocol) server allows you to query Axiom datasets directly from Cursor using natural language queries.Prerequisites
- Cursor with Agent Mode: Ensure you’re using Cursor with Agent mode enabled
- Axiom API Token: You’ll need the Cursor Query API Key from Axiom (contact Egor for access)
Configuration
Add the Axiom MCP server to your Cursor configuration. The MCP server configuration should be added to your Cursor settings:Getting the API Token
To get the Cursor Query API Key:- Navigate to Axiom API Tokens
- Or contact Egor for access to the token
Setup Guide
For detailed setup instructions, see the Axiom MCP Server documentation.Using Axiom MCP in Cursor
Once configured, you can query Axiom datasets directly from Cursor using natural language.Example Queries
- “Give me the list of Axiom datasets”
- “Generate me a report for all warnings from cona_webapp dataset for the last 3 days”
- “Show me all errors from cona_webapp in production for the last 7 days”
- “What are the most common error messages in cona_temporal-workers?”
Query Capabilities
The MCP server supports:- Dataset Listing: List all available datasets
- Field Discovery: Get schema information for datasets
- Query Execution: Run APL (Axiom Processing Language) queries
- Report Generation: Generate formatted reports from query results
- Dashboard Access: View and retrieve dashboard information
- Monitor Status: Check monitor statuses and history
Query Language (APL)
Axiom uses APL (Axiom Processing Language) for queries. Most queries start with the dataset name in square brackets:Report Generation
Axiom reports are automatically generated in a standardized format when requested through Cursor.Report Location
Reports are stored in:.reports/axiom/
If the directory doesn’t exist, Cursor will create it automatically. If creation fails, you can create it manually:
Report Format
Each report follows a standardized structure:- YAML Frontmatter: Contains metadata about the report
- Summary: High-level overview of findings
- Context: Background and assumptions
- Findings: Key observations and data points
- Analysis: Detailed interpretation
- Conclusions: Derived conclusions
- Next Actions: Recommended follow-up steps
Report Naming
Reports are named using the format:DD-MM-YYYY-hh:mm:ss.md
Example: 22-01-2026-21:46:37.md
Report Index
All reports are automatically indexed in:.reports/axiom/index.md
The index lists all reports in reverse chronological order (newest first).
Example Report Request
- Query the
cona_webappdataset - Filter for errors in production
- Analyze the last 7 days of data
- Generate a comprehensive report with findings and recommendations
Available Datasets
cona_webapp
Type: Next.js application logs Description: Contains logs from the Next.js web application, including:- Server actions
- API routes
- Request/response logs
- Web vitals
- Error traces
- Authentication events
level: Log level (info, warning, error)message: Log messageorg_id: Organization IDuser_id: User IDpath: Request pathvercel.environment: Deployment environment (production, preview, development)request.*: Request metadata (method, path, headers, etc.)fields.*: Custom metadata fields
cona_temporal-workers
Type: Events Description: Contains logs from Temporal workers, including:- Workflow execution logs
- Activity logs
- Error traces
- Performance metrics
- Log level and message
- Workflow/activity identifiers
- Execution metadata
- Error information
Configuration
Environment Variables
Required environment variables for Axiom integration:Git Configuration
The reports directory is excluded from version control:Best Practices
1. Use the Centralized Logger
Always use the centralized logger function instead of direct Axiom calls:2. Include Context in Metadata
Always include relevant context in log metadata:3. Error Logging
Always log errors with full context:4. Log Levels
Use appropriate log levels:info: Normal operations, successful actions, important eventswarning: Expected issues (validation failures, auth failures, etc.)error: Unexpected failures, exceptions, bugs
5. Query Best Practices
When querying Axiom datasets:- Always restrict time ranges: Use
where ['_time'] > ago(7d)to limit data scanned - Use aggregations: Prefer
summarizeover raw data when possible - Project specific fields: Only select fields you need
- Start with dataset name: Most queries should start with
['dataset-name']
Security Monitoring
Axiom serves as CONA’s centralized security monitoring and intrusion detection system. All security events are automatically logged and monitored in real-time.Key Security Detection Rules
- Brute Force Detection - Failed login attempts (>5 in 1 minute)
- Unauthorized Access - 401/403 errors on protected routes
- API Rate Limiting - Excessive API requests (>100/min)
- Admin Access Monitoring - All
/adminroute access logged - Session Hijacking - Same session from multiple IPs
- Suspicious Data Access - Unusual database query patterns
- Geographic Anomalies - Logins from multiple countries in 24h
- Error Patterns - Security-related errors (SQL injection, XSS attempts)
- Data Exfiltration - Excessive downloads (>100MB in 30min)
- Database Failures - Connection failures indicating DDoS
Security Queries
Detect brute force attempts:Alert Configuration
Critical Alerts (Immediate response):- Brute force attacks (>10 failed logins/min)
- Session hijacking (session from multiple IPs)
- Database connection failures (>5 failures/min)
- Unauthorized access attempts (>10 in 15min)
- Suspicious error patterns (>3 security errors/10min)
- Unusual download activity (>100MB/30min)
- API rate limit violations (>100 requests/min)
- Suspicious data access patterns
- Anomalous geographic access (>2 countries/24h)
Compliance
✅ Centralized Logging - All security events logged✅ Intrusion Detection - 10 detection rules covering OWASP Top 10
✅ Access Monitoring - All admin/privileged access logged
✅ Real-time Alerts - Critical alerts within 1 minute
✅ Retention - 12-month log retention for security events
Log Retention Policy
- Security Events: 12 months (audit compliance)
- Access Logs: 12 months (German accounting compliance)
- Error Logs: 6 months
- Info Logs: 3 months
Troubleshooting
Reports Not Generating
If report generation fails:- Check directory exists: Ensure
.reports/axiom/directory exists - Check MCP connection: Verify Axiom MCP server is configured correctly
- Check API token: Ensure you have access to the Cursor Query API Key
- Check query syntax: Verify your query uses valid APL syntax
Logs Not Appearing in Axiom
If logs aren’t appearing in Axiom:- Check environment variables: Verify
NEXT_PUBLIC_AXIOM_TOKENandNEXT_PUBLIC_AXIOM_DATASETare set - Check dataset name: Ensure the dataset exists in Axiom
- Check network: Verify the application can reach Axiom’s API
- Check logger flush: Ensure
logger.flush()is called (handled automatically in the centralized logger)
MCP Server Connection Issues
If the MCP server isn’t working:- Verify configuration: Check that the MCP server is properly configured in Cursor
- Check API token: Contact Egor to verify API token access
- Restart Cursor: Sometimes a restart is needed after configuration changes
- Check Axiom status: Verify Axiom service is operational
Contact
For questions or issues related to Axiom:- API Token Access: Contact Egor
- Configuration Issues: Check the Axiom MCP documentation
- Dataset Access: Verify you have access to the CONA organization in Axiom