Examples
Practical examples and use cases for CloudControl.
AWS Monitoring Example
This example demonstrates how to set up comprehensive monitoring for your AWS infrastructure using CloudControl.
Setting Up AWS Monitoring
Step 1: Connect Your AWS Account
First, connect your AWS account to CloudControl. For detailed instructions, see the AWS Setup guide.
// Import the CloudControl SDK
import { CloudControl } from '@cloudcontrol/sdk';
// Initialize the client
const client = new CloudControl({
region: 'us-west-2'
});
// Connect to AWS
await client.connect({
provider: 'aws',
credentials: {
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
}
});Step 2: Configure Monitoring Rules
// Configure monitoring for EC2 instances
await client.monitoring.configure({
resource: 'ec2',
metrics: ['cpu', 'memory', 'disk', 'network'],
alerts: [
{
metric: 'cpu',
threshold: 80,
duration: '5m',
action: 'notify'
},
{
metric: 'memory',
threshold: 90,
duration: '10m',
action: 'notify'
}
]
});Step 3: Set Up Notification Channels
// Configure notification channels
await client.notifications.configure({
channels: [
{
type: 'email',
recipients: ['admin@example.com', 'ops@example.com']
},
{
type: 'slack',
webhook: 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX',
channel: '#alerts'
}
]
});Multi-Cloud Cost Optimization
Learn how to optimize costs across multiple cloud providers using CloudControl's unified management interface.
Cost Optimization Workflow
Step 1: Analyze Current Spending
// Get cost analysis across all connected providers
const costAnalysis = await client.costs.analyze({
period: 'last30days',
groupBy: ['service', 'region', 'tag']
});
console.log(costAnalysis.summary);
console.log(costAnalysis.recommendations);Step 2: Implement Recommendations
// Apply recommended cost optimizations
await client.costs.optimize({
recommendations: [
'resize-underutilized-instances',
'remove-unused-volumes',
'reserved-instance-coverage'
],
approval: 'manual' // Options: 'auto', 'manual'
});