Set Up Multi-Environment Monitoring
Managing APIs across multiple environments (Development, Staging, Production) can be challenging. Each environment serves a different purpose and requires separate monitoring. Treblle allows you to create separate API instances for each environment, giving you complete visibility into how your API behaves at every stage of deployment.
What You’ll Need
- A Treblle account
- Access to your application in different environments (Development, Staging, Production)
- Ability to configure environment variables
Understanding Environments
Before setting up monitoring, it’s important to understand the different environment options Treblle provides:
Environment Types
Treblle supports four environment types:
- Production: Your live, customer-facing API
- Staging: Pre-production environment for final testing
- Development: Development environment for active development
- Unknown: Default when no environment is specified
API Types
You can also classify APIs by access type:
- Internal: APIs used only within your organization
- External: Public-facing APIs for external consumers
- Partner: APIs used by your partners or customers
Note
Use the Partner type for APIs that your customers or partners integrate with. This helps you monitor and support customer integrations separately from your internal and public APIs.
API Categories
Organize APIs by business function:
- Financial
- Government
- Healthcare
- E-commerce
- Social Media
- Entertainment
- Education
- And more…
Step 1: Create API for Each Environment
For each environment you want to monitor, create a separate API instance in Treblle.
Create Your First API
Navigate to APIs in the sidebar and click + New API. You’ll see the “Add New API” wizard with three steps:
- API Info (current step)
- Integrations
- Setup
Fill in the API Info form:
API Name* (required)
- Enter a descriptive name for this environment
- Examples: “My API - Production”, “My API - Staging”, “My API - Dev”
Environment* (required) - Dropdown with options:
- Production
- Staging (shown selected in screenshot)
- Development
- Unknown
Category* (required) - Dropdown with options:
- Financial (shown selected in screenshot)
- Government
- Healthcare
- E-commerce
- Social Media
- Entertainment
- Education
- And more…
Type* (required) - Dropdown with options:
- Internal (shown selected in screenshot)
- External
- Partner
Tags (optional)
- Add custom tags to organize your APIs
- Press enter to add tags to the list
- Placeholder: “Select tags”
Click Next → to proceed to the Integrations step.
Tip
Use a consistent naming convention across environments, such as “MyApp - Production”, “MyApp - Staging”, “MyApp - Development” to easily identify related APIs.
Step 2: Choose Your Integration Method
After providing API info, you’ll reach the Integrations step. Choose how you want to integrate Treblle with your API.
Click Back to return to API Info or click Create API and Integrate → to proceed to setup.
Note
Select the same integration method for all environments of the same API. This ensures consistent data collection across your deployment pipeline.
Step 3: Configure Integration
After selecting your integration (Express shown in example), you’ll see the Express Setup page with implementation instructions:
Click Finish → to complete the setup.
Top right: Read Full Documentation link for detailed instructions.
Tip
Store your SDK tokens and API keys as environment variables. Never commit credentials directly in your code.
Step 4: Configure Environment Variables
The key to multi-environment monitoring is using different API keys for each environment. Each environment should have its own unique credentials.
Environment Variable Setup
For each environment, configure these variables:
Production:
export TREBLLE_SDK_TOKEN=<your-production-sdk-token>
export TREBLLE_API_KEY=<your-production-api-key>Staging:
export TREBLLE_SDK_TOKEN=<your-staging-sdk-token>
export TREBLLE_API_KEY=<your-staging-api-key>Development:
export TREBLLE_SDK_TOKEN=<your-development-sdk-token>
export TREBLLE_API_KEY=<your-development-api-key>Using .env Files
Create separate .env files for each environment:
.env.production:
TREBLLE_SDK_TOKEN=production_token_here
TREBLLE_API_KEY=production_key_here.env.staging:
TREBLLE_SDK_TOKEN=staging_token_here
TREBLLE_API_KEY=staging_key_here.env.development:
TREBLLE_SDK_TOKEN=development_token_here
TREBLLE_API_KEY=development_key_hereCloud Platform Configuration
For cloud deployments, set environment variables through your platform’s dashboard:
- AWS: Lambda Environment Variables or Systems Manager Parameter Store
- Azure: Application Settings
- Heroku: Config Vars
- Vercel: Environment Variables
- Docker: Docker Compose environment section
Note
Keep your credentials secure. Use secret management services for production environments and never expose API keys in client-side code.
Step 5: Verify Each Environment
After setting up your environments, navigate to APIs in the sidebar to see all your API instances.
The APIs list shows:
API Cards displaying:
- API Name (e.g., “Demo API”, “test”, “Prompt Enhancer API”, “test1”)
- Environment Badge: Staging, Production, Development, Unknown (color-coded)
- Category Badge: (if applicable)
- Type Badge: Internal or External
- Integrate SDK message: For newly created APIs
Example APIs shown:
- Demo API - Staging - Internal - 9.9K requests, 8 endpoints, 1 problem
- test - Production - Financial - Internal - Integrate SDK prompt, No data
- Prompt Enhancer API - Production - Internal - 3.4K requests, 2 endpoints, 0 problems
- test1 - Development - Government - Internal - Integrate SDK prompt, No data
- test1 - Unknown - Rnd - External - Integrate SDK prompt, No data
Tip
Use the environment badges to quickly identify which APIs are in production versus development or staging. This helps prevent accidentally modifying production settings.
Compare Environments
Once all environments are set up and receiving data, you can compare their behavior:
Compare Request Volumes
Look at the request counts for each environment:
- Production typically has the highest volume
- Staging should mirror production load during testing
- Development has variable, lower volume
Compare Error Rates
Navigate to each API’s dashboard to compare:
- Production errors impact real users
- Staging errors indicate issues before production release
- Development errors are expected during active development
Compare Performance
Check load times across environments:
- Production should have optimized performance
- Staging should match production configuration
- Development may be slower due to debug tools
Compare Endpoints
Verify endpoint parity:
- All environments should have the same endpoints
- New endpoints appear in development first
- Changes flow: Development → Staging → Production
Set Up Environment-Specific Alerts
Note
Learn more about setting up alerts in the Set Up Custom Alerts tutorial.
Configure different alert thresholds for each environment.
Production Alerts
Set strict monitoring for production:
- Alert on any 5xx errors
- Alert when error rate exceeds 1%
- Alert when average response time exceeds 500ms
- Send to on-call team via Slack/PagerDuty
Staging Alerts
Set moderate monitoring for staging:
- Alert on critical errors during load testing
- Alert when error rate exceeds 5%
- Send to development team via Slack
Development Alerts
Set lenient monitoring for development:
- Optional: Alert on persistent errors
- Focus on security vulnerabilities
- Send to individual developers
Troubleshooting
API Not Receiving Requests
Problem: Environment shows “Integrate SDK” or “No data”
Solution:
- Verify environment variables are set correctly
- Check that the SDK is properly initialized
- Restart your application after setting variables
- Make test requests to generate data
Wrong Environment Showing
Problem: Requests appear in wrong environment
Solution:
- Verify you’re using the correct API key for that environment
- Check environment variable names match exactly
- Ensure you’re not mixing production and staging keys
Missing Environments
Problem: Only seeing production data
Solution:
- Create separate API instances for each environment
- Configure unique API keys for each
- Deploy with environment-specific credentials