Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analytics Dashboard #72

Open
wants to merge 104 commits into
base: master
Choose a base branch
from
Open

Analytics Dashboard #72

wants to merge 104 commits into from

Conversation

jordanschalm
Copy link
Collaborator

@jordanschalm jordanschalm commented Feb 23, 2017

Todo:
[x] Update main README with info about analytics
[x] Update sample config with dashboard config
[x] Add mitigation for HELO spamming

jordanschalm and others added 30 commits January 2, 2017 20:09
- Hasher decorator
- MySQL decorator

also fixes a bug with header parsing

Todo:
redis decorator, cleanup / remove legacy code, finalise interfaces
- Compressor decorator
- Header decorator
- Redis decorator

Other:
Moved events to its own package so that they can be used by backend without getting into circular dep.
Guerrilla embeds events directly instead of wrapping the function

Todo:
, cleanup / remove legacy code, finalise interfaces, change processor initialize to use events. Use a channel for backend errors.
- processor lines can configured via config and built during initialization
- backend gateway manages creating of processor lines and starting / stopping workers that use these lines
- TODO: lots of cleanup, change to allow multiple rcpt to, more comments, test backend shutdown/restart on config reload
- add comments at the start of all processors
- Remove initializers / shutdowners once backend is shutdown
- redis processor: propagate close error
- mysql processor: propaget close error
- add more comments
- Added in type support to Backend's extractConfig func
- saveStatus contains queued instead of hash, better semantically
- BackendGateway default config if processor_line not present, or save_workers_size not present
- added queued id to envelope, a temporary default id is generated too
…reation

- Made some symbols public, ie. Service.ExtractConfig, BaseConfig
- Envelope: added a NewRreader() function that returns a reader for the processed email
- Moved resetting the envelope from client.go to envelope itself.
- Added a Reseed() function that seeds the envelope with data at the start of a connection
# Conflicts:
#	.gitignore
#	.travis.yml
#	README.md
#	api.go
#	api_test.go
#	backends/backend.go
#	backends/gateway.go
#	backends/gateway_test.go
#	backends/p_mysql.go
#	backends/p_redis.go
#	backends/processor.go
#	backends/validate.go
#	client.go
#	cmd/guerrillad/serve.go
#	cmd/guerrillad/serve_test.go
#	config.go
#	config_test.go
#	event.go
#	glide.lock
#	goguerrilla.conf.sample
#	guerrilla.go
#	log/log.go
#	mail/envelope.go
#	mail/envelope_test.go
#	server.go
#	tests/guerrilla_test.go
- Start blocks until Stop() is called (using a non-blocking version of ListenAndServe)
@flashmob
Copy link
Owner

@jordanschalm

Made the following changes:

  • Added a Stop() function, this required adding channels for stopping and using a non-blocking version of ListenAndServe that returned a Closer (see http.go). Could you validate that all that needs to be stopped is being stopped?

Also, started writing tests. It would be good if we could add more tests for this.

Now trying to figure out this problem, when pointing the browser to http:


INFO[0020] Logging analytics data                        clients=0 ram=3010784
2017/03/23 00:32:13 http: panic serving 10.0.2.2:34084: runtime error: invalid memory address or nil pointer dereference
goroutine 7 [running]:
net/http.(*conn).serve.func1(0xc4200aa460)
	/usr/local/go/src/net/http/server.go:1721 +0xd0
panic(0x873f60, 0xd0cc80)
	/usr/local/go/src/runtime/panic.go:489 +0x2cf
net/http.serveFile(0xd21ce0, 0xc42021c1c0, 0xc42009e900, 0x0, 0x0, 0xc42023e0d4, 0x1, 0xc42023e101)
	/usr/local/go/src/net/http/fs.go:525 +0x8b
net/http.(*fileHandler).ServeHTTP(0xc420337820, 0xd21ce0, 0xc42021c1c0, 0xc42009e900)
	/usr/local/go/src/net/http/fs.go:689 +0xb4
github.com/flashmob/go-guerrilla/vendor/github.com/gorilla/mux.(*Router).ServeHTTP(0xc420339680, 0xd21ce0, 0xc42021c1c0, 0xc42009e900)
	/home/flashmob/projects/golang/src/github.com/flashmob/go-guerrilla/vendor/github.com/gorilla/mux/mux.go:114 +0x10c
net/http.serverHandler.ServeHTTP(0xc420334790, 0xd21ce0, 0xc42021c1c0, 0xc42009e600)
	/usr/local/go/src/net/http/server.go:2568 +0x92
net/http.(*conn).serve(0xc4200aa460, 0xd224e0, 0xc42006a200)
	/usr/local/go/src/net/http/server.go:1825 +0x612
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:2668 +0x2ce

it was doing this before the changes..

My dashboard config:

"dashboard": {
    "is_enabled": true,
    "listen_interface": ":8081",
    "tick_interval": "5s",
    "max_window": "24h",
    "ranking_aggregation_interval": "6h"
  }

The 8081 port is forwarded via ssh

@jordanschalm
Copy link
Collaborator Author

That might be because the statik package doesn't contain the correct JS/HTML files? I haven't encountered that before. Have you run the build.sh file in the root?

@flashmob
Copy link
Owner

thanks; didn't do that - will try that soon!

@flashmob
Copy link
Owner

It seems like the statik package is missing from the repo. Could you pls commit when you get a chance? Thanks.

@jordanschalm
Copy link
Collaborator Author

jordanschalm commented Mar 23, 2017

@flashmob So I deliberately didn't include the statik package because it's a build artifact, and it's pretty big (~7MB). If it's committed each time a change is made to the dashboard, that'll increase the repo size pretty quickly, but it's an option.

In order to use the dashboard you need to:

  • install dependencies npm install
  • build front-end into HTTP-serveable bundle file npm run build
  • make statik package

This is a somewhat long process so it certainly shouldn't be part of building guerrillad, since that is very fast right now. However, it does have to happen at least once after the package is installed, assuming the statik package is not committed.

Another option would be to add a one-time build step to the Makefile called dashboard (actually already there, but doesn't quite work due to me not knowing Make very well, that's why I added the build.sh script instead) that builds everything required for the dashboard. This has the benefit of not needing to commit build artifacts, but adds a step to the installation process.

Installation process would then be like:

git clone <url>
make dependencies
make dashboard
make guerrillad

flashmob and others added 11 commits March 24, 2017 01:30
inject dashboard hook to logger form the guerrilla package
Lock ranking buffers while aggregating
…backend

Fix concurrent read/write of ranking buffers in dashboard
Remove some console logs from js util
fix a typo in backend
- point log to use log from go-guerrilla/log package so the logger can be injected
- dashboard coverage increased to > 80%
@ghost
Copy link

ghost commented Jul 19, 2018

Is this ready to be committed to Master ? Dashboard is useful for me.

@flashmob
Copy link
Owner

flashmob commented Feb 1, 2019

This branch (dashboard) has been updated with the latest master.

If you require the dashboard, you may git checkout this branch and build according to this doc https://github.com/flashmob/go-guerrilla/wiki/Dashboard

@flashmob
Copy link
Owner

flashmob commented Feb 1, 2019

Todo in the future:

  • Break up this branch by putting the front-end in a separate repo (and parts of the backend that services the front-end). Throw away the logrus hook, as we won't need it anymore.
  • Merge the other half of this branch to master. This means merging all the event logging code to master.
  • In the separate repo, implement scanning of the log file and processing the events, incorporating the existing code.
  • Add more types of events to the log (garbage collector, amount of data transferred, etc..) to be enabled via config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants