Loading...
Loading...
This skill should be used when the user requests to add a new third-party API service to the AWS billing/quota monitoring system. It handles the complete onboarding process including adapter creation, Lambda deployment, CloudWatch alarms, Dashboard updates, and verification. Triggers on requests mentioning "add service monitoring", "monitor API balance", "setup quota alerts", "add to billing dashboard", or similar service integration requests.
npx skill4agent add oldwinter/skills api-billing-service-onboarding/Users/cdd/Code/all-code-in-mba/source-code/lambda-function/justjustfileadapters/*.tsadapters/index.tssrc/handler.tssrc/types.tssrc/metrics.tsCLAUDE.mdadapters/<service_name>.tsreferences/adapter-templates.mdBillingMetricserviceapiKeyMasktotalremainingremainingRatiocurrencyunitadapters/resend.tsadapters/serper.tsadapters/scrapedo.tsadapters/index.tsadaptersimport { fetchServiceName } from "./service_name";
export const adapters = {
// ... existing adapters
service_name: fetchServiceName,
};src/handler.tsconsole.log("✅ Billing check completed")// <Service Display Name>
if (apiKeys.<service_name>) {
try {
console.log("🔍 Fetching <Service> quota...");
const metric = await adapters.<service_name>(apiKeys.<service_name>);
await pushMetrics(metric);
results.push({
service: "<service_name>",
status: "success",
remaining: metric.remaining,
total: metric.total,
ratio: metric.remainingRatio
});
} catch (error: any) {
console.error("❌ <Service> error:", error.message);
results.push({ service: "<service_name>", status: "error", error: error.message });
}
}scripts/add-secret-key.sh <service_name> <api_key># Get current secrets
aws secretsmanager get-secret-value \
--secret-id api-billing-monitor/keys \
--query SecretString --output text > /tmp/secrets.json
# Edit /tmp/secrets.json to add: "<service_name>": "<api_key>"
# Update secrets
aws secretsmanager update-secret \
--secret-id api-billing-monitor/keys \
--secret-string file:///tmp/secrets.json# Quick deployment (recommended)
just deploy-quick
# Or full deployment with verbose output
just deploy# Trigger Lambda manually
just invoke
# Check logs for the new service
just logs | grep <service_name>aws cloudwatch put-metric-alarm \
--alarm-name "<Service>-Low-Balance" \
--namespace "ThirdPartyAPIBilling" \
--metric-name "Remaining" \
--dimensions Name=Service,Value=<service_name> \
--statistic Average \
--period 1800 \
--evaluation-periods 1 \
--threshold <absolute_value> \
--comparison-operator LessThanThreshold \
--alarm-actions "arn:aws:sns:us-east-1:830101142436:CloudWatchAlarmsToFeishu" \
--alarm-description "<Service> remaining balance below <threshold>"aws cloudwatch put-metric-alarm \
--alarm-name "<Service>-Low-Ratio" \
--namespace "ThirdPartyAPIBilling" \
--metric-name "RemainingRatio" \
--dimensions Name=Service,Value=<service_name> \
--statistic Average \
--period 1800 \
--evaluation-periods 1 \
--threshold 0.05 \
--comparison-operator LessThanThreshold \
--alarm-actions "arn:aws:sns:us-east-1:830101142436:CloudWatchAlarmsToFeishu" \
--alarm-description "<Service> remaining ratio below 5%"just alarms | grep <Service>scripts/add-to-dashboard.sh <service_name> "<Service Display Name>" "<masked_api_key>"aws cloudwatch get-dashboard \
--dashboard-name "API-Billing-Monitor" \
--query "DashboardBody" \
--output text > /tmp/dashboard.json/tmp/dashboard.jsonaws cloudwatch put-dashboard \
--dashboard-name "API-Billing-Monitor" \
--dashboard-body file:///tmp/dashboard.jsonreferences/dashboard-widget-template.jsonCLAUDE.md| <service_name> | <unit> | <threshold> | <description> |# 1. Trigger monitoring
just invoke
# 2. Check logs for successful execution
just logs | grep "<service_name>"
# Expected: "✅ Metrics pushed for <service_name>"
# 3. Verify metrics in CloudWatch
aws cloudwatch list-metrics \
--namespace ThirdPartyAPIBilling \
--dimensions Name=Service,Value=<service_name>
# 4. Check alarm status
just alarms | grep "<Service>"
# 5. View current status
just status
# 6. Visit dashboard
echo "https://us-east-1.console.aws.amazon.com/cloudwatch/home?region=us-east-1#dashboards/dashboard/API-Billing-Monitor"just statusjust logsjust secrets-fulljust invokeaws cloudwatch list-metrics --namespace ThirdPartyAPIBillingaws cloudwatch describe-alarms --alarm-names "<Service>-Low-Balance"just test-alarm <Service>-Low-BalanceThirdPartyAPIBillingService=<service_name>APIKey=<masked_key>references/service-integration-examples.md