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 withconfig=True, format='json'
- slicing functions (optional) for splitting large data (db tables) by time intervals
- functions with
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 dictionaryself.last_gathered_entries
. Load from persistent storage Dict contains keys equal to collector's registered functions' keys (with @register decorator)_save_last_gathered_entries
: Persistingself.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 serviceMAX_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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file insights-analytics-collector-0.1.1.tar.gz
.
File metadata
- Download URL: insights-analytics-collector-0.1.1.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.64.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9b038cfea60663b5b8300e840d4aa54b37ecb40b2053b96dee3521a32c92f24 |
|
MD5 | 6410c083e7e0194fef4540263ac41be9 |
|
BLAKE2b-256 | 890cf92de9dc78e84af53e2759eeade76a6be031d425a72cbfe656ea26f1e48b |
File details
Details for the file insights_analytics_collector-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: insights_analytics_collector-0.1.1-py3-none-any.whl
- Upload date:
- Size: 24.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.64.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6f2a228bdc333d9258a3264cad9b5aab20cdfc8130f0c0da051c9454d0ccd6b |
|
MD5 | 0256791bf1c074d20cbe72eda530a25f |
|
BLAKE2b-256 | 1a6d04d2e74d71e7035c57c449bcfefe0a0ca4ec816e9de923e78af741dae479 |