Skip to main content

No project description provided

Project description

signalflow-client-python

PyPI - Version PyPI - Python Version


Table of Contents

Installation

To install the SignalFlow Python client library, open a terminal and run the following command:

pip install signalflow-client-python

Run a SignalFlow computation

The following example allows you run a SignalFlow computation from the command line. For additional examples, see the examples directory.

  1. Install the signalfx package:

    pip install signalfx
    
  2. Create a .py file that includes the following content:

    #!/usr/bin/env python
    
    import argparse
    import signalfx  # noqa
    from signalfx.signalflow import messages, SignalFlowClient  # noqa
    
    
    if __name__ == "__main__":
        parser = argparse.ArgumentParser(
            description="SignalFx SignalFlow streaming analytics demo"
        )
        parser.add_argument(
            "--stream-endpoint",
            help="SignalFx SignalFlow stream API endpoint",
            default="https://stream.signalfx.com",
        )
        parser.add_argument("token", help="Your SignalFx API access token")
        parser.add_argument("program", help="SignalFlow program to execute")
        options = parser.parse_args()
    
        client = SignalFlowClient(
            token=options.token,
            endpoint=options.stream_endpoint,
        )
    
        try:
            # Execute the computation and iterate over the message stream
            print("Requesting computation: {0}".format(options.program))
            c = client.execute(options.program)
            print("Waiting for data...")
            for msg in c.stream():
                if isinstance(msg, messages.DataMessage):
                    print(
                        "\033[34;1m{0}\033[;0m @{1}: {2}".format(
                            "data",
                            msg.logical_timestamp_ms,
                            ", ".join(
                                [
                                    "\033[;1m{0}\033[;0m: {1}".format(k, v)
                                    for k, v in msg.data.items()
                                ]
                            ),
                        )
                    )
                elif isinstance(msg, messages.EventMessage):
                    print(
                        "\033[35;1m{0}\033[34;1m@\033[;0m @{1}: {2}".format(
                            "event",
                            msg.timestamp_ms,
                            ", ".join(
                                [
                                    "\033[;1m{0}\033[;0m: {1}".format(k, v)
                                    for k, v in msg.properties.items()
                                ]
                            ),
                        )
                    )
                elif isinstance(msg, messages.MetadataMessage):
                    print(
                        "\033[32;1m{0}\033[;0m for \033[;1m{1}\033[;0m:\n  {2}".format(
                            "metadata",
                            msg.tsid,
                            "\n  ".join(
                                [
                                    "\033[;1m{0}\033[;0m: {1}".format(k, v)
                                    for k, v in msg.properties.items()
                                ]
                            ),
                        )
                    )
        except KeyboardInterrupt:
            print(" Detaching from computation...")
        finally:
            client.close()
        print("Done.")
    
  3. Run the Python script, specifying values for the streaming endpoint (optional), the API access token, and the SignalFlow program.

    For example:

    python <file-name>.py --stream-endpoint https://stream.us0.signalfx.com <api-token> "data('sf.org.num.orguser').publish()"
    

License

signalflow-client-python is distributed under the terms of the Apache-2.0 license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

signalflow_client_python-1.3.0.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

signalflow_client_python-1.3.0-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file signalflow_client_python-1.3.0.tar.gz.

File metadata

File hashes

Hashes for signalflow_client_python-1.3.0.tar.gz
Algorithm Hash digest
SHA256 15d89c7e80c193288d72b7fba88cce2aac4ede225a29d80015f491b3b3a6e454
MD5 19caf29aca30eb570b60cc27f375f63e
BLAKE2b-256 a0713bc728855485be0c54a23aa98f6915513b43137a2130c4a677ac860dcb80

See more details on using hashes here.

File details

Details for the file signalflow_client_python-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for signalflow_client_python-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1567268c937853771e90584002dd257cff8615d96146c786917b17047606701c
MD5 88a4d6c387ef194d44c5fbc3fcd3541f
BLAKE2b-256 ab0a3603dac5fe3d4f13e9e977ec860d8205bc4cc242a71a48deb8f2d2eb2dcd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page