<commit_before># Juttle Graphite Adapter

[![Build Status](https://travis-ci.org/juttle/juttle-graphite-adapter.svg?branch=master)](https://travis-ci.org/juttle/juttle-graphite-adapter)

Graphite adapter for the [Juttle data flow
language](https://github.com/juttle/juttle), with read & write support.

## Examples

Reading existing metrics is as simple as:

```juttle
read graphite name ~ 'app1.*.response_ms' -from :1 week ago:
| reduce value = avg(value) by name
```

This will compute last week's average of every metric matching `app1.*.response_ms`.

If you encoded something like the region or hostname into the metric name then
you can easily parse that name in juttle. Let's say your metric name looks
like `region.host.metric_name`. Then you can calculate the average value of the
response time per host every 1 minute for the last 24 hours like so:

```juttle
read graphite name ~ '*.response_ms' -from :24 hours ago:
| put host = String.split(name, '.')[1]
| reduce -every :1 minute: value = avg(value) by host
```

## Installation

Like Juttle itself, the adapter is installed as a npm package. Both Juttle and
the adapter need to be installed side-by-side:

```bash
$ npm install juttle
$ npm install juttle-graphite-adapter
```

## Configuration

The adapter needs to be registered and configured so that it can be used from
within Juttle. To do so, add the following to your `~/.juttle/config.json` file:

```json
{
    "adapters": {
        "juttle-graphite-adapter": {
            "carbon": {
                "host": "localhost",
                "port": 2003
            },
            "webapp": {
                "host": "localhost",
                "port": 8080,
                "username": "...",
                "password": "..."
            }
        }
    }
}
```

Keys in `carbon` specify the location of Graphite storage backend, keys in
`webapp` contain configuration for the Graphite frontend.

## Usage

### Data Model

Graphite stores metrics with:

- `name` - alphanumeric sequence defining a path to your metric that you should
consider naming appropriately. See [graphite documentation](http://graphite.wikidot.com/getting-your-data-into-graphite)
for more details.<commit_msg>Update README to reflect juttle-config change.<commit_after># Juttle Graphite Adapter

[![Build Status](https://travis-ci.org/juttle/juttle-graphite-adapter.svg?branch=master)](https://travis-ci.org/juttle/juttle-graphite-adapter)

Graphite adapter for the [Juttle data flow
language](https://github.com/juttle/juttle), with read & write support.

## Examples

Reading existing metrics is as simple as:

```juttle
read graphite name ~ 'app1.*.response_ms' -from :1 week ago:
| reduce value = avg(value) by name
```

This will compute last week's average of every metric matching `app1.*.response_ms`.

If you encoded something like the region or hostname into the metric name then
you can easily parse that name in juttle. Let's say your metric name looks
like `region.host.metric_name`. Then you can calculate the average value of the
response time per host every 1 minute for the last 24 hours like so:

```juttle
read graphite name ~ '*.response_ms' -from :24 hours ago:
| put host = String.split(name, '.')[1]
| reduce -every :1 minute: value = avg(value) by host
```

## Installation

Like Juttle itself, the adapter is installed as a npm package. Both Juttle and
the adapter need to be installed side-by-side:

```bash
$ npm install juttle
$ npm install juttle-graphite-adapter
```

## Configuration

The adapter needs to be registered and configured so that it can be used from
within Juttle. To do so, add the following to your `~/.juttle/config.json` file:

```json
{
    "adapters": {
        "graphite": {
            "carbon": {
                "host": "localhost",
                "port": 2003
            },
            "webapp": {
                "host": "localhost",
                "port": 8080,
                "username": "...",
                "password": "..."
            }
        }
    }
}
```

Keys in `carbon` specify the location of Graphite storage backend, keys in
`webapp` contain configuration for the Graphite frontend.

## Usage

### Data Model

Graphite stores metrics with:

- `name` - alphanumeric sequence defining a path to your metric that you should
consider naming appropriately. See [graphite documentation](http://graphite.wikidot.com/getting-your-data-into-graphite)
for more details.
{'fraction_non_alphanumeric': 0.1099594411897251, 'fraction_numerical': 0.00811176205497972, 'mean_word_length': 3.133147113594041, 'pattern_counts': {'":': 20, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1581606', 'n_tokens_mistral': 1370, 'n_tokens_neox': 1251, 'n_words': 492}