Skip to content

Commit

Permalink
Experimental Prometheus remote-write Output
Browse files Browse the repository at this point in the history
  • Loading branch information
codebien committed Dec 6, 2022
1 parent a403c90 commit a2ab89a
Show file tree
Hide file tree
Showing 254 changed files with 37,205 additions and 1,859 deletions.
18 changes: 18 additions & 0 deletions cmd/integration_test.go
Expand Up @@ -1488,3 +1488,21 @@ func TestRunTags(t *testing.T) {
expTags["check"] = "status is 101"
assert.Equal(t, float64(3), sum(getSampleValues(t, jsonResults, "checks", expTags)))
}

func TestPrometheusRemoteWriteOutput(t *testing.T) {
t.Parallel()

ts := newGlobalTestState(t)
ts.args = []string{"k6", "run", "--out", "experimental-prometheus-rw", "-"}
ts.stdIn = bytes.NewBufferString(`
import exec from 'k6/execution';
export default function () {};
`)

newRootCommand(ts.globalState).execute()
ts.outMutex.Lock()
stdOut := ts.stdOut.String()
ts.outMutex.Unlock()

assert.Contains(t, stdOut, "output: Prometheus remote write")
}
5 changes: 5 additions & 0 deletions cmd/outputs.go
Expand Up @@ -13,6 +13,8 @@ import (
"go.k6.io/k6/output/influxdb"
"go.k6.io/k6/output/json"
"go.k6.io/k6/output/statsd"

"github.com/grafana/xk6-output-prometheus-remote/pkg/remotewrite"
)

// TODO: move this to an output sub-module after we get rid of the old collectors?
Expand All @@ -32,6 +34,9 @@ func getAllOutputConstructors() (map[string]func(output.Params) (output.Output,
"please use the statsd output with env. variable K6_STATSD_ENABLE_TAGS=true instead")
},
"csv": csv.New,
"experimental-prometheus-rw": func(params output.Params) (output.Output, error) {
return remotewrite.New(params)
},
}

exts := output.GetExtensions()
Expand Down
16 changes: 13 additions & 3 deletions go.mod
Expand Up @@ -12,6 +12,7 @@ require (
github.com/fatih/color v1.13.0
github.com/golang/protobuf v1.5.2
github.com/gorilla/websocket v1.5.0
github.com/grafana/xk6-output-prometheus-remote v0.0.8
github.com/grafana/xk6-redis v0.1.1
github.com/grafana/xk6-timers v0.1.2
github.com/grafana/xk6-websockets v0.1.6
Expand All @@ -23,6 +24,7 @@ require (
github.com/mattn/go-isatty v0.0.16
github.com/mccutchen/go-httpbin v1.1.2-0.20190116014521-c5cb2f4802fa
github.com/mstoykov/atlas v0.0.0-20220808085829-90340e9998bd
github.com/mstoykov/envconfig v1.4.1-0.20220114105314-765c6d8c76f1
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c
github.com/pmezard/go-difflib v1.0.0
Expand All @@ -39,26 +41,34 @@ require (
golang.org/x/term v0.0.0-20220919170432-7a66f970e087
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af
google.golang.org/grpc v1.49.0
google.golang.org/protobuf v1.27.1
google.golang.org/protobuf v1.28.1
gopkg.in/guregu/null.v3 v3.3.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/andybalholm/cascadia v1.3.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/dlclark/regexp2 v1.7.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/go-redis/redis/v8 v8.11.5 // indirect
github.com/go-sourcemap/sourcemap v2.1.4-0.20211119122758-180fcef48034+incompatible
github.com/golang/snappy v0.0.4 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/mstoykov/envconfig v1.4.1-0.20220114105314-765c6d8c76f1
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mstoykov/k6-taskqueue-lib v0.1.0 // indirect
github.com/prometheus/client_golang v1.14.1-0.20221122130035-8b6e68085b10 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
go.buf.build/grpc/go/gogo/protobuf v1.4.9 // indirect
go.buf.build/grpc/go/prometheus/prometheus v1.4.4 // indirect
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08 // indirect
google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21 // indirect
)
364 changes: 360 additions & 4 deletions go.sum

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions vendor/github.com/beorn7/perks/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a2ab89a

Please sign in to comment.