Skip to content

Commit

Permalink
chore: update prometheus exporter readme with example and links
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurkale22 committed Nov 11, 2019
1 parent 460d986 commit 7182cff
Showing 1 changed file with 50 additions and 2 deletions.
52 changes: 50 additions & 2 deletions packages/opentelemetry-exporter-prometheus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,57 @@
[![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 metrics with [OpenTelemetry Metrics](https://github.com/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

handle.add(50);
```


## 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://github.com/open-telemetry/opentelemetry-js>
- For help or feedback on this project, join us on [gitter][gitter-url]

## License

Expand Down

0 comments on commit 7182cff

Please sign in to comment.