usage

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 platformauth.Principal) PrincipalScope

type QueryScope

type QueryScope struct {
	Since      time.Time
	WindowDays int
	Limit      int
	Namespaces []string
	TeamIDs    []string
	Server     string
	Decision   string
	ToolName   string
}

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 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"`
}

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"`
}

type UsageFilters

type UsageFilters struct {
	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"`
}

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"`
}

Jump to

Keyboard shortcuts

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