cloudzero-uca-tools


Namecloudzero-uca-tools JSON
Version 0.7.11 PyPI version JSON
download
home_pageNone
SummaryCloudZero UCA Toolkit
upload_time2024-08-17 02:06:17
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseApache-2.0
keywords cloudzero toolkit uca analysis cost economics unit
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # CloudZero UCA Toolkit
Utilities for generating, transforming and transmitting unit cost analytics (UCA) data to the CloudZero API.
Visit our [UCA documentation](https://docs.cloudzero.com/docs/unit-cost-analytics) to learn more about
[CloudZero](https://www.cloudzero.com) and our enhanced unit cost analytics capabilities.

## Features
* Transmit UCA data to CloudZero (using the CloudZero UCA API)
* Generate UCA data
* Convert raw data in CSV form to UCA JSON format

## Prerequisites
* Tested on MacOS, should probably run on Linux in general
* Python 3.9 or newer
* `pipx` or your favorite method of installing packages from PyPi. Have you considered [pipx](https://pypa.github.io/pipx/)?

## Installation
      $ pipx install cloudzero-uca-tools

## Quick Starts

* [Allocation Telemetry Quick Start](docs/quick_starts/quick_start_allocation_telemetry/quick_start_allocation_telemetry.md)
* [Unit Metric Telemetry Quick Start](docs/quick_starts/quick_start_unit_metric_telemetry/quick_start_unit_metric_telemetry.md)

## General Usage

CloudZero UCA tools exist to produce UCA events that can then be transmitted to the CloudZero API
for analysis and processing. To use the CloudZero API, you should first obtain an [API key](https://app.cloudzero.com/organization/api-keys)
from https://app.cloudzero.com/organization/api-keys

    $ uca
    Usage: uca [OPTIONS] COMMAND [ARGS]...
    
      CloudZero Unit Cost Analytics Toolkit
    
    Options:
      --version                 Show the version and exit.
      -c, --configuration TEXT  UCA configuration file (JSON)
      -dry, --dry-run           Perform a dry run, read and transform the data but
                                do not send it to the API. Sample events will be output to the screen
      -k, --api-key TEXT        API Key to use
      --help                    Show this message and exit.
    
    Commands:
      convert
      transmit
      generate

### Basic Configuration
A configuration file is typically required to define how UCA telemetry is to be created, converted or transmitted.
The following is a minimal configuration file for transmitting data to the CloudZero API 
(if you don't want to specify the API on the command line, otherwise no configuration file 
is required for `transmit`). If you wish to use `generate` or `convert` however a configuration file
is required.

    {
      "version": "1",                               
      "settings": {
        "api_key": "<YOUR API KEY HERE>"
      }
    }

    # API Key can also be provided at runtime via the CLI. Get an API key at https://app.cloudzero.com/organization/api-keys

Each command has its own set of command line options that will need to be provided as well 

## Transmit
`transmit` allows you send UCA data directly to the CloudZero API without having to write
code. To use `transmit` you prepare in advance an [ND-JSON](http://ndjson.org/) formatted input file
which contains one or more correctly formatted JSON UCA records as input. 

### Help
    $ uca transmit --help
    Usage: uca transmit [OPTIONS]
    
    Options:
      -d, --data TEXT       Source data, in text or gzip + text format, supports
                            file:// or s3:// paths  [required]
      -o, --output TEXT     Instead of sending events to the API, write
                            events to an output file (note: will overwrite file if it exists)
      -t, --transform TEXT  Optional transformation script using jq
                            (https://stedolan.github.io/jq/). Used when the source
                            data needs modification or cleanup. See README.md for
                            usage instructions
      --help                Show this message and exit.

### input data
Your input data must be a valid [ND-JSON](http://ndjson.org/) document which can be either a text or gzip file,
consisting of one JSON record per line. 

For example:

     {'timestamp': '2021-03-22 00:00:00+00:00', 'granularity': 'DAILY', 'element-name': 'StateEx', 'filter': {"custom:Environment": ["Production"]}, 'telemetry-stream': 'test-data', 'value': '40.0000'} 
     {'timestamp': '2021-04-01 00:00:00+00:00', 'granularity': 'DAILY', 'element-name': 'Hooli', 'filter': {"custom:Environment": ["Production"]}, 'telemetry-stream': 'test-data', 'value': '23.0000'}

#### Using an optional JQ transform
You can optionally provide a JQ script to transform the source data on the fly before transmission. 
This is helpful when you have minor or even major changes you want to make to the data quickly, and
it would be more complicated or impossible to alter the input data (for example an existing system
is producing UCA data in an older format).

##### Example JQ Script
The following script requires the `id` field to be present (records missing this field will be skipped), followed
by setting the target field using a metadata and cost-context field, followed by setting the cost-context to a 
constant value and then deleting the metadata and uca fields

    select(.id != "")
    | .filter = {"tag:environment": [.metadata.environment], "tag:feature": [".metadata.feature"] }
    | del(.metadata, .uca)

##### Example Input before JQ transform:
    {
      "uca": "v1.5",
      "timestamp": "2021-05-25 13:00:00+0000",
      "granularity": "HOURLY",
      "element-name": "frank",
      "telemetry-stream": "test-data",
      "value": "1073641",
      "metadata": {
        "environment": "production",
        "feature": "rosebud"
      }
    }

##### Example Transformed Output after JQ transform:
    {
      "timestamp": "2021-05-25 13:00:00",
      "granularity": "HOURLY",
      "id": "frank",
      "filter": {
        "tag:environment": ["production"],
        "tag:feature": ["rosebud"]
      },
      "telemetry-stream": "Cost-Per-Customer",
      "value": "1073641"
    }

## Convert
`convert` allows you to convert raw data in CSV format to UCA JSON format. To use `convert` you prepare in advance a CSV file of the
raw unit cost data you wish to convert and then define the mapping of the CSV columns to UCA fields in a configuration file.

### Help
    $ uca generate --help
    Usage: uca convert [OPTIONS]
    
    Options:
      -d, --data TEXT  Source data, in text or gzip + text format, supports
                       file:// or s3:// paths  [required]
      --help           Show this message and exit.

### Configuration File
    {
      "version": "1",
      "template": {
        "timestamp": "$ACCESS_TIME",
        "granularity": "HOURLY",
        "element-name": "$CUST_ID",
        "filter": {
          "custom:Environment": [
            "Prod"
          ]
        },
        "telemetry-stream": "cost-per-customer",
        "value": "$DURATION"
      },
      "settings": {
        "api_key": "<YOUR API KEY HERE>"            # Also can be provided at runtime via the CLI. Get an API key at https://app.cloudzero.com/organization/api-keys
        "convert": {
          "stream_name": "cost-per-customer",
          "format": "CSV",                          # currently only CSV is supported
          "schema": {
            "columns": {                            # Define one or more columns that will be used from the input CSV file
              "CUST_ID": {                          # The name of the column in the CSV file
                "type": "STRING"                    # Specify the type of the column to ensure proper conversion, can be STRING, NUMBER, DATETIME or TIME
              },
              "ACCESS_TIME": {
                "type": "DATETIME"                  # DATETIME is a special type that will attempt to convert a wide range of datetime formats (including unix timestamp) to ISO 8601 UTC format 
              },
              "DURATION": {
                "type": "TIME",                     # TIME is a special type that will convert a time duration expressed in HH:mm:ss to seconds
                "format": "HH:mm:ss"
              }
            }
          }
        }
      }
    }

#### Examples
Convert raw data from `data-file.csv` into UCA JSON format using a `config-file.json` as configuration, and write to `output-file.json`

    $ uca convert -d data-file.csv -c config-file.json -o output-file.json 


## Generate
`generate` will create UCA data over a defined time period based on rules and source data (CSV) that you define.
Rules enable you to define how the data is to be generated based on the provided source data and can be used to 
create static allocations, dynamic allocations, or even random allocations that can be used to verify system operation
or facilitate a demonstration.

### Help
    $ uca generate --help
    Usage: uca generate [OPTIONS]
    
    Options:
      -s, --start TEXT   start datetime <YYYY-MM-DD HH:MM:SS>                      [optional]
      -e, --end TEXT     End datetime <YYYY-MM-DD HH:MM:SS>                        [optional]
      --today            Generate events for the current day                       [optional]
      -d, --data TEXT    Input UCA data (CSV)                                      [required]
      -o, --output TEXT  Instead of transmitting the data to the CloudZero API,    [optional]
                         Save the output to a file.
      --help             Show this message and exit.                               [optional]

#### Examples
Generate UCA data between 2021-03-13 and 2021-04-07 using data/configuration.json and data/data.csv as input. 
Performs only a dry run and do not send the results to the CloudZero API

    $ uca generate -s 2021-03-13 -e 2021-04-07 -c data/configuration.json -d data/data.csv --dry-run

Generate UCA data using data/configuration.json and data/data.csv (which must contain a timestamp column) 
as input. Performs only a dry run and do not send the results to the CloudZero API

    $ uca generate -s 2021-03-13 -e 2021-04-07 -c data/configuration.json -d data/data.csv --dry-run


#### Configuration File
The `generate` command requires a UCA template definition and specific settings that should be applied when generating data. You 
can learn more [about the UCA format and our UCA Telemetry API here](https://docs.cloudzero.com/reference#telemetry).

    {
      "version": "1",                               # can be anything you want that helps you keep track of things
      "template": {
        "timestamp": "$timestamp",                  # Timestamp will be replaced automatically or from the input data source
        "granularity": "DAILY",                     # Granularity can be HOURLY, DAILY or MONTHLY. See notes below for usage
        "element-name": "$element_name",            # Will be replaced using data from your data CSV
        "filter": {},                               # Use a filter to map spend to a combination of tags, dimensions, accounts, etc...
        "telemetry-stream": "test-data",            # Unique name for this telemetry stream          
        "value": "$value"                           # Will be replaced using generated data or data from your data CSV
      },
      "settings": {
        "generate": {
          "mode": "exact",                          # Can be `exact`, `random`, `jitter` or `allocation`
          "jitter": 15,                             # if mode is jitter, defines the +/- random range to applie to the $value
          "allocation": 1000                        # if mode is allocation, defines the total amount to be allocated across elements in your data file
          "precision": 4                            # The number of desired decimal places. If not provided, the default is 4
        },
        "api_key": "<YOUR API KEY HERE>"            # Also can be provided at runtime via the CLI. Get an API key at https://app.cloudzero.com/organization/api-keys
      }
    }

##### A note on using MONTHLY granularity.
MONTHLY is a special (non-standard) granularity that can only be used with the UCA toolkit. MONTHLY will expand the input data 
over the year and month provided to all possible days in a given month to create DAILY UCA telemetry.

For example if you have this input data:

     element_name,timestamp,value
     "SuperDogs, Inc",2022-10-1,8
     "CoolCats, LLC",2022-10-1,229

This will expand to 61 events, 31 for "SuperDogs, Inc" and 31 for "CoolCats, LLC" (31 days in October) 

#### Data CSV
The data CSV defines the input data you wish to feed into the template to produce
matching UCA records for all rows in your data CSV for each hour or day as defined. The following
example has 13 "customers" and can be used as input for all configuration modes (`exact`, `random`, `jitter`, or `allocation`).

        element_name,value,allocation
        Sunbank,37,8.5574
        SoftwareCorp,17,0.4091
        "Parts, Inc.",140,10.9955
        Transport Co.,25,6.3033
        "WeShipit, Inc.",124,23.7549
        CapitalTwo,90,1.5231
        Bank of Sokovia,43,0.1198
        Makers,9,1.0767
        StateEx,40,3.5057
        Flitter,15,22.9554
        Pets2you,78,6.3358
        Hooli,23,4.3294
        Massive Dynamic,42,10.1339

#### Example output
Using the `exact` configuration above, this data will produce UCA events similar to the following:

    {'timestamp': '2021-03-22 00:00:00+00:00', 'granularity': 'DAILY', 'element-name': 'StateEx', 'filter': {}, 'telemetry-stream': 'test-data', 'value': '40.0000'}
    {'timestamp': '2021-04-01 00:00:00+00:00', 'granularity': 'DAILY', 'element-name': 'Hooli', 'filter': {}, 'telemetry-stream': 'test-data', 'value': '23.0000'}
    {'timestamp': '2021-04-01 00:00:00+00:00', 'granularity': 'DAILY', 'element-name': 'Sunbank', 'filter': {}, 'telemetry-stream': 'test-data', 'value': '37.0000'}
    {'timestamp': '2021-04-06 00:00:00+00:00', 'granularity': 'DAILY', 'element-name': 'Transport Co.', 'filter': {}, 'telemetry-stream': 'test-data', 'value': '25.0000'}
    {'timestamp': '2021-03-19 00:00:00+00:00', 'granularity': 'DAILY', 'element-name': 'StateEx', 'filter': {}, 'telemetry-stream': 'test-data', 'value': '40.0000'}

## Testing/Developing
First create a virtual environment of your choice, and activate it. Then, install UCA Toolkit for local development:
```bash
python -m pip install --editable .
```
Run the following commands if you had previously installed it using pip or pipx:

1. Uninstall `uca` (e.g. pipx uninstall cloudzero-uca-tools)
2. Create a Virtualenv for your `uca` development
3. Enter your virtualenv and install all of the necessary dependencies by running make init
4. Finally, configure `uca` for use in your environment using pip install -e .
5. Once that is done, the `uca` cli will be available in your shell (you may or may not need to restart your shell).
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "cloudzero-uca-tools",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "CloudZero, Toolkit, UCA, analysis, cost, economics, unit",
    "author": null,
    "author_email": "CloudZero <support@cloudzero.com>",
    "download_url": "https://files.pythonhosted.org/packages/dc/93/4760db3fa9f0fd9718abf2c6c9b62a6e67c3f2e2ab53dc8e2af3bbd9176b/cloudzero_uca_tools-0.7.11.tar.gz",
    "platform": null,
    "description": "# CloudZero UCA Toolkit\nUtilities for generating, transforming and transmitting unit cost analytics (UCA) data to the CloudZero API.\nVisit our [UCA documentation](https://docs.cloudzero.com/docs/unit-cost-analytics) to learn more about\n[CloudZero](https://www.cloudzero.com) and our enhanced unit cost analytics capabilities.\n\n## Features\n* Transmit UCA data to CloudZero (using the CloudZero UCA API)\n* Generate UCA data\n* Convert raw data in CSV form to UCA JSON format\n\n## Prerequisites\n* Tested on MacOS, should probably run on Linux in general\n* Python 3.9 or newer\n* `pipx` or your favorite method of installing packages from PyPi. Have you considered [pipx](https://pypa.github.io/pipx/)?\n\n## Installation\n      $ pipx install cloudzero-uca-tools\n\n## Quick Starts\n\n* [Allocation Telemetry Quick Start](docs/quick_starts/quick_start_allocation_telemetry/quick_start_allocation_telemetry.md)\n* [Unit Metric Telemetry Quick Start](docs/quick_starts/quick_start_unit_metric_telemetry/quick_start_unit_metric_telemetry.md)\n\n## General Usage\n\nCloudZero UCA tools exist to produce UCA events that can then be transmitted to the CloudZero API\nfor analysis and processing. To use the CloudZero API, you should first obtain an [API key](https://app.cloudzero.com/organization/api-keys)\nfrom https://app.cloudzero.com/organization/api-keys\n\n    $ uca\n    Usage: uca [OPTIONS] COMMAND [ARGS]...\n    \n      CloudZero Unit Cost Analytics Toolkit\n    \n    Options:\n      --version                 Show the version and exit.\n      -c, --configuration TEXT  UCA configuration file (JSON)\n      -dry, --dry-run           Perform a dry run, read and transform the data but\n                                do not send it to the API. Sample events will be output to the screen\n      -k, --api-key TEXT        API Key to use\n      --help                    Show this message and exit.\n    \n    Commands:\n      convert\n      transmit\n      generate\n\n### Basic Configuration\nA configuration file is typically required to define how UCA telemetry is to be created, converted or transmitted.\nThe following is a minimal configuration file for transmitting data to the CloudZero API \n(if you don't want to specify the API on the command line, otherwise no configuration file \nis required for `transmit`). If you wish to use `generate` or `convert` however a configuration file\nis required.\n\n    {\n      \"version\": \"1\",                               \n      \"settings\": {\n        \"api_key\": \"<YOUR API KEY HERE>\"\n      }\n    }\n\n    # API Key can also be provided at runtime via the CLI. Get an API key at https://app.cloudzero.com/organization/api-keys\n\nEach command has its own set of command line options that will need to be provided as well \n\n## Transmit\n`transmit` allows you send UCA data directly to the CloudZero API without having to write\ncode. To use `transmit` you prepare in advance an [ND-JSON](http://ndjson.org/) formatted input file\nwhich contains one or more correctly formatted JSON UCA records as input. \n\n### Help\n    $ uca transmit --help\n    Usage: uca transmit [OPTIONS]\n    \n    Options:\n      -d, --data TEXT       Source data, in text or gzip + text format, supports\n                            file:// or s3:// paths  [required]\n      -o, --output TEXT     Instead of sending events to the API, write\n                            events to an output file (note: will overwrite file if it exists)\n      -t, --transform TEXT  Optional transformation script using jq\n                            (https://stedolan.github.io/jq/). Used when the source\n                            data needs modification or cleanup. See README.md for\n                            usage instructions\n      --help                Show this message and exit.\n\n### input data\nYour input data must be a valid [ND-JSON](http://ndjson.org/) document which can be either a text or gzip file,\nconsisting of one JSON record per line. \n\nFor example:\n\n     {'timestamp': '2021-03-22 00:00:00+00:00', 'granularity': 'DAILY', 'element-name': 'StateEx', 'filter': {\"custom:Environment\": [\"Production\"]}, 'telemetry-stream': 'test-data', 'value': '40.0000'} \n     {'timestamp': '2021-04-01 00:00:00+00:00', 'granularity': 'DAILY', 'element-name': 'Hooli', 'filter': {\"custom:Environment\": [\"Production\"]}, 'telemetry-stream': 'test-data', 'value': '23.0000'}\n\n#### Using an optional JQ transform\nYou can optionally provide a JQ script to transform the source data on the fly before transmission. \nThis is helpful when you have minor or even major changes you want to make to the data quickly, and\nit would be more complicated or impossible to alter the input data (for example an existing system\nis producing UCA data in an older format).\n\n##### Example JQ Script\nThe following script requires the `id` field to be present (records missing this field will be skipped), followed\nby setting the target field using a metadata and cost-context field, followed by setting the cost-context to a \nconstant value and then deleting the metadata and uca fields\n\n    select(.id != \"\")\n    | .filter = {\"tag:environment\": [.metadata.environment], \"tag:feature\": [\".metadata.feature\"] }\n    | del(.metadata, .uca)\n\n##### Example Input before JQ transform:\n    {\n      \"uca\": \"v1.5\",\n      \"timestamp\": \"2021-05-25 13:00:00+0000\",\n      \"granularity\": \"HOURLY\",\n      \"element-name\": \"frank\",\n      \"telemetry-stream\": \"test-data\",\n      \"value\": \"1073641\",\n      \"metadata\": {\n        \"environment\": \"production\",\n        \"feature\": \"rosebud\"\n      }\n    }\n\n##### Example Transformed Output after JQ transform:\n    {\n      \"timestamp\": \"2021-05-25 13:00:00\",\n      \"granularity\": \"HOURLY\",\n      \"id\": \"frank\",\n      \"filter\": {\n        \"tag:environment\": [\"production\"],\n        \"tag:feature\": [\"rosebud\"]\n      },\n      \"telemetry-stream\": \"Cost-Per-Customer\",\n      \"value\": \"1073641\"\n    }\n\n## Convert\n`convert` allows you to convert raw data in CSV format to UCA JSON format. To use `convert` you prepare in advance a CSV file of the\nraw unit cost data you wish to convert and then define the mapping of the CSV columns to UCA fields in a configuration file.\n\n### Help\n    $ uca generate --help\n    Usage: uca convert [OPTIONS]\n    \n    Options:\n      -d, --data TEXT  Source data, in text or gzip + text format, supports\n                       file:// or s3:// paths  [required]\n      --help           Show this message and exit.\n\n### Configuration File\n    {\n      \"version\": \"1\",\n      \"template\": {\n        \"timestamp\": \"$ACCESS_TIME\",\n        \"granularity\": \"HOURLY\",\n        \"element-name\": \"$CUST_ID\",\n        \"filter\": {\n          \"custom:Environment\": [\n            \"Prod\"\n          ]\n        },\n        \"telemetry-stream\": \"cost-per-customer\",\n        \"value\": \"$DURATION\"\n      },\n      \"settings\": {\n        \"api_key\": \"<YOUR API KEY HERE>\"            # Also can be provided at runtime via the CLI. Get an API key at https://app.cloudzero.com/organization/api-keys\n        \"convert\": {\n          \"stream_name\": \"cost-per-customer\",\n          \"format\": \"CSV\",                          # currently only CSV is supported\n          \"schema\": {\n            \"columns\": {                            # Define one or more columns that will be used from the input CSV file\n              \"CUST_ID\": {                          # The name of the column in the CSV file\n                \"type\": \"STRING\"                    # Specify the type of the column to ensure proper conversion, can be STRING, NUMBER, DATETIME or TIME\n              },\n              \"ACCESS_TIME\": {\n                \"type\": \"DATETIME\"                  # DATETIME is a special type that will attempt to convert a wide range of datetime formats (including unix timestamp) to ISO 8601 UTC format \n              },\n              \"DURATION\": {\n                \"type\": \"TIME\",                     # TIME is a special type that will convert a time duration expressed in HH:mm:ss to seconds\n                \"format\": \"HH:mm:ss\"\n              }\n            }\n          }\n        }\n      }\n    }\n\n#### Examples\nConvert raw data from `data-file.csv` into UCA JSON format using a `config-file.json` as configuration, and write to `output-file.json`\n\n    $ uca convert -d data-file.csv -c config-file.json -o output-file.json \n\n\n## Generate\n`generate` will create UCA data over a defined time period based on rules and source data (CSV) that you define.\nRules enable you to define how the data is to be generated based on the provided source data and can be used to \ncreate static allocations, dynamic allocations, or even random allocations that can be used to verify system operation\nor facilitate a demonstration.\n\n### Help\n    $ uca generate --help\n    Usage: uca generate [OPTIONS]\n    \n    Options:\n      -s, --start TEXT   start datetime <YYYY-MM-DD HH:MM:SS>                      [optional]\n      -e, --end TEXT     End datetime <YYYY-MM-DD HH:MM:SS>                        [optional]\n      --today            Generate events for the current day                       [optional]\n      -d, --data TEXT    Input UCA data (CSV)                                      [required]\n      -o, --output TEXT  Instead of transmitting the data to the CloudZero API,    [optional]\n                         Save the output to a file.\n      --help             Show this message and exit.                               [optional]\n\n#### Examples\nGenerate UCA data between 2021-03-13 and 2021-04-07 using data/configuration.json and data/data.csv as input. \nPerforms only a dry run and do not send the results to the CloudZero API\n\n    $ uca generate -s 2021-03-13 -e 2021-04-07 -c data/configuration.json -d data/data.csv --dry-run\n\nGenerate UCA data using data/configuration.json and data/data.csv (which must contain a timestamp column) \nas input. Performs only a dry run and do not send the results to the CloudZero API\n\n    $ uca generate -s 2021-03-13 -e 2021-04-07 -c data/configuration.json -d data/data.csv --dry-run\n\n\n#### Configuration File\nThe `generate` command requires a UCA template definition and specific settings that should be applied when generating data. You \ncan learn more [about the UCA format and our UCA Telemetry API here](https://docs.cloudzero.com/reference#telemetry).\n\n    {\n      \"version\": \"1\",                               # can be anything you want that helps you keep track of things\n      \"template\": {\n        \"timestamp\": \"$timestamp\",                  # Timestamp will be replaced automatically or from the input data source\n        \"granularity\": \"DAILY\",                     # Granularity can be HOURLY, DAILY or MONTHLY. See notes below for usage\n        \"element-name\": \"$element_name\",            # Will be replaced using data from your data CSV\n        \"filter\": {},                               # Use a filter to map spend to a combination of tags, dimensions, accounts, etc...\n        \"telemetry-stream\": \"test-data\",            # Unique name for this telemetry stream          \n        \"value\": \"$value\"                           # Will be replaced using generated data or data from your data CSV\n      },\n      \"settings\": {\n        \"generate\": {\n          \"mode\": \"exact\",                          # Can be `exact`, `random`, `jitter` or `allocation`\n          \"jitter\": 15,                             # if mode is jitter, defines the +/- random range to applie to the $value\n          \"allocation\": 1000                        # if mode is allocation, defines the total amount to be allocated across elements in your data file\n          \"precision\": 4                            # The number of desired decimal places. If not provided, the default is 4\n        },\n        \"api_key\": \"<YOUR API KEY HERE>\"            # Also can be provided at runtime via the CLI. Get an API key at https://app.cloudzero.com/organization/api-keys\n      }\n    }\n\n##### A note on using MONTHLY granularity.\nMONTHLY is a special (non-standard) granularity that can only be used with the UCA toolkit. MONTHLY will expand the input data \nover the year and month provided to all possible days in a given month to create DAILY UCA telemetry.\n\nFor example if you have this input data:\n\n     element_name,timestamp,value\n     \"SuperDogs, Inc\",2022-10-1,8\n     \"CoolCats, LLC\",2022-10-1,229\n\nThis will expand to 61 events, 31 for \"SuperDogs, Inc\" and 31 for \"CoolCats, LLC\" (31 days in October) \n\n#### Data CSV\nThe data CSV defines the input data you wish to feed into the template to produce\nmatching UCA records for all rows in your data CSV for each hour or day as defined. The following\nexample has 13 \"customers\" and can be used as input for all configuration modes (`exact`, `random`, `jitter`, or `allocation`).\n\n        element_name,value,allocation\n        Sunbank,37,8.5574\n        SoftwareCorp,17,0.4091\n        \"Parts, Inc.\",140,10.9955\n        Transport Co.,25,6.3033\n        \"WeShipit, Inc.\",124,23.7549\n        CapitalTwo,90,1.5231\n        Bank of Sokovia,43,0.1198\n        Makers,9,1.0767\n        StateEx,40,3.5057\n        Flitter,15,22.9554\n        Pets2you,78,6.3358\n        Hooli,23,4.3294\n        Massive Dynamic,42,10.1339\n\n#### Example output\nUsing the `exact` configuration above, this data will produce UCA events similar to the following:\n\n    {'timestamp': '2021-03-22 00:00:00+00:00', 'granularity': 'DAILY', 'element-name': 'StateEx', 'filter': {}, 'telemetry-stream': 'test-data', 'value': '40.0000'}\n    {'timestamp': '2021-04-01 00:00:00+00:00', 'granularity': 'DAILY', 'element-name': 'Hooli', 'filter': {}, 'telemetry-stream': 'test-data', 'value': '23.0000'}\n    {'timestamp': '2021-04-01 00:00:00+00:00', 'granularity': 'DAILY', 'element-name': 'Sunbank', 'filter': {}, 'telemetry-stream': 'test-data', 'value': '37.0000'}\n    {'timestamp': '2021-04-06 00:00:00+00:00', 'granularity': 'DAILY', 'element-name': 'Transport Co.', 'filter': {}, 'telemetry-stream': 'test-data', 'value': '25.0000'}\n    {'timestamp': '2021-03-19 00:00:00+00:00', 'granularity': 'DAILY', 'element-name': 'StateEx', 'filter': {}, 'telemetry-stream': 'test-data', 'value': '40.0000'}\n\n## Testing/Developing\nFirst create a virtual environment of your choice, and activate it. Then, install UCA Toolkit for local development:\n```bash\npython -m pip install --editable .\n```\nRun the following commands if you had previously installed it using pip or pipx:\n\n1. Uninstall `uca` (e.g. pipx uninstall cloudzero-uca-tools)\n2. Create a Virtualenv for your `uca` development\n3. Enter your virtualenv and install all of the necessary dependencies by running make init\n4. Finally, configure `uca` for use in your environment using pip install -e .\n5. Once that is done, the `uca` cli will be available in your shell (you may or may not need to restart your shell).",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "CloudZero UCA Toolkit",
    "version": "0.7.11",
    "project_urls": {
        "Homepage": "https://github.com/Cloudzero/cloudzero-uca-tools"
    },
    "split_keywords": [
        "cloudzero",
        " toolkit",
        " uca",
        " analysis",
        " cost",
        " economics",
        " unit"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d34de93de9d599bda50d944bdca831d55667befc0fee3f9936e5e7e8223425c6",
                "md5": "e65400a4f28b6d0cec9551a166c2f766",
                "sha256": "b6a6487faf74b23f985b68e547b4e3ac766b2c12f0b04e9fa7ec0aabd15c8cad"
            },
            "downloads": -1,
            "filename": "cloudzero_uca_tools-0.7.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e65400a4f28b6d0cec9551a166c2f766",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 44070,
            "upload_time": "2024-08-17T02:06:15",
            "upload_time_iso_8601": "2024-08-17T02:06:15.702207Z",
            "url": "https://files.pythonhosted.org/packages/d3/4d/e93de9d599bda50d944bdca831d55667befc0fee3f9936e5e7e8223425c6/cloudzero_uca_tools-0.7.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dc934760db3fa9f0fd9718abf2c6c9b62a6e67c3f2e2ab53dc8e2af3bbd9176b",
                "md5": "dbae7b62703f6a399dc0aa8d005f89d0",
                "sha256": "cfc9369254d0658ba878985a16cab5c6a7c6f147bef68aaece92e6876aa3d102"
            },
            "downloads": -1,
            "filename": "cloudzero_uca_tools-0.7.11.tar.gz",
            "has_sig": false,
            "md5_digest": "dbae7b62703f6a399dc0aa8d005f89d0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 30904,
            "upload_time": "2024-08-17T02:06:17",
            "upload_time_iso_8601": "2024-08-17T02:06:17.980116Z",
            "url": "https://files.pythonhosted.org/packages/dc/93/4760db3fa9f0fd9718abf2c6c9b62a6e67c3f2e2ab53dc8e2af3bbd9176b/cloudzero_uca_tools-0.7.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-17 02:06:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Cloudzero",
    "github_project": "cloudzero-uca-tools",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "cloudzero-uca-tools"
}
        
Elapsed time: 0.60700s