Documentation
¶
Index ¶
- Constants
- func QueryAdmission(pool int) (slots, reserved, queue int)
- type Config
- func (c Config) AIAPIKey() string
- func (c Config) AIBaseURL() string
- func (c Config) AgentConfigured() bool
- func (c Config) AlertEmailDefaults() ([]string, error)
- func (c Config) ClientCertificatesRequired() bool
- func (c Config) ControlDir() string
- func (c Config) ControlSQLitePath() string
- func (c Config) LogStartup()
- func (c Config) MCPResourceURL() string
- func (c Config) OIDCRoleMappingConfigured() bool
- func (c Config) QueryDir() string
- func (c Config) QueryDuckDBPath() string
- func (c Config) QueryTempDir() string
- func (c Config) RuntimeSizing() RuntimeSizing
- func (c Config) SMTPConfigured() bool
- func (c Config) SecureCookies() bool
- func (c Config) TLSEnabled() bool
- func (c Config) TelemetryDir() string
- func (c Config) TelemetryParquetDir() string
- func (c Config) Validate() error
- func (c Config) ValidateLoginLinkSecret() error
- type LoadOptions
- type RuntimeSizing
Constants ¶
const ( DefaultAddr = "127.0.0.1:7520" DefaultAnthropicBaseURL = "https://api.anthropic.com" DefaultOpenAIBaseURL = "https://api.openai.com/v1" )
const ( QueryCacheMaxEntries = 1024 QueryCacheMaxBytes = 64 << 20 )
The query result cache's bounds. Entries are panel, exemplar and trace detail results; bytes are estimated from their contents.
Variables ¶
This section is empty.
Functions ¶
func QueryAdmission ¶
QueryAdmission derives the executor's read admission from the pool: slots reads hold connections at once. reserved slots serve interactive reads only; queue bounds dashboard batch tickets (interactive waits are 2*slots). A one-slot pool has no reservation so panels can still execute. A pool of four or more keeps two connections outside the slots for readiness checks and other direct engine reads (such as the panel-internal rollup reader) that must not queue behind admitted panels.
Types ¶
type Config ¶
type Config struct {
// Addr binds the browser, API, MCP, OTLP/gRPC and OTLP/HTTP listener.
Addr string `group:"server" env:"PITOT_ADDR" default:"127.0.0.1:7520"`
// DataDir stores telemetry, query state, and the control database.
DataDir string `group:"storage" env:"PITOT_DATA_DIR" default:"./data"`
// IngestBatchSize sets the group-commit row target; valid values are 1–50000.
// Individual requests remain atomic and can exceed this target.
IngestBatchSize int `group:"ingest" env:"PITOT_INGEST_BATCH_SIZE" default:"50000"`
// IngestMaxInFlightBytes caps decoded telemetry held across concurrent requests
// until durable publication. Zero is unbounded. A single request is admitted
// when no other request holds budget, even if it exceeds the limit.
IngestMaxInFlightBytes int `group:"ingest" env:"PITOT_INGEST_MAX_IN_FLIGHT_BYTES" default:"268435456"`
// IngestToken sets the first ingest token, named configuration, when none has
// ever existed, so an automated install accepts telemetry as soon as it starts.
// Use foi_ plus 43 base64url characters. Only its digest is stored. It is
// ignored once any token has existed, including a revoked one, so a restart
// cannot bring back a revoked token.
IngestToken string `group:"ingest" env:"PITOT_INGEST_TOKEN" secret:"true"`
// RollupInterval schedules analytical rollups; use a Go duration of at least 1s.
RollupInterval time.Duration `group:"storage" env:"PITOT_ROLLUP_INTERVAL" default:"1m"`
// MCPEnabled serves the MCP endpoint at /mcp.
MCPEnabled bool `group:"mcp" env:"PITOT_MCP_ENABLED" default:"true"`
// RetentionDays sets telemetry retention in days; zero disables expiry.
RetentionDays int `group:"storage" env:"PITOT_RETENTION_DAYS" default:"30"`
// MaintenanceInterval controls Parquet retention and compaction, and
// query-cache checkpointing.
MaintenanceInterval time.Duration `group:"storage" env:"PITOT_MAINTENANCE_INTERVAL" default:"1h"`
// Set once at boot, this advances the service and edge rollup
// watermarks to the current max ingested timestamp. Existing history is not
// aggregated into those analytical rollups. Completed-batch trace caches
// still rebuild all retained history in bounded passes;
// uncached files remain immediately queryable. Useful for large pre-seeded
// datasets (benchmarks, restores); off in normal operation.
RollupSkipToLatest bool `group:"storage" env:"PITOT_ROLLUP_SKIP_TO_LATEST" default:"false"`
// DefaultNamespace supplies the namespace for telemetry without one.
DefaultNamespace string `group:"ingest" env:"PITOT_DEFAULT_NAMESPACE" default:"default"`
// PprofEnabled exposes Go's net/http/pprof handlers at /debug/pprof/* for
// CPU/heap/mutex/goroutine profiling under load. Off by default; the routes
// require an admin browser session with operations:read.
PprofEnabled bool `group:"server" env:"PITOT_PPROF_ENABLED" default:"false"`
// QueryCacheTTL is the oldest a dashboard panel, exemplar or trace
// detail result served from memory may be, measured from the end of the
// time window it covers (for traces and exemplars, from when their run
// started). A result younger than half the TTL is served as is; one
// younger than the TTL is served while one background run refreshes it;
// an older one is rerun. A request with Cache-Control: no-cache, such as
// a dashboard's manual refresh, always reruns. Zero disables the cache;
// concurrent identical requests still share one execution.
QueryCacheTTL time.Duration `group:"server" env:"PITOT_QUERY_CACHE_TTL" default:"10s"`
// DuckDBMemory caps DuckDB's memory (e.g. "8GB"). Empty selects 60% of detected
// available memory, reserving headroom for Go. If detection fails, DuckDB uses
// its default with a process headroom adjustment. Startup logs and /readyz
// report the resolved budget and detection status. Set an explicit cap when
// memory limit detection is incomplete.
DuckDBMemory string `group:"storage" env:"PITOT_DUCKDB_MEMORY"`
// DuckDBThreads caps DuckDB's global query worker pool. Zero selects one
// worker per CPU the process may run on (the affinity mask and cgroup
// quota, as GOMAXPROCS resolves them) rather than DuckDB's count of the
// machine's hardware threads. Set it to leave cores free for ingest on a
// query-heavy co-tenant host.
DuckDBThreads int `group:"storage" env:"PITOT_DUCKDB_THREADS" default:"0"`
// DuckDBMaxConns caps the DuckDB read connection pool. Reads scan immutable
// Parquet concurrently; analytical and completed-batch writes use separate
// gates and connections. Zero selects available Go CPUs, bounded to 2–16.
// Startup logs and /readyz report the resolved pool size.
DuckDBMaxConns int `group:"storage" env:"PITOT_DUCKDB_MAX_CONNECTIONS" default:"0"`
// AlertEnabled runs the alert evaluation engine.
AlertEnabled bool `group:"alerts" env:"PITOT_ALERTS_ENABLED" default:"true"`
// AlertEvaluationInterval schedules alert evaluation; use a Go duration of at least 1s.
AlertEvaluationInterval time.Duration `group:"alerts" env:"PITOT_ALERTS_EVALUATION_INTERVAL" default:"30s"`
// AlertHistoryDays sets alert history retention in days.
AlertHistoryDays int `group:"alerts" env:"PITOT_ALERTS_HISTORY_DAYS" default:"7"`
// AlertEmailDefaultTo is a comma-separated list of addresses that receive alerts from rules with no webhook and no email recipients of their own; requires SMTP.
AlertEmailDefaultTo string `group:"alerts" env:"PITOT_ALERTS_EMAIL_DEFAULT_TO"`
// AlertEmailHourlyLimit caps the alert emails sent to one address in any rolling hour, across all rules. Notifications over the limit are suppressed, not delayed, and shown on the rule; 0 suppresses all alert email.
AlertEmailHourlyLimit int `group:"alerts" env:"PITOT_ALERTS_EMAIL_HOURLY_LIMIT" default:"30"`
// AIProvider enables chat by selecting exactly anthropic or openai. Empty disables chat.
AIProvider string `group:"ai" env:"PITOT_AI_PROVIDER" default:""`
// AIModel overrides the provider's default: claude-sonnet-5-5 for Anthropic
// and gpt-6.1-sol for OpenAI. The OpenAI provider expects a reasoning model
// supporting reasoning.encrypted_content for stateless Responses replay.
// A 400 rejecting encrypted content is reported as a server-side configuration
// error; choose a compatible reasoning model with PITOT_AI_MODEL.
AIModel string `group:"ai" env:"PITOT_AI_MODEL"`
// AnthropicAPIKey is required when PITOT_AI_PROVIDER is anthropic.
AnthropicAPIKey string `group:"ai" env:"ANTHROPIC_API_KEY" secret:"true"`
// AnthropicBaseURL defaults to https://api.anthropic.com. Pitot appends
// /v1/messages, preserving any gateway path prefix. Use an HTTP(S) base URL
// without embedded credentials, a query, or a fragment.
AnthropicBaseURL string `group:"ai" env:"ANTHROPIC_BASE_URL"`
// OpenAIAPIKey is required when PITOT_AI_PROVIDER is openai.
OpenAIAPIKey string `group:"ai" env:"OPENAI_API_KEY" secret:"true"`
// OpenAIBaseURL defaults to https://api.openai.com/v1. Pitot appends
// /responses, preserving the API version and any gateway path prefix.
// Use an HTTP(S) base URL without embedded credentials, a query, or a fragment.
OpenAIBaseURL string `group:"ai" env:"OPENAI_BASE_URL"`
// SMTPHost selects the mail server. Host, username, password, and from must all be set to enable SMTP.
SMTPHost string `group:"smtp" env:"PITOT_SMTP_HOST"`
// SMTPPort sets the mail server's positive TCP port.
SMTPPort int `group:"smtp" env:"PITOT_SMTP_PORT" default:"587"`
// SMTPUser authenticates to the mail server; required with SMTP.
SMTPUser string `group:"smtp" env:"PITOT_SMTP_USERNAME"`
// SMTPPass authenticates to the mail server; required with SMTP.
SMTPPass string `group:"smtp" env:"PITOT_SMTP_PASSWORD" secret:"true"`
// SMTPFrom sets the email sender address; required with SMTP.
SMTPFrom string `group:"smtp" env:"PITOT_SMTP_FROM"`
// AuthMode selects local sign-in or oidc; each mode validates its prerequisites.
AuthMode string `group:"auth" env:"PITOT_AUTH_MODE" default:"local"`
// PublicURL sets the external browser origin, MCP token audience, and trusted MCP
// request origin. Required for OIDC; HTTPS is required with MCP.
PublicURL string `group:"server" env:"PITOT_PUBLIC_URL"`
// AuthCodeSecret signs sign-in codes and login links; needs at least 32 characters in local mode and to issue or redeem OIDC break-glass links.
AuthCodeSecret string `group:"auth" env:"PITOT_AUTH_CODE_SECRET" secret:"true"`
// SelfSignup allows verified email addresses to create viewer accounts; requires local auth and SMTP.
SelfSignup bool `group:"auth" env:"PITOT_SELF_SIGNUP" default:"false"`
// SessionIdleTTL expires inactive sessions; use a Go duration of at least 5m.
SessionIdleTTL time.Duration `group:"auth" env:"PITOT_SESSION_IDLE_TTL" default:"12h"`
// SessionAbsoluteTTL limits total session lifetime; it must be at least PITOT_SESSION_IDLE_TTL.
SessionAbsoluteTTL time.Duration `group:"auth" env:"PITOT_SESSION_ABSOLUTE_TTL" default:"168h"`
// SCIMToken enables SCIM 2.0 user provisioning under /scim/v2 and turns off browser setup; requires OIDC mode and at least 32 characters.
SCIMToken string `group:"auth" env:"PITOT_SCIM_TOKEN" secret:"true"`
// OIDCIssuerURL selects the identity provider issuer; required in OIDC mode. Pitot starts while it is unreachable and retries discovery; a mismatched issuer fails startup.
OIDCIssuerURL string `group:"auth" env:"PITOT_OIDC_ISSUER_URL"`
// OIDCClientID identifies Pitot's client registration; required in OIDC mode.
OIDCClientID string `group:"auth" env:"PITOT_OIDC_CLIENT_ID"`
// OIDCClientSecret authenticates Pitot's client registration; required in OIDC mode.
OIDCClientSecret string `group:"auth" env:"PITOT_OIDC_CLIENT_SECRET" secret:"true"`
// OIDCEmailClaim names the claim containing the user's email address.
OIDCEmailClaim string `group:"auth" env:"PITOT_OIDC_EMAIL_CLAIM" default:"email"`
// OIDCEmailVerification selects required verified-email claims or issuer trust; issuer trust requires an allowlist.
OIDCEmailVerification string `group:"auth" env:"PITOT_OIDC_EMAIL_VERIFICATION" default:"required"`
// OIDCAutoProvision creates accounts on OIDC sign-in; requires an allowed group or domain.
OIDCAutoProvision bool `group:"auth" env:"PITOT_OIDC_AUTO_PROVISION" default:"false"`
// OIDCAllowedGroups lists allowed identity-provider groups, separated by commas.
OIDCAllowedGroups string `group:"auth" env:"PITOT_OIDC_ALLOWED_GROUPS"`
// OIDCAllowedDomains lists allowed email domains, separated by commas; wildcard * requires verified email.
OIDCAllowedDomains string `group:"auth" env:"PITOT_OIDC_ALLOWED_DOMAINS"`
// OIDCDefaultRole assigns viewer, operator, or admin to users without a group role mapping.
OIDCDefaultRole string `group:"auth" env:"PITOT_OIDC_DEFAULT_ROLE" default:"viewer"`
// OIDCOperatorGroups lists identity-provider groups mapped to operator, separated by commas.
OIDCOperatorGroups string `group:"auth" env:"PITOT_OIDC_OPERATOR_GROUPS"`
// OIDCAdminGroups lists identity-provider groups mapped to admin, separated by commas.
OIDCAdminGroups string `group:"auth" env:"PITOT_OIDC_ADMIN_GROUPS"`
// MetricsToken authorizes Prometheus scrapes with a bearer token; optional when using an admin session.
MetricsToken string `group:"metrics" env:"PITOT_METRICS_TOKEN" secret:"true"`
// MetricsPublic allows unauthenticated Prometheus scrapes.
MetricsPublic bool `group:"metrics" env:"PITOT_METRICS_PUBLIC" default:"false"`
// TrustedProxyCIDRs lists trusted proxy networks, separated by commas; empty trusts no forwarded client addresses.
TrustedProxyCIDRs string `group:"server" env:"PITOT_TRUSTED_PROXY_CIDRS"`
// TLSCertFile selects the TLS certificate file; requires PITOT_TLS_KEY_FILE.
TLSCertFile string `group:"server" env:"PITOT_TLS_CERT_FILE"`
// TLSKeyFile selects the TLS private key file; requires PITOT_TLS_CERT_FILE.
TLSKeyFile string `group:"server" env:"PITOT_TLS_KEY_FILE"`
// TLSClientCAFile selects a PEM CA bundle; when set, the listener requires client certificates signed by it. Requires PITOT_TLS_CERT_FILE and PITOT_TLS_KEY_FILE.
TLSClientCAFile string `group:"server" env:"PITOT_TLS_CLIENT_CA_FILE"`
// HealthcheckCertFile selects the client certificate pitot healthcheck presents; requires PITOT_HEALTHCHECK_KEY_FILE and PITOT_TLS_CLIENT_CA_FILE.
HealthcheckCertFile string `group:"server" env:"PITOT_HEALTHCHECK_CERT_FILE"`
// HealthcheckKeyFile selects the private key for PITOT_HEALTHCHECK_CERT_FILE; requires PITOT_HEALTHCHECK_CERT_FILE.
HealthcheckKeyFile string `group:"server" env:"PITOT_HEALTHCHECK_KEY_FILE"`
// contains filtered or unexported fields
}
Config is Pitot's canonical configuration schema. Custom environment names use PITOT_; provider credentials and endpoints use their vendor's names. Elapsed-time settings use time.Duration with unit-bearing values.
func Load ¶
func Load(options LoadOptions) (Config, error)
Load resolves built-in defaults and process environment, then sizes and validates the effective configuration.
func (Config) AIBaseURL ¶
AIBaseURL returns the selected provider's API base, including its default.
func (Config) AgentConfigured ¶
AgentConfigured reports whether the in-process AI agent should be started.
func (Config) AlertEmailDefaults ¶
AlertEmailDefaults returns the normalized default alert email destination.
func (Config) ClientCertificatesRequired ¶
ClientCertificatesRequired reports whether the TLS listener requires and verifies client certificates against PITOT_TLS_CLIENT_CA_FILE.
func (Config) ControlDir ¶
func (Config) ControlSQLitePath ¶
func (Config) LogStartup ¶
func (c Config) LogStartup()
LogStartup reports the effective non-secret sizing and security-sensitive deployment choices after Load succeeds.
func (Config) MCPResourceURL ¶
MCPResourceURL returns the canonical OAuth resource URI for the MCP route. MCP is served by the main HTTP server, so it always shares PITOT_PUBLIC_URL. The localhost value preserves zero-configuration development when no public origin is configured.
func (Config) OIDCRoleMappingConfigured ¶
OIDCRoleMappingConfigured reports whether a group list names at least one group. A list of only separators and spaces maps nothing.
func (Config) QueryDuckDBPath ¶
func (Config) QueryTempDir ¶
func (Config) RuntimeSizing ¶
func (c Config) RuntimeSizing() RuntimeSizing
RuntimeSizing returns the effective startup sizing without exposing any credentials or unrelated configuration.
func (Config) SMTPConfigured ¶
SMTPConfigured returns true if SMTP is set up for sending email codes.
func (Config) SecureCookies ¶
func (Config) TLSEnabled ¶
TLSEnabled reports whether a cert/key pair is configured. When true, HTTP serves HTTPS and OTLP gRPC over TLS on PITOT_ADDR.
func (Config) TelemetryDir ¶
func (Config) TelemetryParquetDir ¶
func (Config) ValidateLoginLinkSecret ¶
ValidateLoginLinkSecret reports whether PITOT_AUTH_CODE_SECRET can protect login links. Local mode requires this at startup. OIDC mode checks it only when a break-glass link is issued or redeemed, so OIDC installs that never set the secret keep starting.
type LoadOptions ¶
type LoadOptions struct {
Environ []string
}
LoadOptions selects the environment. A nil Environ uses os.Environ; an empty slice deliberately supplies no environment variables.
type RuntimeSizing ¶
type RuntimeSizing struct {
DuckDBMemory string `json:"duckdb_memory"`
DuckDBMemoryAuto bool `json:"duckdb_memory_auto"`
DuckDBMaxConns int `json:"duckdb_max_conns"`
DuckDBMaxConnsAuto bool `json:"duckdb_max_conns_auto"`
DuckDBThreads int `json:"duckdb_threads"`
DuckDBThreadsAuto bool `json:"duckdb_threads_auto"`
DetectedMemoryBytes uint64 `json:"detected_memory_bytes"`
DetectedHostMemoryBytes uint64 `json:"detected_host_memory_bytes"`
DetectedCgroupLimitBytes uint64 `json:"detected_cgroup_limit_bytes"`
MemorySource string `json:"memory_source"`
MemoryDetectionIncomplete bool `json:"memory_detection_incomplete"`
GOMAXPROCS int `json:"gomaxprocs"`
}
RuntimeSizing is the safe, non-secret sizing state exposed through runtime diagnostics. It reports the effective values after startup resolution and preserves whether each value came from the machine or the operator.