1.4.0 ā€¢ Published 1 year ago

@classapp-tech/prometheus-integration v1.4.0

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

@classapp-tech/prometheus-integration

āœ… 100% test coverage

Unit Test

Installation

Use the package manager node to install.

npm install @classapp-tech/prometheus-integration

Usage

To send metrics to the Prometheus Aggregation Gateway it is necessary to be in the same network (VPC), that is, from a Lambda or EC2 machine.

Example code to send metrics from a Lambda:

import { PrometheusAggregator } from '../index';

exports.handler = async (event) => {
  const prometheusAggregator = new PrometheusAggregator({
    endpoint: "your-endpoint-here.co",
    logger: {
      info: (message: string) => {
        // you can handle info messages from prometheus-integration here
      },
      warn: (message: string) => {
        // you can handle warnings from prometheus-integration here
      },
      error: (message: string) => {
        // you can handle errors from prometheus-integration here
      },
    }
  });

  // ... perform any action, for example notify a email message

  prometheusAggregator.incrementCounter({
    name: 'example_message_email_notification',
    description: 'Notification sent by email about example message',
  });

  // ... perform another action, for example notify by sms

  prometheusAggregator.incrementCounter({
    name: 'example_message_sms_notification',
    description: 'Notification sent by SMS about example message',
  });

  // ...

  // before leaving lambda, send metrics to Prometheus Aggregation Gateway

  await prometheusAggregator.pushMetrics();

  return {
    statusCode: 200,
    body: 'OK',
  };
};

Supported metrics are:

Type of MetricsOperations
Countersincrement
Gaugesincrement, decrement
Histogramsobservation, startTimer, stopTimer

Attention

  • await should only be used when the metrics are ready to be sent
  • The instance must be created within the handler so that no cache is maintained and duplicate metrics are not sent
1.4.0

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.1.1

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.0

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago