{"id":7772,"library":"sumologic-sdk","title":"Sumo Logic Python SDK","description":"The Sumo Logic Python SDK (version 0.1.17) is a community-supported Python interface to the Sumo Logic REST API, designed to simplify interactions with the API in Python code. It provides functionality for various API operations, including content management, search, and collector interactions. The library maintains an active development status with periodic updates, with the latest release in June 2024.","status":"active","version":"0.1.17","language":"en","source_language":"en","source_url":"https://github.com/SumoLogic/sumologic-python-sdk","tags":["observability","logging","monitoring","sumologic","sdk","api","rest"],"install":[{"cmd":"pip install sumologic-sdk","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Used for making HTTP requests to the Sumo Logic API.","package":"requests","optional":false}],"imports":[{"note":"The primary client class is named SumoLogic and resides directly under the 'sumologic' package.","wrong":"import sumologic_sdk","symbol":"SumoLogic","correct":"from sumologic import SumoLogic"}],"quickstart":{"code":"import os\nfrom sumologic import SumoLogic\n\n# Set your Sumo Logic Access ID, Access Key, and API endpoint as environment variables\n# e.g., export SUMO_ACCESS_ID='your_access_id'\n#       export SUMO_ACCESS_KEY='your_access_key'\n#       export SUMO_ENDPOINT='https://api.sumologic.com/api' (or your region-specific endpoint)\n\naccess_id = os.environ.get('SUMO_ACCESS_ID', '')\naccess_key = os.environ.get('SUMO_ACCESS_KEY', '')\nendpoint = os.environ.get('SUMO_ENDPOINT', 'https://api.sumologic.com/api') # Default for US1\n\nif not all([access_id, access_key, endpoint]):\n    print(\"Error: SUMO_ACCESS_ID, SUMO_ACCESS_KEY, and SUMO_ENDPOINT environment variables must be set.\")\nelse:\n    try:\n        # Initialize the Sumo Logic client\n        sumo = SumoLogic(access_id, access_key, endpoint)\n\n        # Example: Get a list of all collectors\n        collectors = sumo.get_collectors_sync()\n\n        print(f\"Successfully connected to Sumo Logic. Found {len(collectors)} collectors.\")\n        for collector in collectors[:3]: # Print first 3 collectors for brevity\n            print(f\"  - ID: {collector['id']}, Name: {collector['name']}\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart initializes the `SumoLogic` client using credentials and an API endpoint, then fetches and prints the first few Sumo Logic collectors. Ensure you have your `SUMO_ACCESS_ID`, `SUMO_ACCESS_KEY`, and `SUMO_ENDPOINT` set as environment variables. The endpoint should match your Sumo Logic deployment (e.g., `https://api.us2.sumologic.com/api`)."},"warnings":[{"fix":"Verify your Python environment's TLS configuration. Update Python or OS if necessary.","message":"Sumo Logic only accepts connections from clients using TLS version 1.2 or greater. Ensure your execution environment is configured for TLS 1.2+.","severity":"breaking","affected_versions":"All versions"},{"fix":"Always use the correct region-specific API endpoint (e.g., `https://api.us2.sumologic.com/api`, `https://api.eu.sumologic.com/api`). Refer to the Sumo Logic documentation to find your account's deployment endpoint.","message":"Incorrect API endpoint for your Sumo Logic deployment can lead to authentication failures (401 Unauthorized) or other API errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Implement exponential backoff and respect any `Retry-After` headers in API responses to avoid being throttled.","message":"Sumo Logic APIs enforce rate limits (e.g., 4 requests/second, up to 10 concurrent requests per access key). Exceeding these limits will result in a `429 rate.limit.exceeded` error.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your code handles and passes the session cookie returned by the initial Search Job API call for all follow-up requests to the same job.","message":"When using the Search Job API, the initial query creates a session cookie. This cookie must be stored and passed with all subsequent calls related to that specific search job to avoid `500 Internal Server Error` or `Job ID is invalid`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Double-check your `SUMO_ACCESS_ID` and `SUMO_ACCESS_KEY` for accuracy. Verify that `SUMO_ENDPOINT` points to the correct region-specific Sumo Logic API URL (e.g., `https://api.us2.sumologic.com/api`).","cause":"The provided Access ID or Access Key is incorrect, or the API endpoint used does not correspond to your Sumo Logic deployment region.","error":"HTTP 401 Unauthorized: Credential could not be verified."},{"fix":"Ensure that the session cookie returned by the initial `/search/jobs` API call is included in the headers of all follow-up requests to the same search job.","cause":"For the Search Job API, subsequent calls to check status or retrieve results require a session cookie established by the initial search query. This cookie was likely not passed.","error":"HTTP 500 Internal Server Error or 'Job ID is invalid' when retrieving search results."},{"fix":"Implement robust retry logic with exponential backoff. Wait for a period, potentially indicated by a `Retry-After` header, before making further requests.","cause":"Your application has exceeded the API rate limits (e.g., 4 requests/second or 10 concurrent requests per access key) imposed by Sumo Logic.","error":"HTTP 429 Too Many Requests: rate.limit.exceeded"},{"fix":"Check network connectivity, DNS resolution (`nslookup collectors.sumologic.com`), and firewall rules from your environment to Sumo Logic's API endpoints.","cause":"Intermittent or consistent network connectivity issues, DNS resolution problems, or firewall blocks preventing the client from reaching Sumo Logic servers.","error":"ConnectException for receiver url: 'collectors.sumologic.com:443'; on attempt: 'X'. org.apache.http.NoHttpResponseException: The target server failed to respond."}]}