# promjs-export

> another export format for promjs

Latest version **0.1.1** (published 2019-08-31) · ISC license · 0 weekly downloads

## Install

```sh
npm install promjs-export
pnpm add promjs-export
yarn add promjs-export
bun add promjs-export
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2019-08-31 |
| First published | 2019-08-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 8.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | frezc |

## Links

- npm: https://www.npmjs.com/package/promjs-export
- npm.io page: https://npm.io/package/promjs-export

## Dependencies (2)

- [promjs](https://npm.io/package/promjs.md) ^0.4.0
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.3.4

## Recent versions

- 0.1.1 (latest) — 2019-08-31
- 0.1.0 — 2019-08-25

## README

This is a export function for [promjs](https://github.com/weaveworks/promjs)

# Intall
```shell
yarn add promjs-export
```

# Usage
```js
import { exportMetrics } from 'promjs-export';
import prom from 'promjs';

const registry = prom();
const pageRequestCounter = registry.create('counter', 'page_requests', 'A counter for page requests');
pageRequestCounter.inc();

expect(exportMetrics(registry)).toEqual([
    {
        name: 'page_requests',
        help: 'A counter for page requests',
        type: 'COUNTER',
        metrics: [
            {
                value: 1,
            }
        ]
    }
]);
```

# Data model
It's almost same as [prom2json](https://github.com/prometheus/prom2json)

```typescript
declare type Labels = Record<string, string>;
interface HistogramValue {
    labels?: Labels;
    buckets: Record<string, number>;
    count: number;
    sum: number;
}
interface CounterValue {
    labels?: Labels;
    value: number;
}
declare type MetricObject = {
    name: string;
    help: string;
} & ({
    type: 'GAUGE' | 'COUNTER';
    metrics: CounterValue[];
} | {
    type: 'HISTOGRAM';
    metrics: HistogramValue[];
});
/**
 *
 * @param registry registry.data is private, so we should break ts type check here
 */
export declare function exportMetrics(registry: any): MetricObject[];
```

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