CI/CD Integration

Back to Help
Overview

SilentCanary's CI/CD integration automatically creates and manages monitoring canaries for your deployments. This ensures every service has monitoring from day one and reduces manual setup overhead.

Benefits
  • Automatic canary creation for new services
  • Deployment tracking and correlation
  • Template-based configuration
  • Zero manual intervention required
Supported Platforms
  • GitHub Actions
  • GitLab CI/CD
  • Jenkins
  • Azure DevOps
  • Any CI/CD with webhook support
Quick Setup Guide

Follow these steps to integrate SilentCanary with your CI/CD pipeline:

Step-by-Step Setup
  1. Create API Key: Go to Settings → API Key Management → Create New API Key
  2. Add to CI/CD Secrets: Store your API key as SILENTCANARY_API_KEY in your CI/CD platform's secrets
  3. Add Integration Step: Copy the appropriate code snippet below and add it to your deployment pipeline
  4. Customize: Update service name, environment, and notification settings
  5. Deploy & Test: Run your pipeline and check your SilentCanary dashboard
Prerequisites
  • SilentCanary account at https://silentcanary.com
  • API key with appropriate permissions
  • CI/CD pipeline with internet access
  • curl or equivalent HTTP client available
Tip: Start with one service to test the integration, then roll out to other services.
What Happens Next?

Canary automatically created for your service

Notifications configured based on your settings

Monitoring begins immediately after deployment

API Authentication
Creating Your API Key

API keys are managed through your account settings:

  1. Go to Settings → API Key Management
  2. Click "Create New API Key"
  3. Enter a descriptive name (e.g., "Production CI/CD")
  4. Copy the generated API key
  5. Store it securely in your CI/CD platform's secrets
Security Best Practices:
  • Use separate API keys for different environments
  • Name your keys descriptively
  • Monitor usage in settings
  • Rotate keys regularly
Using the API Key

Include the API key in all requests:

curl -H "X-API-Key: YOUR_API_KEY_FROM_SETTINGS" \
     -H "Content-Type: application/json" \
     https://silentcanary.com/api/v1/...
Usage Tracking: Monitor your API key usage, including request count and last used timestamp, in the Settings page.
Deployment Webhook
Endpoint
POST https://silentcanary.com/api/v1/deployment/webhook
Request Body
{
  "service_name": "my-api-service",
  "environment": "production",
  "deployment_id": "deploy-12345",
  "commit_sha": "a1b2c3d4e5f6",
  "branch": "main",
  "pipeline_url": "https://github.com/org/repo/actions/runs/12345",
  "template": "microservice",
  "interval_minutes": 30,
  "alert_type": "both",
  "email": "team@company.com",
  "slack_webhook": "https://hooks.slack.com/services/...",
  "enable_smart_alerts": true
}
Required Fields
  • service_name: Name of the service being deployed
  • environment: Environment (production, staging, etc.)
  • deployment_id: Unique deployment identifier
Optional Fields
  • template: Template to use (default, microservice, batch_job, api_service)
  • commit_sha: Git commit hash
  • branch: Git branch name
  • pipeline_url: Link to CI/CD pipeline
  • interval_minutes: Override default check-in interval
  • alert_type: email, slack, or both
  • email: Alert email address
  • slack_webhook: Slack webhook URL
  • enable_smart_alerts: Enable ML-based smart alerts
Response
{
  "status": "created",
  "canary_id": "uuid-here",
  "canary_token": "token-here",
  "message": "Created new canary for my-api-service in production",
  "canary_url": "https://silentcanary.com/canary/uuid-here",
  "check_in_url": "https://silentcanary.com/ping/token-here",
  "deployment_info": {
    "deployment_id": "deploy-12345",
    "commit_sha": "a1b2c3d4e5f6",
    "branch": "main",
    "pipeline_url": "https://github.com/org/repo/actions/runs/12345"
  }
}
Canary Templates
default
  • Interval: 60 minutes
  • Alerts: Email + Slack
  • Smart Alerts: Enabled
  • Use Case: General services
microservice
  • Interval: 30 minutes
  • Alerts: Slack only
  • Smart Alerts: Enabled
  • Use Case: Microservices
batch_job
  • Interval: 24 hours
  • Alerts: Email only
  • Smart Alerts: Disabled
  • Use Case: Daily batch jobs
api_service
  • Interval: 15 minutes
  • Alerts: Email + Slack
  • Smart Alerts: Enabled
  • Use Case: High-frequency APIs
Platform Examples
GitHub Actions
- name: Register with SilentCanary
  run: |
    curl -X POST https://silentcanary.com/api/v1/deployment/webhook \
         -H "X-API-Key: ${{ secrets.SILENTCANARY_API_KEY }}" \
         -H "Content-Type: application/json" \
         -d '{
           "service_name": "${{ github.event.repository.name }}",
           "environment": "production",
           "deployment_id": "${{ github.run_id }}",
           "commit_sha": "${{ github.sha }}",
           "branch": "${{ github.ref_name }}",
           "pipeline_url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
           "template": "microservice"
         }'
GitLab CI/CD
register_canary:
  script:
    - |
      curl -X POST https://silentcanary.com/api/v1/deployment/webhook \
           -H "X-API-Key: $SILENTCANARY_API_KEY" \
           -H "Content-Type: application/json" \
           -d "{
             \"service_name\": \"$CI_PROJECT_NAME\",
             \"environment\": \"$CI_ENVIRONMENT_NAME\",
             \"deployment_id\": \"$CI_PIPELINE_ID\",
             \"commit_sha\": \"$CI_COMMIT_SHA\",
             \"branch\": \"$CI_COMMIT_REF_NAME\",
             \"pipeline_url\": \"$CI_PIPELINE_URL\",
             \"template\": \"api_service\"
           }"
  only:
    - main
Jenkins
pipeline {
    agent any
    stages {
        stage('Register Canary') {
            steps {
                script {
                    def payload = [
                        service_name: env.JOB_NAME,
                        environment: "production",
                        deployment_id: env.BUILD_ID,
                        commit_sha: env.GIT_COMMIT,
                        branch: env.GIT_BRANCH,
                        pipeline_url: env.BUILD_URL,
                        template: "default"
                    ]
                    
                    sh """
                        curl -X POST https://silentcanary.com/api/v1/deployment/webhook \\
                             -H "X-API-Key: \${SILENTCANARY_API_KEY}" \\
                             -H "Content-Type: application/json" \\
                             -d '${groovy.json.JsonOutput.toJson(payload)}'
                    """
                }
            }
        }
    }
}
Integration in Application Code

Add check-ins to your application code to report health status:

Python Example
import requests
import os

def healthcheck():
    """Send check-in to SilentCanary"""
    canary_token = os.getenv('SILENTCANARY_TOKEN')
    if canary_token:
        try:
            response = requests.get(
                f"https://silentcanary.com/ping/{canary_token}",
                params={"message": "Service running normally"},
                timeout=5
            )
            print(f"SilentCanary check-in: {response.status_code}")
        except Exception as e:
            print(f"SilentCanary check-in failed: {e}")

# Call periodically or in health check endpoint
if __name__ == "__main__":
    healthcheck()
Node.js Example
const axios = require('axios');

async function healthcheck() {
    const canaryToken = process.env.SILENTCANARY_TOKEN;
    if (canaryToken) {
        try {
            const response = await axios.get(
                `https://silentcanary.com/ping/${canaryToken}`,
                { 
                    params: { message: "Service running normally" },
                    timeout: 5000 
                }
            );
            console.log(`SilentCanary check-in: ${response.status}`);
        } catch (error) {
            console.log(`SilentCanary check-in failed: ${error.message}`);
        }
    }
}

// Call periodically
setInterval(healthcheck, 30 * 60 * 1000); // Every 30 minutes
Go Example
package main

import (
    "fmt"
    "net/http"
    "os"
    "time"
)

func healthcheck() {
    token := os.Getenv("SILENTCANARY_TOKEN")
    if token == "" {
        return
    }
    
    client := &http.Client{Timeout: 5 * time.Second}
    url := fmt.Sprintf("https://silentcanary.com/ping/%s?message=Service+running+normally", token)
    
    resp, err := client.Get(url)
    if err != nil {
        fmt.Printf("SilentCanary check-in failed: %v\n", err)
        return
    }
    defer resp.Body.Close()
    
    fmt.Printf("SilentCanary check-in: %d\n", resp.StatusCode)
}

func main() {
    // Call periodically
    ticker := time.NewTicker(30 * time.Minute)
    defer ticker.Stop()
    
    for {
        select {
        case <-ticker.C:
            healthcheck()
        }
    }
}
Best Practices
Do
  • Use consistent naming conventions (service-environment)
  • Set appropriate check-in intervals for your service type
  • Enable smart alerts for production services
  • Include deployment metadata for better tracking
  • Use environment-specific templates
  • Store API keys securely in CI/CD secrets
Don't
  • Hardcode API keys in code or config files
  • Use overly aggressive check-in intervals
  • Create canaries for temporary/test services
  • Ignore failed webhook calls in CI/CD
  • Use the same canary for multiple environments
  • Forget to implement actual health checks
Troubleshooting
Common Issues

Cause: Invalid or expired API key
Solution:
  • Check that your API key is active in Settings
  • Ensure the key is stored correctly in your CI/CD secrets
  • Create a new API key if the current one is compromised
  • Verify the key name matches what's used in your pipeline

Cause: Missing required fields in request
Solution: Ensure service_name, environment, and deployment_id are included in the payload

Cause: Incorrect token or URL
Solution: Use the check_in_url returned from the webhook response, or verify the token is correct