Skip to content

Commit

Permalink
chore: update prometheus exporter readme with usage and links (#521)
Browse files Browse the repository at this point in the history
* chore: update prometheus exporter readme with example and links

* fix: minor change
  • Loading branch information
mayurkale22 authored Nov 14, 2019
1 parent 6f56c37 commit 631d9e4
Showing 1 changed file with 51 additions and 2 deletions.
53 changes: 51 additions & 2 deletions packages/opentelemetry-exporter-prometheus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,58 @@
[![devDependencies][devDependencies-image]][devDependencies-url]
[![Apache License][license-image]][license-image]

OpenTelemetry Exporter Prometheus provides a metrics endpoint for Prometheus.
The OpenTelemetry Prometheus Metrics Exporter allows the user to send collected [OpenTelemetry Metrics](https:/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-metrics) to Prometheus.

**Work in progress**
[Prometheus](https://prometheus.io/) is a monitoring system that collects metrics, by scraping exposed endpoints at regular intervals, evaluating rule expressions. It can also trigger alerts if certain conditions are met. For assistance setting up Prometheus, [Click here](https://opencensus.io/codelabs/prometheus/#0) for a guided codelab.

## Installation

```bash
npm install --save @opentelemetry/metrics
npm install --save @opentelemetry/exporter-prometheus
```

## Usage

Create & register the exporter on your application.

```js
const { PrometheusExporter } = require('@opentelemetry/exporter-prometheus');
const { Meter } = require('@opentelemetry/metrics');

// Add your port and startServer to the Prometheus options
const options = {port: 9464, startServer: true};
const exporter = new PrometheusExporter(options);

// Register the exporter
const meter = new Meter();
meter.addExporter(exporter);

// Now, start recording data
const counter = meter.createCounter('metric_name');
counter.add(10, meter.labels({ [key]: 'value' }));

// Record data using Handle: It is recommended to keep a reference to the Handle instead of
// always calling `getHandle()` method for every operations.
const handle = counter.getHandle(meter.labels({ [key]: 'value' }));
handle.add(10);

// .. some other work

// Create and record Gauge
const gauge = meter.createGauge('metric_name1');
gauge.set(10, meter.labels({ [key1]: 'value1' }));
```

## Viewing your metrics

With the above you should now be able to navigate to the Prometheus UI at: http://localhost:9464/metrics

## Useful links
- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
- To learn more about Prometheus, visit: https://prometheus.io/
- For more about OpenTelemetry JavaScript: <https:/open-telemetry/opentelemetry-js>
- For help or feedback on this project, join us on [gitter][gitter-url]

## License

Expand Down

0 comments on commit 631d9e4

Please sign in to comment.