ghz
ghz copied to clipboard
Can't figure out how to use ghz-web
Heya. Having been unblocked by the fix to #55 (thanks again), I've tried to use the web frontend. I seem to be having issues with the binary -- could you have a look, please? 😃
Proto file(s)
NA
Command line arguments / config
web.toml
is
protoset="gateway.protoset"
cert="/hab/svc/gateway/config/service.crt"
key="/hab/svc/gateway/config/service.key"
cacert="/hab/svc/gateway/config/root_ca.crt"
cname="gateway"
call="gateway.api.users.UsersMgmt/GetUsers"
[m]
"api-token"="bASZ1UdqkTjEqK3V-h1npK5tyfs="
host="10.0.2.15:2001"
CLI call is ./ghc-web -config web.toml
Expected Behavior
It starts.
Actual Behavior
# ./ghz-web -config web.toml
panic: Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work. This is a stub
goroutine 1 [running]:
main.main()
/Users/bdjurkovic/dev/golang/ghz/cmd/ghz-web/main.go:60 +0x4c5
#
Steps to Reproduce (including precondition)
Get 0.26.0, run it with the config above.
Your Environment
- OS: osx
- ghz version: 0.26.0
Hello, ghz-web is a completely separate complimentary application for storing, viewing and comparing the results of test runs over time. It would have separate config not related to your ghz
runs. It seems I am compiling it incorrectly so sqlite3 support may not work atm, I'll work on fixing this; and also improving the documentation. But it should work with postgres or mysql. So to get started, for example run postgres and create a database called ghz
.
Create a web.yml
wherever ghz-web
is:
---
server:
port: 3000
database:
type: postgres
connection: host=localhost port=5432 dbname=ghz sslmode=disable
log:
level: debug
Run it using
ghz-web -config web.yml
Go to http://localhost:3000/ and you should see a UI. Create a project. Take note of the ID.
The idea is that then you can perform ghz
tests over time and use curl or HTTPie to send the JSON results to the server to save then for tracking and viewing. The web server has a special ingest
API for performing this:
ghz -insecure \
-proto ./greeter.proto \
-call helloworld.Greeter.SayHello \
-d '{"name": "Bob"}' \
-tags '{"env": "staging", "created by":"Joe Developer"}' \
-name 'Greeter SayHello' \
-O json \
0.0.0.0:50051 | http POST localhost:3000/api/projects/1/ingest
Basically do a ghz
call, make sure to use -O json
to create a JSON report, then pipe the output to http
(or curl) to send to the web server's ingest API endpoint under project with ID 1
(substitute the project id here if needed).
Note that ghz
itself can output to HTML (sample), which may be useful if you do not absolutely need all the functionality of ghz-web and do not want the additional operational implications of running a server.
Hope this helps.
ghz-web
tool is Beta and still a bit of a WIP heh. I'll work to fix the compile issue above and improve the documentation.
I think there's something wrong with the sqlite3 compilation as well. I'm getting the same error when trying to start the server on OSX 10.13.6 using the 0.26.0 Darwin build. Looking forward to trying this out!
Hello, can you please try v0.27.0 and see if that works for you.
Thanks for the quick fix! I was able to get past starting the web server with the new build. However when using the generic write endpoint (POST /api/projects/:id/ingest) I get the following error:
HTTP/1.1 404 Not Found
Access-Control-Allow-Origin: *
Content-Length: 64
Content-Type: application/json; charset=UTF-8
Date: Fri, 25 Jan 2019 19:56:33 GMT
Vary: Origin
X-Request-Id: vCYTodNuAGEWR8HMrHiFt30HXFrJ7ZMu
{
"message": "strconv.ParseUint: parsing \":id\": invalid syntax"
}
Server log:
{"time":"2019-01-25T11:55:26.499443-08:00","id":"iWu3JXDEHsnyxsEEP6hv70MYBBBA0SYp","remote_ip":"::1","host":"localhost:3333","method":"POST","uri":"/api/projects/:id/ingest/","status":404, "latency":198452,"latency_human":"198.452µs","bytes_in":19042,"bytes_out":64}
My command:
ghz -config ./telemetry-test.json | http POST localhost:3333/api/projects/:id/ingest
Post works against a known project id.
The idea is that normally you would create a project and then use that ID to ingest multiple runs for that project and track them over time. So use the UI to create a project for a specific call for example, and then use that project ID for all tests of that call. Alternatively there is an /api/ingest
endpoint that will automatically create the project and ingest the result. But normally you would want to create the project yourself, as it does not really make sense to constantly create project + a result every time. It defeats the purpose of grouping runs together so they can be traced over time and compared.
can i ask question too about ghz web? so. i have web.yml
server:
port: 3306
database:
type: mysql
connection: root:fdsafasfasdfa@/ghz
log:
level: info
path: /tmp/ghz.log
i start command ghz-web -config web.yml
than i go to http://localhost:3306/
command completes succefully
and see this:
than i start command
ghz -config .\FSI.json POST localhost:3306/api/projects/1/ingest
this config have "O": "json"
it completes and i see json result in stdout, so all good.
and still no changes on http://localhost:3306/
Heya! What a surprise to stumble upon my own issue here 😅
It's been a while, and I've had a chance to look into gRPC performance once more. Using ghz via the Golang interface is really nice, and I've been trying to inject the JSON report via the API:
$ ghz --insecure -Ojson --call LoadService.PushDataStruct -d '{"path":"/foo", "data": {"bar": 2}}' 127.0.0.1:8
080 > cli-rep.json
$ curl -XPOST 127.0.0.1:80/api/ingest -d @cli-rep.json
{"project":{"id":4,"createdAt":"2022-12-09T14:14:06.239526+01:00","updatedAt":"2022-12-09T14:14:06.239526+01:00","name":"young-
catfish-46","description":"","status":"ok"},"report":{"id":9,"createdAt":"2022-12-09T14:14:06.240694+01:00","updatedAt":"2022-1
2-09T14:14:06.240694+01:00","projectID":4,"endReason":"normal","date":"0001-01-01T00:00:00Z","count":0,"total":0,"average":0,"f
astest":0,"slowest":0,"rps":0,"status":"ok","latencyDistribution":[]},"options":{"id":9,"createdAt":"2022-12-09T14:14:06.241357
+01:00","updatedAt":"2022-12-09T14:14:06.241357+01:00","reportID":9,"info":{"insecure":false,"load-schedule":"","load-start":0,
"load-end":0,"load-step":0,"load-step-duration":0,"load-max-duration":0,"concurrency-schedule":"","concurrency-start":0,"concur
rency-end":0,"concurrency-step":0,"concurrency-step-duration":0,"concurrency-max-duration":0,"binary":false,"CPUs":0}},"histogr
am":{"id":9,"createdAt":"2022-12-09T14:14:06.241929+01:00","updatedAt":"2022-12-09T14:14:06.241929+01:00","reportID":9,"buckets
":[]},"details":{"success":0,"fail":0}}
AFAICT that looks OK, however, on the ghz-web interface, it doesn't look OK:

Clicking on the report, I get a blank page, and this console log:

I've tried both firefox and chrome. I've built ghz-web
using go build ./cmd/ghz-web
in a repo checkout because the binary from the Darwin release bundle wasn't recognized as an executable on my system.
Would you happen to know what I did wrong?