# influx-gateway

> an influxdb gateway, takes json as input

Latest version **0.1.5** (published 2016-02-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install influx-gateway
pnpm add influx-gateway
yarn add influx-gateway
bun add influx-gateway
```

Provides the commands `igw`, `influx-gateway`.

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2016-02-24 |
| First published | 2015-09-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Tianxiang Chen |
| Maintainers | txchen |
| Keywords | influxdb, json, gateway |

## Links

- npm: https://www.npmjs.com/package/influx-gateway
- Repository: https://github.com/txchen/influx-gateway
- Homepage: https://github.com/txchen/influx-gateway#readme
- Issues: https://github.com/txchen/influx-gateway/issues
- npm.io page: https://npm.io/package/influx-gateway

## Dependencies (9)

- [awrap](https://npm.io/package/awrap.md) 0.0.1
- [babel](https://npm.io/package/babel.md) ^5.8.23
- [bunyan](https://npm.io/package/bunyan.md) ^1.5.1
- [extend](https://npm.io/package/extend.md) ^3.0.0
- [express](https://npm.io/package/express.md) ^4.13.3
- [commander](https://npm.io/package/commander.md) ^2.9.0
- [body-parser](https://npm.io/package/body-parser.md) ^1.14.1
- [request-promise](https://npm.io/package/request-promise.md) ^1.0.0
- [express-bunyan-logger](https://npm.io/package/express-bunyan-logger.md) ^1.1.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.1.5 (latest) — 2016-02-24
- 0.1.4 — 2016-02-23
- 0.1.3 — 2015-10-14
- 0.1.2 — 2015-10-12
- 0.1.1 — 2015-10-09
- 0.1.0 — 2015-10-09
- 0.0.3 — 2015-09-23
- 0.0.2 — 2015-09-23
- 0.0.1 — 2015-09-23

## README

# influx-gateway

[![Build Status](https://travis-ci.org/txchen/influx-gateway.svg)](https://travis-ci.org/txchen/influx-gateway)
[![NPM version](http://img.shields.io/npm/v/influx-gateway.svg?style=flat-square)](https://www.npmjs.com/package/influx-gateway)
[![Code Climate](https://codeclimate.com/github/txchen/influx-gateway/badges/gpa.svg)](https://codeclimate.com/github/txchen/eslint-plugin-riot)

InfluxDB had a json protocol but it will be deprecated, this service helps you to write json into influxDB.

## How to deploy

Firstly, install:

```bash
$ npm install influx-gateway -g
```

Then command `igw` or `influx-gateway` will be available.

Now we need a configuration file for influx-gateway, you can see the example by running:

```bash
$ igw genconfig
```

Create a config file, and then we can run the server:

```bash
$ igw -c [configfile]
```

## Configuration

Config is quite straight forward. The only tricky part is: if your influxdb requires authentication, you should include the username and password in the `influx_url`.

## Authentication

Influx-gateway does not provide authentication, you can put a proxy in front of igw. For example, an nginx instance with basic auth check enabled.

## API

* GET /ping

Ping will check the influxdb connectivity.

* POST /event

This API would transform json input into influx db's line protocol message. See [Here](https://influxdb.com/docs/v0.9/write_protocols/line.html) for more information about line-protocol.

Example payload:

```json
{
  "_name": "cpu",
  "__f1": 1,
  "tag1": "v1",
  "tag2": "v2"
}
```

`_name` must be specified as the measurement name, type must be string, regex: `/^[a-zA-Z0-9][\w-\.\/]*$/`

Field name starts with `__[a-zA-Z0-9]`, and remaining part use the same rule as measurement name.

Field value can be number, boolean or string.

Fields are optional, if no fields in the payload, igw will add `count=1i` automatically.

Tag name and tag value also should follow the measurement name regex.

Tags are also optional.

* POST /query

This API accepts influxdb query and returns json result. Query must start with `SELECT`.

Example payload:

```json
{
  "q": "SELECT value FROM cpu_load_short WHERE region='us-west'",
}
```

Example result:

```json
{
  "latency": 230,
  "series": [
    {
      "name": "cpu_load_short",
      "columns": [
        "time",
        "value"
      ],
      "values": [
        [
          "2015-01-29T21:55:43.702900257Z",
          0.55
        ],
        [
          "2015-01-29T21:55:43.702900257Z",
          23422
        ],
        [
          "2015-06-11T20:46:02Z",
          0.64
        ]
      ]
    }
  ]
}
```

## Changelog

**2016-02-24** `0.1.5`
Add query latency in response.

**2016-02-23** `0.1.4`
Add query api.

**2015-10-13** `0.1.3`
Upgrade dependencies.

**2015-10-11** `0.1.2`
1st working version.

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