SignalFx Python Library

raw JSON →
1.1.16 verified Mon Apr 27 auth: no python maintenance

SignalFx Python Library provides a client for sending metrics and events to SignalFx, and for interacting with SignalFlow computations. Current version 1.1.16, released 2022-07. Maintenance mode; no active development.

pip install signalfx
error ValueError: Unknown type for value: ...
cause Sending invalid metric value type (e.g., string, list). Values must be int or float.
fix
Ensure metric value is numeric: {'metric': 'cpu', 'value': float(cpu_percent)}
error signalfx.exceptions.SignalFxException: 401 Unauthorized
cause Invalid or missing access token.
fix
Set SIGNALFX_ACCESS_TOKEN environment variable or pass token to SignalFx().
error ImportError: cannot import name 'SignalFx' from 'signalfx' (unknown location)
cause Old Python version missing the module or corrupted install.
fix
pip install --upgrade signalfx. On Python 2.7, use signalfx <=1.0.19.
breaking Versions 1.1.7 to 1.1.11 contain serious bugs (HTTP reconnection issues, data corruption). Upgrade directly to 1.1.12 or later.
fix pip install 'signalfx>=1.1.12'
deprecated The 'pyformance' integration (SignalFxRegistry) is deprecated and removed in later versions. Use OpenTelemetry or custom metrics instead.
fix Migrate to OpenTelemetry SDK or direct ingest via signalfx.
gotcha The SignalFlow API (get_computation, etc.) uses a different token (stream token) than ingest token. Must use SignalFx(stream_endpoint=...) or set SIGNALFX_ACCESS_TOKEN for ingest, but for SignalFlow you need to use the SignalFx(api_endpoint=...) with the stream token.
fix Use separate SignalFx instances for ingest and SignalFlow with appropriate tokens.

Send a datapoint and event using the v1 SDK with a context manager.

import os
from signalfx import SignalFx

# Set token via environment variable
sfx = SignalFx(api_endpoint='https://ingest.signalfx.com', ingest_timeout_seconds=5)
# If using a realm: sfx = SignalFx(api_endpoint='https://ingest.<REALM>.signalfx.com')
with sfx.ingest(os.environ.get('SIGNALFX_ACCESS_TOKEN', '')) as ingest:
    ingest.send_datapoints([
        {
            'metric': 'cpu.utilization',
            'value': 42.0,
            'dimensions': {'host': 'server1'}
        }
    ])
    ingest.send_events([
        {
            'eventType': 'deployment',
            'dimensions': {'host': 'server1'}
        }
    ])