usage

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequestUsageQuery

func RequestUsageQuery(dbName, where string) string

func ServersQuery

func ServersQuery(dbName, where string) string

func WhereClause

func WhereClause(scope QueryScope, extraConditions ...string) (string, []any)

Types

type ActorUsage

type ActorUsage struct {
	HumanID       string    `json:"human_id"`
	AgentID       string    `json:"agent_id"`
	Events        uint64    `json:"events"`
	UniqueServers uint64    `json:"unique_servers"`
	UniqueTools   uint64    `json:"unique_tools"`
	Denied        uint64    `json:"denied"`
	LastSeen      time.Time `json:"last_seen"`
}

type DecisionUsage

type DecisionUsage struct {
	Decision string `json:"decision"`
	Events   uint64 `json:"events"`
}

type PrincipalScope

type PrincipalScope struct {
	Namespaces []string
	TeamIDs    []string
}

func PrincipalOwnedScope

func PrincipalOwnedScope(p passport.Principal) PrincipalScope

type QueryScope

type QueryScope struct {
	AgentID       string
	Since         time.Time
	WindowDays    int
	Limit         int
	Namespaces    []string
	TeamIDs       []string
	Server        string
	Decision      string
	ToolName      string
	Until         time.Time
	RPCMethod     string
	PolicyVersion string
	Scope         string
	HTTPStatus    string
	Admin         bool
}

func (QueryScope) Filters

func (scope QueryScope) Filters() UsageFilters

type RecentActivity

type RecentActivity struct {
	Timestamp time.Time `json:"timestamp"`
	Server    string    `json:"server,omitempty"`
	Namespace string    `json:"namespace,omitempty"`
	TeamID    string    `json:"team_id,omitempty"`
	HumanID   string    `json:"human_id,omitempty"`
	AgentID   string    `json:"agent_id,omitempty"`
	SessionID string    `json:"session_id,omitempty"`
	Decision  string    `json:"decision,omitempty"`
	ToolName  string    `json:"tool_name,omitempty"`
	EventType string    `json:"event_type,omitempty"`
}

type RequestUsage

type RequestUsage struct {
	Server        string    `json:"server"`
	Namespace     string    `json:"namespace"`
	TeamID        string    `json:"team_id,omitempty"`
	RPCMethod     string    `json:"rpc_method"`
	ToolName      string    `json:"tool_name,omitempty"`
	Decision      string    `json:"decision"`
	PolicyVersion string    `json:"policy_version,omitempty"`
	Events        uint64    `json:"events"`
	HTTPFailures  uint64    `json:"http_failures"`
	P95LatencyMS  float64   `json:"p95_latency_ms"`
	LastSeen      time.Time `json:"last_seen"`
	TraceID       string    `json:"trace_id,omitempty"`
}

RequestUsage groups actual gateway events; no tool arguments or results are returned.

type ServerUsage

type ServerUsage struct {
	Server       string    `json:"server"`
	Namespace    string    `json:"namespace"`
	TeamID       string    `json:"team_id,omitempty"`
	Events       uint64    `json:"events"`
	Allowed      uint64    `json:"allowed"`
	Denied       uint64    `json:"denied"`
	UniqueHumans uint64    `json:"unique_humans"`
	UniqueAgents uint64    `json:"unique_agents"`
	LastSeen     time.Time `json:"last_seen"`
}

type Service

type Service struct {
	DB       clickhouse.Conn
	DBName   string
	Resolver identity.Resolver
}

func (*Service) HandleAdminUsage

func (s *Service) HandleAdminUsage(w http.ResponseWriter, r *http.Request)

func (*Service) HandleUserUsage

func (s *Service) HandleUserUsage(w http.ResponseWriter, r *http.Request)

type TimePoint

type TimePoint struct {
	Bucket            time.Time `json:"bucket"`
	Events            uint64    `json:"events"`
	Allowed           uint64    `json:"allowed"`
	Denied            uint64    `json:"denied"`
	RequestsPerSecond float64   `json:"requests_per_second"`
}

type ToolUsage

type ToolUsage struct {
	Server   string    `json:"server"`
	ToolName string    `json:"tool_name"`
	HumanID  string    `json:"human_id"`
	TeamID   string    `json:"team_id"`
	AgentID  string    `json:"agent_id"`
	Events   uint64    `json:"events"`
	Denied   uint64    `json:"denied"`
	LastSeen time.Time `json:"last_seen"`
}

type Totals

type Totals struct {
	Events           uint64  `json:"events"`
	Allowed          uint64  `json:"allowed"`
	Denied           uint64  `json:"denied"`
	UniqueServers    uint64  `json:"unique_servers"`
	UniqueHumans     uint64  `json:"unique_humans"`
	UniqueAgents     uint64  `json:"unique_agents"`
	UniqueSessions   uint64  `json:"unique_sessions"`
	HTTPFailures     uint64  `json:"http_failures"`
	ServerErrors     uint64  `json:"server_errors"`
	AverageLatencyMS float64 `json:"average_latency_ms"`
	P95LatencyMS     float64 `json:"p95_latency_ms"`
	BytesIn          uint64  `json:"bytes_in"`
	BytesOut         uint64  `json:"bytes_out"`
}

type UsageFacets

type UsageFacets struct {
	Servers        []string `json:"servers"`
	Methods        []string `json:"methods"`
	Tools          []string `json:"tools"`
	PolicyVersions []string `json:"policy_versions"`
}

type UsageFilters

type UsageFilters struct {
	AgentID       string   `json:"agent_id,omitempty"`
	Namespaces    []string `json:"namespaces,omitempty"`
	TeamIDs       []string `json:"team_ids,omitempty"`
	Server        string   `json:"server,omitempty"`
	Decision      string   `json:"decision,omitempty"`
	ToolName      string   `json:"tool_name,omitempty"`
	RPCMethod     string   `json:"rpc_method,omitempty"`
	PolicyVersion string   `json:"policy_version,omitempty"`
	Scope         string   `json:"scope,omitempty"`
	HTTPStatus    string   `json:"http_status,omitempty"`
}

type UsageResponse

type UsageResponse struct {
	Totals        Totals           `json:"totals"`
	Servers       []ServerUsage    `json:"servers"`
	Actors        []ActorUsage     `json:"actors"`
	Tools         []ToolUsage      `json:"tools"`
	Decisions     []DecisionUsage  `json:"decisions"`
	Series        []TimePoint      `json:"series,omitempty"`
	Recent        []RecentActivity `json:"recent,omitempty"`
	WindowDays    int              `json:"window_days"`
	Filters       UsageFilters     `json:"filters,omitempty"`
	Requests      []RequestUsage   `json:"requests,omitempty"`
	Facets        *UsageFacets     `json:"facets,omitempty"`
	BucketSeconds int              `json:"bucket_seconds"`
	WindowStart   time.Time        `json:"window_start"`
	WindowEnd     time.Time        `json:"window_end"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL