yandex-cloud-monitoring-metrics
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

yandex-cloud-monitoring-metrics

A library for sending metrics to yandex cloud monitoring.

API doc https://cloud.yandex.com/en/docs/monitoring/operations/metric/add.

Supported metric types

  1. DGAUGE: shows the metric value at a certain point in time. For example, the amount of used RAM.
  2. GAUGE: shows the metric value at a certain point in time.
  3. COUNTER: shows the metric value that increases over time. For example, the number of days of service continuous running.
  4. RATE: shows the change in the metric value over time. For example, the number of requests per second.

Getting started

  1. Get the ID of the folder for which you are granted the monitoring.editor role or a higher role (https://cloud.yandex.com/en/docs/resource-manager/operations/folder/get-id)
  2. Create a service account https://cloud.yandex.com/en-ru/docs/iam/concepts/users/service-accounts with monitoring.writer permission
  3. Store the service account ID, access key ID and private key

Install

npm install yandex-cloud-monitoring-metrics

Usage

const metricsLogger = new YandexCloudMonitoringMetricsLogger(
  process.env.SERVICE_ACCOUNT_ID,
  process.env.ACCESS_KEY_ID,
  process.env.PRIVATE_KEY,
  process.env.FOLDER_ID
);

const metrics: IYandexMetricRequest = {
  metrics: [
    {
      name: 'performance.metric',
      type: YandexMetricType.GAUGE,
      value: 150,
      labels: {
        env: 'production',
        tag1: 'value1',
      },
    },
  ],
};

const { writtenMetricsCount, error } = await metricsLogger.writeMetrics(
  metrics
);

Package Sidebar

Install

npm i yandex-cloud-monitoring-metrics

Weekly Downloads

174

Version

1.1.0

License

MIT

Unpacked Size

12.8 kB

Total Files

9

Last publish

Collaborators

  • enigmadalio7