Python Client for Yandex Cloud Monitoring
Project description
Python Client for Yandex Cloud Monitoring
Installation
pip3 install python-yandex-cloud-monitoring
Getting started with Yandex Monitoring
Credentials
Service Account Keys only ...
Service Account Keys
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 indicator. Specified as a fractional number.
metrics.dgauge(
"temperature",
random.random(),
ts=datetime.datetime.now(datetime.timezone.utc),
labels={"building": "office", "room": "openspace"}
)
# Counter.
metrics.counter("counter", n, labels={"building": "office", "room": "openspace"})
# Numeric indicator. Specified as an integer.
metrics.igauge("number", n, labels={"building": "office", "room": "openspace"})
# Derivative.
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
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
Hashes for python-yandex-cloud-monitoring-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72670571cfd3224765fb222423d189e1ba33e323ceeb164b1dc47dfe618698ee |
|
MD5 | 0bca2cbe432518225b1f5ae169283576 |
|
BLAKE2b-256 | 38d0b352aa24dc64aeee4da3a35f098b727183711aaf50208767f132a90f5127 |
Hashes for python_yandex_cloud_monitoring-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48b4d5d6f6ac2e0e45216831e874dff0acbd8fe485ca6edd660a851478f28b35 |
|
MD5 | dd4cb3238753afc43c504df21ba7fff6 |
|
BLAKE2b-256 | 4f5a9d5ba36aa47452f5030b40818152981cc7ce7156577d3cd00288b85ef3ec |