satellite: use evenkit instead of evenstat/top endpoint

We had multiple experiment so far to collect high cardinality data (mainly in aggregated form).

 1. we have a `/top` endpoint which aggregates events with upper bound
 2. we use same api (eventstat) to publish S3 gateway-mt agents to influxdb

This patch starts to replace theses api with jtolio/eventkit. Instead of aggregation all events can be sent to a collector host where we can do aggregation and/or persisting data.

Change-Id: Id6df4882b51d2dbd2be9401ee4199d14f3ff7186
This commit is contained in:
Márton Elek 2022-10-24 11:43:47 +02:00
parent a2ca443e29
commit 11df98a392
No known key found for this signature in database
GPG Key ID: D51EA8F00EE79B28
3 changed files with 10 additions and 24 deletions

View File

@ -12,14 +12,12 @@ import (
"go.uber.org/zap"
"storj.io/common/encryption"
"storj.io/common/eventstat"
"storj.io/common/lrucache"
"storj.io/common/macaroon"
"storj.io/common/pb"
"storj.io/common/rpc/rpcstatus"
"storj.io/common/signing"
"storj.io/common/storj"
"storj.io/private/debug"
"storj.io/storj/satellite/accounting"
"storj.io/storj/satellite/attribution"
"storj.io/storj/satellite/buckets"
@ -80,15 +78,6 @@ type Endpoint struct {
defaultRS *pb.RedundancyScheme
config Config
versionCollector *versionCollector
top endpointTop
}
// endpointTop represents in-memory counter stats.
// Cached info can be retrieved from the /mon monitoring endpoint.
type endpointTop struct {
Project eventstat.Sink
Partner eventstat.Sink
UserAgent eventstat.Sink
}
// NewEndpoint creates new metainfo endpoint instance.
@ -139,11 +128,6 @@ func NewEndpoint(log *zap.Logger, buckets *buckets.Service, metabaseDB *metabase
defaultRS: defaultRSScheme,
config: config,
versionCollector: newVersionCollector(log),
top: endpointTop{
Project: debug.Top.NewTagCounter("auth_request_project", "project"),
Partner: debug.Top.NewTagCounter("auth_request_partner", "partner"),
UserAgent: debug.Top.NewTagCounter("auth_request_user_agent", "agent"),
},
}, nil
}

View File

@ -11,6 +11,7 @@ import (
"strconv"
"time"
"github.com/jtolio/eventkit"
"github.com/zeebo/errs"
"go.uber.org/zap"
"golang.org/x/time/rate"
@ -35,6 +36,8 @@ var (
ipRegexp = regexp.MustCompile(`^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$`)
)
var ek = eventkit.Package()
func getAPIKey(ctx context.Context, header *pb.RequestHeader) (key *macaroon.APIKey, err error) {
defer mon.Task()(&ctx)(&err)
if header != nil {
@ -128,11 +131,15 @@ func (endpoint *Endpoint) validateBasic(ctx context.Context, header *pb.RequestH
return nil, nil, rpcstatus.Error(rpcstatus.PermissionDenied, "Unauthorized API credentials")
}
endpoint.top.Project(keyInfo.ProjectID.String())
endpoint.top.Partner(keyInfo.PartnerID.String())
userAgent := ""
if keyInfo.UserAgent != nil {
endpoint.top.UserAgent(string(keyInfo.UserAgent))
userAgent = string(keyInfo.UserAgent)
}
ek.Event("auth",
eventkit.String("user-agent", userAgent),
eventkit.String("project", keyInfo.ProjectID.String()),
eventkit.String("partner", keyInfo.PartnerID.String()),
)
if err = endpoint.checkRate(ctx, keyInfo.ProjectID); err != nil {
endpoint.log.Debug("rate check failed", zap.Error(err))

View File

@ -48,11 +48,6 @@ func TestEndpoint_validateAuthN(t *testing.T) {
endpoint := Endpoint{
log: zaptest.NewLogger(t),
apiKeys: &mockAPIKeys{secret: secret},
top: endpointTop{
Project: func(name string) {},
Partner: func(name string) {},
UserAgent: func(name string) {},
},
}
now := time.Now()