Metadata-Version: 2.4
Name: python-yandex-cloud-monitoring
Version: 1.0.0
Summary: Python Client for Yandex Cloud Monitoring
Home-page: https://github.com/mcode-cc/python-yandex-cloud-monitoring
Author: MCode GmbH
Author-email: monitoring.pyclm@mcode.cc
License: GPLv3
Project-URL: Bug Tracker, https://github.com/mcode-cc/python-yandex-cloud-monitoring/issues
Keywords: yandex cloud monitoring trace
Platform: Any
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: No Input/Output (Daemon)
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Internet
Classifier: Topic :: Communications
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: System :: Networking
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: PyJWT>=2.4.0
Requires-Dist: requests>=2.26.0
Requires-Dist: cryptography>41.0.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: platform
Dynamic: project-url
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

[![PyPI](https://img.shields.io/pypi/v/python-yandex-cloud-monitoring)](https://pypi.org/project/python-yandex-cloud-monitoring/)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/python-yandex-cloud-monitoring)
[![PyPI - License](https://img.shields.io/pypi/l/python-yandex-cloud-monitoring)](https://github.com/mcode-cc/python-yandex-cloud-monitoring/blob/main/LICENSE)


# Python Client for Yandex Cloud Monitoring
 
## Supported Python versions

The 1.\*.* release line officially supports Python 3.9–3.12 (see `python_requires` and classifiers in `setup.py`). Make sure your dependencies (especially `cryptography`) are installed with versions compatible with your interpreter.
PyPy - supported but starting from pypy:3.11


## Installation

    pip3 install python-yandex-cloud-monitoring

[Getting started with Yandex Monitoring](https://cloud.yandex.com/en/docs/monitoring/quickstart)

## Credentials

Service Account Keys only ...

[Access management](https://cloud.yandex.com/en/docs/monitoring/security/)


### Service Account Keys & Roles

For write metrics, add a folder role: _monitoring.editor_

```python
import datetime
import random

from pyclm.monitoring import Monitoring

metrics = Monitoring(
    credentials={
        "service_account_key": {
            "service_account_id": "....",
            "id": "....",
            "private_key": "<PEM>"
        },
        "cloudId": "<CLOUD_ID>",
        "folderId": "<FOLDER_ID>"
    },
    group_id="default",
    resource_type="....", resource_id="....",
    elements=100, period=10, workers=1
)

for n in range(1000):
    #  Numeric value (decimal). It shows the metric value at a certain point in time.
    #  For example, the amount of used RAM
    metrics.dgauge(
        "temperature", 
        random.random(), 
        ts=datetime.datetime.now(datetime.timezone.utc), 
        labels={"building": "office", "room": "openspace"}
    )
    #  Tag. It shows the metric value that increases over time.
    #  For example, the number of days of service continuous running.
    metrics.counter("counter", n, labels={"building": "office", "room": "openspace"})
    #  Numeric value (integer). It shows the metric value at a certain point in time.
    metrics.igauge("number", n, labels={"building": "office", "room": "openspace"})
    #  Derivative value. It shows the change in the metric value over time.
    #  For example, the number of requests per second.
    metrics.rate("rate", random.random(), labels={"building": "office", "room": "openspace"})

```

_credentials.cloudId_ - The ID of the cloud that the resource belongs to.

_credentials.folderId_ - The ID of the folder that the resource belongs to.

_resource_type_ - Resource type, serverless.function, hostname.
Value must match the regular expression ([a-zA-Z][-a-zA-Z0-9_.]{0,63})?.

_resource_id_ - Resource ID, i.e., ID of the function producing metrics.
Value must match the regular expression ([a-zA-Z0-9][-a-zA-Z0-9_.]{0,63})?.

_elements_ - The number of elements before writing, must be in the range 1-100.

_period_ -  Number of seconds to wait for new log entries before writing.

_workers_ - Number of process ingestion.

_timeout_ - Timeouts HTTP requests.

Timeouts can be configured via the `timeout` argument:

```python
from pyclm.monitoring import Monitoring

metrics = Monitoring(
    credentials={...},
    group_id="default",
    resource_type="...",
    resource_id="...",
    elements=100,
    period=10,
    workers=1,
    timeout=(3, 5),  # (connect_timeout, read_timeout) in seconds
)
```

By default, `timeout=(3, 5)` is used for all outgoing HTTP requests (connection timeout 3 seconds, read timeout 5 seconds).
