Documentation
¶
Overview ¶
Package analytics is the Visionary server: fixed dashboards over the D1 request log and system metrics, an AI analyst that investigates questions with read-only SQL, saved panels, and a request log explorer.
Index ¶
Constants ¶
const UserAgent = "Visionary/1.0"
UserAgent identifies Visionary to the auth API and model provider.
Variables ¶
var ( Version = "" Commit = "" )
Version and Commit are set at build time:
go build -ldflags "-X github.com/styropyr0/visionary/internal/analytics.Version=v0.3.2 \ -X github.com/styropyr0/visionary/internal/analytics.Commit=e20dc71..."
A build without them falls back to the commit Railway or Go recorded.
Functions ¶
This section is empty.
Types ¶
type AnalystPanel ¶
type AnalystPanel struct {
Title string `json:"title"`
Description string `json:"description"`
Query string `json:"query"`
Viz Viz `json:"viz"`
Result *Result `json:"result"`
}
AnalystPanel is a finished chart: spec, the template SQL for saving, and data.
type Config ¶
type Config struct {
Addr string
DatabaseURL string
D1APIBase string
D1AccountID string
D1DatabaseID string
D1APIToken string
OpenAIAPIKey string
OpenAIAPIBase string
Model string
ModelReasoning string
MaxRows int
MaxRangeDays int
ApdexMs int
SLOTarget float64
// AppName is the product whose API is being analysed ("Acme"); the
// analyst uses it in answers. DataNotes is free text about the data the
// analyst should know, such as what user_role values mean.
AppName string
DataNotes string
// Auth is delegated to an existing API; see internal/authbridge.
Auth authbridge.Config
SessionSecret string
SessionTTL time.Duration
RoleCheckEvery time.Duration
TrustProxy bool
SecureCookieEnv string
}
func LoadConfig ¶
LoadConfig reads the environment. D1 variables use the same names as the API server that writes the tables.
type Result ¶
type Result struct {
Columns []string `json:"columns"`
Rows [][]any `json:"rows"`
Truncated bool `json:"truncated"`
RowsRead int64 `json:"rows_read"`
DurationMs float64 `json:"duration_ms"`
SQL string `json:"sql"`
Bucket int64 `json:"bucket"`
From string `json:"from"`
To string `json:"to"`
// Source says where a fixed panel was read from: "raw", "rollup_1m" or
// "rollup_1h" (the coarsest rollup used; ragged edges are always raw).
Source string `json:"source,omitempty"`
}
Result is what every data endpoint returns.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
type UptimeCheck ¶
type UptimeCheck struct {
ID int64 `json:"id"`
Name string `json:"name"`
URL string `json:"url"`
Method string `json:"method"`
ExpectStatus string `json:"expect_status"`
BodyContains string `json:"body_contains"`
Headers map[string]string `json:"headers"`
IntervalS int `json:"interval_s"`
TimeoutMs int `json:"timeout_ms"`
DegradedMs int `json:"degraded_ms"`
FollowRedirects bool `json:"follow_redirects"`
Enabled bool `json:"enabled"`
OnStatusPage bool `json:"on_status_page"`
StatusShowURL bool `json:"status_show_url"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
UptimeCheck is one HTTP probe. Header values with secret-looking names are masked in API responses; sending the mask back keeps the stored value.
Source Files
¶
- about.go
- alerts.go
- alerts_api.go
- alerts_channels.go
- alerts_eval.go
- alerts_explain.go
- alerts_metrics.go
- alerts_preview.go
- alerts_schema.go
- alerts_slo.go
- alerts_store.go
- analyst.go
- anomaly.go
- auth.go
- config.go
- dialect.go
- digest.go
- digest_email.go
- digest_more.go
- features.go
- hosts.go
- hosts_api.go
- hosts_containers.go
- hosts_ingest.go
- hosts_schema.go
- llm.go
- logs.go
- notify.go
- notify_email.go
- otlp.go
- otlp_attrs.go
- otlp_logs.go
- otlp_metrics.go
- otlp_state.go
- otlp_traces.go
- otlp_write.go
- overview.go
- performance.go
- query.go
- rollups.go
- rollups_job.go
- rollups_panels.go
- rollups_route.go
- rollups_sql.go
- rum.go
- rum_fingerprint.go
- rum_ingest.go
- rum_panels.go
- rum_writer.go
- security.go
- security_alerts.go
- security_api.go
- security_detect.go
- security_digest.go
- security_panels.go
- server.go
- sqlguard.go
- status.go
- status_template.go
- store.go
- system.go
- team.go
- team_audit.go
- team_dashboards.go
- team_keys.go
- team_roles.go
- team_schema.go
- telemetry.go
- telemetry_errors.go
- telemetry_releases.go
- telemetry_spans.go
- uptime.go
- uptime_checks.go
- uptime_guard.go
- uptime_incidents.go
- uptime_runner.go
- uptime_stats.go
- viz.go