Skip to main content

A streaming hub. Sort of.

Project description

Señor Octopus is a streaming hub, fetching data from APIs, transforming it, filtering it, and storing it, based on a declarative configuration.

Confused? Keep reading.

A simple example

Señor Octopus reads a pipeline defintion from a configuration file like this:

# generate random numbers and send them to "check" and "normal"
[random]
plugin = source.random
flow = -> check, normal
schedule = * * * * *

# filter numbers from "random" that are > 0.5 and send to "high"
[check]
plugin = filter.jsonpath
flow = random -> high
filter = $.events[?(@.value>0.5)]

# log all the numbers coming from "random" at the default level
[normal]
plugin = sink.log
flow = * ->

# log all the numbers coming from "check" at the warning level
[high]
plugin = sink.log
flow = check ->
level = warning

The example above has a source called “random”, that generates random numbers every minute (its schedule). It’s connected to 2 other nodes, “check” and “normal” (flow = -> check, normal). Each random number is an event that looks like this:

{
    "timestamp": "2021-01-01T00:00:00+00:00",
    "name": "hub.random",
    "value": 0.6394267984578837
}

The node check is a filter that verifies that the value of each number is greater than 0.5. Events that pass the filter are sent to the high node (the filter connects the two nodes, according to flow = random -> high).

The node normal is a sink that logs events. It receives events from any other node (flow = * ->), and simply logs them at the INFO level (the default). The node high, on the other hand, receives events only from check, and logs them at the WARNING level.

To run it:

$ srocto config.ini -vv

A concrete example

Now for a more realistic example. I wanted to monitor the air quality in my bedroom, using an Awair Element. Since their API is throttled I want to read values once every 5 minutes, and store everything in a Postgres database. If the CO2 value is higher than 1000 ppm I want to receive a notification on my phone, limited to one message every 30 minutes.

This is the config I use for that:

[awair]
plugin = source.awair
flow = -> *
schedule = */5 * * * *
prefix = hub.awair
AWAIR_ACCESS_TOKEN = XXX
AWAIR_DEVICE_TYPE = awair-element
AWAIR_DEVICE_ID = 12345

[high_co2]
plugin = filter.jsonpath
flow = awair -> pushover
filter = $.events[?(@.name=="hub.awair.co2" and @.value>1000)]

[pushover]
plugin = sink.pushover
flow = high_co2 ->
throttle = 30 minutes
PUSHOVER_APP_TOKEN = XXX
PUSHOVER_USER_TOKEN = johndoe

[db]
plugin = sink.db.postgresql
flow = * ->
batch = 15 minutes
POSTGRES_DBNAME = dbname
POSTGRES_USER = user
POSTGRES_PASSWORD = password
POSTGRES_HOST = host
POSTGRES_PORT = 5432

I’m using Pushover to send notifications to my phone.

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

senor-octopus-0.1.2.tar.gz (25.7 kB view details)

Uploaded Source

Built Distribution

senor_octopus-0.1.2-py2.py3-none-any.whl (14.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file senor-octopus-0.1.2.tar.gz.

File metadata

  • Download URL: senor-octopus-0.1.2.tar.gz
  • Upload date:
  • Size: 25.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for senor-octopus-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3fe80f65d1f19f5017086d82860a0261b12fdc433a6da96e35c58c928765a62d
MD5 b79f5b88b90650da6df9d268ab62b11a
BLAKE2b-256 b8a16d4488587d71d2bda06c1303a68555fa63feadd36e0301c3adbc58dcdc60

See more details on using hashes here.

Provenance

File details

Details for the file senor_octopus-0.1.2-py2.py3-none-any.whl.

File metadata

  • Download URL: senor_octopus-0.1.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for senor_octopus-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a86b980ef689f21941e3961d1c917bd0eb8f2ba13b0f6dbaaf61befed42e262c
MD5 25b5d4303879fda3fb83cb314e470aa2
BLAKE2b-256 9a4f1e64d134ce5ef3c4501a9b9ee1035d30fd824d6b8d7366b1d9cdb039aaf7

See more details on using hashes here.

Provenance

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