# exposition

> Prometheus text-based exposition parse and stringify

Latest version **1.2.0** (published 2017-10-19) · MPL-2.0 license · 0 weekly downloads

## Install

```sh
npm install exposition
pnpm add exposition
yarn add exposition
bun add exposition
```

Provides the command `exposition`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2017-10-19 |
| First published | 2017-05-09 |
| Weekly downloads | 0 |
| License | MPL-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | wyatt |
| Maintainers | wyatt |
| Keywords | prometheus, parse, exposition, prom |

## Links

- npm: https://www.npmjs.com/package/exposition
- Repository: https://github.com/geek/exposition
- Homepage: https://github.com/geek/exposition#readme
- Issues: https://github.com/geek/exposition/issues
- npm.io page: https://npm.io/package/exposition

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.2.0 (latest) — 2017-10-19
- 1.1.0 — 2017-05-19
- 1.0.0 — 2017-05-10
- 0.0.0 — 2017-05-09

## README

# exposition
Prometheus text-based exposition parse and stringify

[![Build Status](https://secure.travis-ci.org/geek/exposition.svg)](http://travis-ci.org/geek/exposition)


## Usage

```javascript
const parsed = Exposition.parse(strProm);
```

## API

### `parse(str)`

Parse a Prometheus text-formatted exposition string and return as an object representation. For example, the following entry is parsed as the below object.


```
# HELP net_agg_packets_in Aggregate inbound packets
# TYPE net_agg_packets_in counter
net_agg_packets_in 153
```

```json
[
  {
    "name": "net_agg_packets_in",
    "type": "COUNTER",
    "help": "Aggregate inbound packets",
    "metrics": [
      {
        "value": "153"
      }
    ]
  }
]
```

Exposition will also parse more complex structures, for example:

```
# HELP http_request_duration_seconds A histogram of the request duration.
# TYPE http_request_duration_seconds histogram
http_request_duration_seconds_bucket{le="0.05"} 24054
http_request_duration_seconds_bucket{le="0.1"} 33444
http_request_duration_seconds_bucket{le="0.2"} 100392
http_request_duration_seconds_bucket{le="0.5"} 129389
http_request_duration_seconds_bucket{le="1"} 133988
http_request_duration_seconds_bucket{le="+Inf"} 144320
http_request_duration_seconds_sum 53423
http_request_duration_seconds_count 144320
```

is represented as

```json
[{
    "name": "http_request_duration_seconds",
    "metrics": [
       {
          "buckets": {
             "1": "133988",
             "0.05": "24054",
             "0.1": "33444",
             "0.2": "100392",
             "0.5": "129389",
             "+Inf": "144320"
          },
          "sum": "53423",
          "count": "144320"
       }
    ],
    "help": "A histogram of the request duration.",
    "type": "HISTOGRAM"
}]
```


### `stringify(array)`

Returns an exposition text-formatted representation of the array of objects.

Example:

```js
const Exposition = require('exposition');

const input = [{
  name: 'net_agg_packets_in',
  help: 'Aggregate inbound packets',
  type: 'COUNTER',
  metrics: [
    {
      value: '153'
    }
  ]
}];

console.log(Exposition.stringify(input));
```

result:
```
# HELP net_agg_packets_in Aggregate inbound packets
# TYPE net_agg_packets_in counter
net_agg_packets_in 153
```

---
_Source: https://npm.io/package/exposition · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
