Sysdig Platform Python Client

0.19.0 · active · verified Thu Apr 16

sdcclient is the official Python client for the Sysdig Platform APIs (Monitor and Secure). It provides an easy-to-use interface to interact with Sysdig's REST APIs for tasks such as metric extraction, alert management, and user/team administration. The current version is 0.19.0, and releases generally follow the development of the Sysdig platform, with updates for new API features and bug fixes.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to instantiate a Sysdig Monitor client using an API token, preferably from an environment variable, and then fetch basic user information. It also shows how to handle the common `[success_boolean, result_or_error]` return pattern.

import os
from sdcclient import SdMonitorClient

# It's recommended to store your API token in an environment variable for security.
# export SYSDIG_API_TOKEN='YOUR_SYSDIG_API_TOKEN'
# export SDC_URL='https://app.sysdig.com'

api_token = os.environ.get('SYSDIG_API_TOKEN', '')
sdc_url = os.environ.get('SDC_URL', 'https://app.sysdig.com') # Default SaaS URL

if not api_token:
    print("Error: SYSDIG_API_TOKEN environment variable not set.")
    exit(1)

# Instantiate the Sysdig Monitor client
client = SdMonitorClient(api_token, sdc_url=sdc_url)

# Example: Get current user information
ok, res = client.get_user_info()

if ok:
    print("Successfully connected to Sysdig Monitor.")
    print(f"User Info: {res}")
else:
    print(f"Failed to get user info: {res}")

view raw JSON →