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 & 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
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.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93ee6b468f929a1450024a95106e19886b4dbc245de895a05d66ae7e5f192a47 |
|
MD5 | c087b564d20a96e62fce8e0a9251a3af |
|
BLAKE2b-256 | e5ef926bcebcbab75719d79a3c3235d0eb11df266bc32fc62e9ea3772eb43bca |
Hashes for python_yandex_cloud_monitoring-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9cb7a7904b96a1313e03e6d6fbbea7be2b1b20798f23ccebbfdd27658c6a4ee |
|
MD5 | 44cd41ae2662fd6b3f9b1ab826cd25c5 |
|
BLAKE2b-256 | 412a3593fa5fd215741bcf55ca9298e2ea5aa0e4f371ad489ea7b72463de913c |