Skip to main content

Create translators for the Orwell platform

Project description

Orwell Package For Building Translators

About

Orwell is an open-source platform that allows you to integrate different metrics collectors into one large super-system, storing the data from different sources in Prometheus' format.

With that goal in mind, this package tries to facilitate as much as possible the task of creating translator services compatible with Orwell's architecture.

Development

If a given service's output follows the scheme "host,metric,value", its translator could be built with the following example:

from orwell import Metric, Runner


# The translator function should be able to receive multiple lines
# of the desired service output and return a list of Metric objects

def translate (lines: str) -> list[Metric]:
  metrics = [ line.split(',') for line in lines.split('\n') ]
  return [ Metric(metric, value, { 'host': host }) for host, metric, value in metrics ]


translator = Runner(translate)
translator.run()

Usage

With the example given above we now have three options for running the service:

Command-Line Mode

python main.py cmd <output>

The output will be processed and printed.

Server Mode

python main.py server

A Flask server will start accepting POST requests for /metrics. The body of the request must be a dictionary with the only key metrics. The response will be the processed output whenever the status code is 200.

Environment Variables

FLASK_HOST Default "localhost"

FLASK_PORT Default "5000""

FLASK_DEBUG If set the server will start in debug mode.

Production Mode

python main.py prod

This is the most important mode as it allows to read messages from Kafka and write them to a Redis database, according to the Orwell's architecture.

Environment Variables

REDIS_HOST Default "localhost"

REDIS_PASSWORD Default "root"

KAFKA_HOST Default "localhost""

KAFKA_PORT Default 9093

KAFKA_TOPIC Default "general"

Pull Mode

python main.py pull

This mode allows gathering data from a custom endpoint.

Environment Variables

PULL_ENDPOINT

PULL_INTERVAL Default "localhost"

REDIS_PASSWORD Default "root"

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

orwell_translators-1.1.5.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

orwell_translators-1.1.5-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file orwell_translators-1.1.5.tar.gz.

File metadata

  • Download URL: orwell_translators-1.1.5.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for orwell_translators-1.1.5.tar.gz
Algorithm Hash digest
SHA256 cc6b92446c1091ba4fc9fba9c70d7361d06d19792e83906f3306910f9ad77eb0
MD5 1fe33da645fa6bc0f9d4d69d211c6e89
BLAKE2b-256 b6c0461ce225dabbdf53da015190ac78813acfeb87593e951c109eea737ad9a5

See more details on using hashes here.

File details

Details for the file orwell_translators-1.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for orwell_translators-1.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 16935b66ee350df9ce381c98d1ea9f001f9cb9b9adf941d2802e0aee28932716
MD5 632d373821d724d05726d85747262232
BLAKE2b-256 a1005c7011c4a5144c2802f6d34aa8f4c37ca63b687cd4c70ec00f2c17313a4d

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