metrics: Add metrics to unauthenticated endpoints (#15899)
This commit is contained in:
parent
5e75ea9fb3
commit
bed8716e44
|
@ -21,6 +21,11 @@ func NewRegionEndpoint(srv *Server, ctx *RPCContext) *Region {
|
||||||
// required for this endpoint because memberlist is used to populate the
|
// required for this endpoint because memberlist is used to populate the
|
||||||
// peers list we read from.
|
// peers list we read from.
|
||||||
func (r *Region) List(args *structs.GenericRequest, reply *[]string) error {
|
func (r *Region) List(args *structs.GenericRequest, reply *[]string) error {
|
||||||
|
// note: we're intentionally throwing away any auth error here and only
|
||||||
|
// authenticate so that we can measure rate metrics
|
||||||
|
r.srv.Authenticate(r.ctx, args)
|
||||||
|
r.srv.MeasureRPCRate("region", structs.RateMetricList, args)
|
||||||
|
|
||||||
*reply = r.srv.Regions()
|
*reply = r.srv.Regions()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ func NewStatsFetcher(logger log.Logger, pool *pool.ConnPool, region string) *Sta
|
||||||
// RPC to each server, so we let it finish and then clean up the in-flight
|
// RPC to each server, so we let it finish and then clean up the in-flight
|
||||||
// tracking.
|
// tracking.
|
||||||
func (f *StatsFetcher) fetch(server *autopilot.Server, replyCh chan *autopilot.ServerStats) {
|
func (f *StatsFetcher) fetch(server *autopilot.Server, replyCh chan *autopilot.ServerStats) {
|
||||||
var args struct{}
|
var args structs.GenericRequest
|
||||||
var reply structs.RaftStats
|
var reply structs.RaftStats
|
||||||
|
|
||||||
// defer some cleanup to notify everything else that the fetching is no longer occurring
|
// defer some cleanup to notify everything else that the fetching is no longer occurring
|
||||||
|
|
|
@ -26,11 +26,17 @@ func (s *Status) Ping(args structs.GenericRequest, reply *struct{}) error {
|
||||||
// note: we're intentionally throwing away any auth error here and only
|
// note: we're intentionally throwing away any auth error here and only
|
||||||
// authenticate so that we can measure rate metrics
|
// authenticate so that we can measure rate metrics
|
||||||
s.srv.Authenticate(s.ctx, &args)
|
s.srv.Authenticate(s.ctx, &args)
|
||||||
|
s.srv.MeasureRPCRate("status", structs.RateMetricRead, &args)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Leader is used to get the address of the leader
|
// Leader is used to get the address of the leader
|
||||||
func (s *Status) Leader(args *structs.GenericRequest, reply *string) error {
|
func (s *Status) Leader(args *structs.GenericRequest, reply *string) error {
|
||||||
|
// note: we're intentionally throwing away any auth error here and only
|
||||||
|
// authenticate so that we can measure rate metrics
|
||||||
|
s.srv.Authenticate(s.ctx, args)
|
||||||
|
s.srv.MeasureRPCRate("status", structs.RateMetricRead, args)
|
||||||
|
|
||||||
if args.Region == "" {
|
if args.Region == "" {
|
||||||
args.Region = s.srv.config.Region
|
args.Region = s.srv.config.Region
|
||||||
}
|
}
|
||||||
|
@ -49,6 +55,11 @@ func (s *Status) Leader(args *structs.GenericRequest, reply *string) error {
|
||||||
|
|
||||||
// Peers is used to get all the Raft peers
|
// Peers is used to get all the Raft peers
|
||||||
func (s *Status) Peers(args *structs.GenericRequest, reply *[]string) error {
|
func (s *Status) Peers(args *structs.GenericRequest, reply *[]string) error {
|
||||||
|
// note: we're intentionally throwing away any auth error here and only
|
||||||
|
// authenticate so that we can measure rate metrics
|
||||||
|
s.srv.Authenticate(s.ctx, args)
|
||||||
|
s.srv.MeasureRPCRate("status", structs.RateMetricList, args)
|
||||||
|
|
||||||
if args.Region == "" {
|
if args.Region == "" {
|
||||||
args.Region = s.srv.config.Region
|
args.Region = s.srv.config.Region
|
||||||
}
|
}
|
||||||
|
@ -71,7 +82,7 @@ func (s *Status) Peers(args *structs.GenericRequest, reply *[]string) error {
|
||||||
// aware of
|
// aware of
|
||||||
func (s *Status) Members(args *structs.GenericRequest, reply *structs.ServerMembersResponse) error {
|
func (s *Status) Members(args *structs.GenericRequest, reply *structs.ServerMembersResponse) error {
|
||||||
authErr := s.srv.Authenticate(s.ctx, args)
|
authErr := s.srv.Authenticate(s.ctx, args)
|
||||||
s.srv.MeasureRPCRate("status", structs.RateMetricRead, args)
|
s.srv.MeasureRPCRate("status", structs.RateMetricList, args)
|
||||||
if authErr != nil {
|
if authErr != nil {
|
||||||
return structs.ErrPermissionDenied
|
return structs.ErrPermissionDenied
|
||||||
}
|
}
|
||||||
|
@ -109,7 +120,12 @@ func (s *Status) Members(args *structs.GenericRequest, reply *structs.ServerMemb
|
||||||
}
|
}
|
||||||
|
|
||||||
// RaftStats is used by Autopilot to query the raft stats of the local server.
|
// RaftStats is used by Autopilot to query the raft stats of the local server.
|
||||||
func (s *Status) RaftStats(args struct{}, reply *structs.RaftStats) error {
|
func (s *Status) RaftStats(args *structs.GenericRequest, reply *structs.RaftStats) error {
|
||||||
|
// note: we're intentionally throwing away any auth error here and only
|
||||||
|
// authenticate so that we can measure rate metrics
|
||||||
|
s.srv.Authenticate(s.ctx, args)
|
||||||
|
s.srv.MeasureRPCRate("status", structs.RateMetricRead, args)
|
||||||
|
|
||||||
stats := s.srv.raft.Stats()
|
stats := s.srv.raft.Stats()
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
@ -129,6 +145,11 @@ func (s *Status) RaftStats(args struct{}, reply *structs.RaftStats) error {
|
||||||
// HasNodeConn returns whether the server has a connection to the requested
|
// HasNodeConn returns whether the server has a connection to the requested
|
||||||
// Node.
|
// Node.
|
||||||
func (s *Status) HasNodeConn(args *structs.NodeSpecificRequest, reply *structs.NodeConnQueryResponse) error {
|
func (s *Status) HasNodeConn(args *structs.NodeSpecificRequest, reply *structs.NodeConnQueryResponse) error {
|
||||||
|
// note: we're intentionally throwing away any auth error here and only
|
||||||
|
// authenticate so that we can measure rate metrics
|
||||||
|
s.srv.Authenticate(s.ctx, args)
|
||||||
|
s.srv.MeasureRPCRate("status", structs.RateMetricRead, args)
|
||||||
|
|
||||||
// Validate the args
|
// Validate the args
|
||||||
if args.NodeID == "" {
|
if args.NodeID == "" {
|
||||||
return errors.New("Must provide the NodeID")
|
return errors.New("Must provide the NodeID")
|
||||||
|
|
Loading…
Reference in New Issue