Skip to main content

Python Client for Yandex Cloud Monitoring

Project description

PyPI PyPI - Python Version PyPI - License

Python Client for Yandex Cloud Monitoring

Installation

pip3 install python-yandex-cloud-monitoring

Getting started with Yandex Monitoring

Credentials

Service Account Keys only ...

Access management

Service Account Keys & Roles

For write metrics, add a folder role: monitoring.editor

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.

from pyclm.monitoring import Monitoring, Chrono

metrics = Monitoring()

with Chrono(metrics, name="elapsed", labels={"measured": "calculation"}, mul=10**9):
    # ... measured calculation ...

name - Name of the metric. The default value is elapsed. Additional metric process_{name} sum of the kernel and user-space CPU time.

mul - Process time for profiling default as seconds mul = 10^9 .. nanoseconds mul = 1

labels - Metric labels as key:value pairs.

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

python_yandex_cloud_monitoring-0.0.5.tar.gz (19.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_yandex_cloud_monitoring-0.0.5-py3-none-any.whl (31.8 kB view details)

Uploaded Python 3

File details

Details for the file python_yandex_cloud_monitoring-0.0.5.tar.gz.

File metadata

File hashes

Hashes for python_yandex_cloud_monitoring-0.0.5.tar.gz
Algorithm Hash digest
SHA256 a513641e908cfeb3074a4e6986aab8cf17f01086e72e340f5d934ff4806cd370
MD5 c612f8ed079e4486da0fe832d72122d1
BLAKE2b-256 341ecff2649b959c9b181d01a0ce304656e03f39ccfe5db197872dd45414689c

See more details on using hashes here.

File details

Details for the file python_yandex_cloud_monitoring-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for python_yandex_cloud_monitoring-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8adce598792c8914bff1f17a904b5a1a96399ce024b1893a4c975e00b5e1e0c2
MD5 173d9ea9016a5dff69f3df8401426474
BLAKE2b-256 f244b4bfc8fd6b44e60a6605901c57dabaf881aaf8d50621fb94886a9c3e333d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page