Skip to main content

Collector Package for Insights for AAP

Project description

Insights Analytics Collector

This package helps with collecting data by user-defined collector methods. It packs collected data to one or more tarballs and sends them to user-defined URL.

Some data and classes has to be implemented. By function:

  • persisting settings
  • data like credentials, content type etc. for shipping (POST request)

By Classes:

  • Collector
  • Package
  • collector_module:
    • functions with @register decorator, one with config=True, format='json'
    • slicing functions (optional) for splitting large data (db tables) by time intervals

Implement Collector

Collector is an Abstract class, implement abstract methods.

  • _package_class: Returns class of your implementation of Package
  • _is_valid_license: Check for valid license specific to your service
  • _is_shipping_configured: Check if shipping to cloud is configured
  • _last_gathering: returns datetime. Loading last successful run from some persistent storage
  • _save_last_gather: Persisting last successful run
  • _load_last_gathered_entries: Has to fill dictionary self.last_gathered_entries. Load from persistent storage Dict contains keys equal to collector's registered functions' keys (with @register decorator)
  • _save_last_gathered_entries: Persisting self.last_gathered_entries

An example can be found in Test collector

Implement Package

Package is also abstract class. You have to implement basically info for POST request to cloud.

  • PAYLOAD_CONTENT_TYPE: contains registered content type for cloud's ingress service
  • MAX_DATA_SIZE: maximum size in bytes of uncompressed data for one tarball. Ingress limits uploads to 100MB. Defaults to 200MB.
  • get_ingress_url: Cloud's ingress service URL
  • _get_rh_user: User for POST request
  • _get_rh_password: Password for POST request
  • _get_x_rh_identity: X-RH Identity Used for local testing instead of user and password
  • _get_http_request_headers: Dict with any custom headers for POST request

An example can be found in Test package

Collector module

Module with gathering functions is the main part you need to implement. It should contain functions returning data either in dict format or list of CSV files.

Function is registered by @register decorator:

from insights_analytics_collector import register

@register('json_data', '1.0', format='json', description="Data description")
def json_data(**kwargs):
    return {'my_data': 'True'}

Decorator @register has following attributes:

  • key: (string) name of output file (usually the same as function name)
  • version: (string) i.e. '1.0'. Version of data - added to the manifest.json for parsing on cloud's side
  • description: (string) not used yet
  • format: (string) Default: 'json' extension of output file, can be "json" of "csv". Also determines function output.
  • config: (bool) Default: False. there has to be one function with config=True, format=json
  • fnc_slicing: Intended for large data. Described in Slicing function below
  • shipping_group: (string) Default: 'default'. Splits data to packages by group, if required.
from <your-namespace> import Collector  # your implementation

collector = Collector
collector.gather()

Slicing function

Collectors

Registered collectors

Abstract classes

Tarballs

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

insights-analytics-collector-0.0.1.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file insights-analytics-collector-0.0.1.tar.gz.

File metadata

  • Download URL: insights-analytics-collector-0.0.1.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for insights-analytics-collector-0.0.1.tar.gz
Algorithm Hash digest
SHA256 09aca0771a496df7d68d1d76f161017bb59660f9526c92bc1f4a1e2fc6b102b6
MD5 7a901a9d0f9eef22d96a2e3e4ee4a14a
BLAKE2b-256 57130e3e00950b9d1c6807ac5daace89990ea457da24d9821c9771bc16922749

See more details on using hashes here.

File details

Details for the file insights_analytics_collector-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: insights_analytics_collector-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for insights_analytics_collector-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7a69a3b0a6cacbee134d2d8aba895f52c71eccb9d0a8be7211c5f76a3fadab5d
MD5 f3ac5c6e98a0ad03b9936bbd0138ca1d
BLAKE2b-256 eb38106cbc93ea0a65f97faf9163c18fb29646466a692943eea13b9bb6eeeed8

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