Skip to content

Commit

Permalink
InfluxDB Line Protocol support (#26)
Browse files Browse the repository at this point in the history
* inital support for summary as influx line format

* add inlfux-line output option

* add influx-details option

* remove pretty.json

* influx fixes and docs

* fix usage and docs

* relative links

* fix spelling

* readme

* readme

* readme
  • Loading branch information
bojand authored Sep 8, 2018
1 parent 60ab9ba commit 6350d97
Show file tree
Hide file tree
Showing 10 changed files with 1,679 additions and 7 deletions.
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,21 @@

Simple [gRPC](http://grpc.io/) benchmarking and load testing tool inspired by [hey](https://github.com/rakyll/hey/) and [grpcurl](https://github.com/fullstorydev/grpcurl).

## Documentation

- [Intall](#install)
- [Usage](#usage)
- [Call Template Data](#call_template_data)
- [Examples](#examples)
- [Output](#output)
- [Extras](#extras)

<a name="install"></a>
## Install

Download a prebuilt executable binary from the [releases page](https://github.com/bojand/ghz/releases).

<a name="usage"></a>
## Usage

```
Expand Down Expand Up @@ -56,6 +67,8 @@ Options:
"json" outputs the metrics report in JSON format.
"pretty" outputs the metrics report in pretty JSON format.
"html" outputs the metrics report as HTML.
"influx-summary" outputs the metrics summary as influxdb line protocol.
"influx-details" outputs the metrics details as influxdb line protocol.
-i Comma separated list of proto import paths. The current working directory and the directory
of the protocol buffer file are automatically added to the import list.
Expand All @@ -70,6 +83,7 @@ Options:

Alternatively all settings can be set via `ghz.json` file if present in the same path as the `ghz` executable. A custom configuration file can be specified using `-config` option.

<a name="call_template_data"></a>
## Call Template Data

Data and metadata can specify [template actions](https://golang.org/pkg/text/template/) that will be parsed and evaluated at every request. Each request gets a new instance of the data. The available variables / actions are:
Expand All @@ -92,6 +106,7 @@ type callTemplateData struct {

This can be useful to inject variable information into the data or metadata payload for each request, such as timestamp or unique request number. See examples below.

<a name="examples"></a>
## Examples

A simple unary call:
Expand Down Expand Up @@ -166,8 +181,12 @@ Example `ghz.json`
}
```

<a name="output"></a>
## Output

<a name="output-summary"></a>
### Summary

Sample standard output of summary of the results:

```
Expand Down Expand Up @@ -204,6 +223,9 @@ Status code distribution:
[OK] 2000 responses
```

<a name="output-csv"></a>
### CSV

Alternatively with `-O csv` flag we can get detailed listing in csv format:

```sh
Expand All @@ -221,10 +243,54 @@ duration (ms),status,error
...
```

<a name="output-html"></a>
### HTML

HTML output can be generated using `html` as format in the `-O` option. See [sample output](http://bojand.github.io/sample.html).

<a name="output-json"></a>
### JSON

Using `-O json` outputs JSON data, and `-O pretty` outputs JSON in pretty format.

<a name="output-influx"></a>
### InfluxDB Line Protocol

Using `-O influx-summary` outputs the summary data as [InfluxDB Line Protocol](https://docs.influxdata.com/influxdb/v1.6/concepts/glossary/#line-protocol). Sample output:

```
ghz_run,proto="/testdata/greeter.proto",call="helloworld.Greeter.SayHello",host="0.0.0.0:50051",n=1000,c=50,qps=0,z=0,timeout=20,dial_timeout=10,keepalive=0,data="{\"name\":\"{{.InputName}}\"}",metadata="{\"rn\":\"{{.RequestNumber}}\"}",errors=74,has_errors=true count=1000,total=50000556,average=1771308,fastest=248603,slowest=7241944,rps=19999.78,median=1715940,p95=4354194,errors=74 128802790
```

Use `-O influx-summary` to get the individual details for each request:

```
ghz_detail,proto="/testdata/greeter.proto",call="helloworld.Greeter.SayHello",host="0.0.0.0:50051",n=1000,c=50,qps=0,z=0,timeout=20,dial_timeout=10,keepalive=0,data="{\"name\":\"{{.InputName}}\"}",metadata="{\"rn\":\"{{.RequestNumber}}\"}",hasError=false latency=5157328,error=,status=OK 681023506
ghz_detail,proto="/testdata/greeter.proto",call="helloworld.Greeter.SayHello",host="0.0.0.0:50051",n=1000,c=50,qps=0,z=0,timeout=20,dial_timeout=10,keepalive=0,data="{\"name\":\"{{.InputName}}\"}",metadata="{\"rn\":\"{{.RequestNumber}}\"}",hasError=false latency=4990499,error=,status=OK 681029613
```

## Extras

For conveniance we include prebuilt [Grafana](http://grafana.com/) dashboards for [summary](extras/influx-summary-grafana-dashboard.json) and [details](extras/influx-details-grafana-dashboard.json).

Summary Grafana Dashboard:

<div align="center">
<br>
<img src="extras/influx-summary-grafana-dashboard.png" alt="Summary Grafana Dashboard">
<br>
</div>


Details Grafana Dashboard:

<div align="center">
<br>
<img src="extras/influx-details-grafana-dashboard.png" alt="Details Grafana Dashboard">
<br>
</div>


## Credit

Icon made by <a href="http://www.freepik.com" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a>
Expand Down
9 changes: 9 additions & 0 deletions cmd/ghz/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ Options:
"json" outputs the metrics report in JSON format.
"pretty" outputs the metrics report in pretty JSON format.
"html" outputs the metrics report as HTML.
"influx-summary" outputs the metrics summary as influxdb line protocol.
"influx-details" outputs the metrics details as influxdb line protocol.
-i Comma separated list of proto import paths. The current working directory and the directory
of the protocol buffer file are automatically added to the import list.
Expand Down Expand Up @@ -195,7 +197,14 @@ func runTest(config *config.Config) (*ghz.Report, error) {
return nil, err
}

input := config.Proto
if config.Protoset != "" {
input = config.Protoset
}

opts := &ghz.Options{
Proto: input,
Call: config.Call,
Host: config.Host,
Cert: config.Cert,
CName: config.CName,
Expand Down
Loading

0 comments on commit 6350d97

Please sign in to comment.