Documentation
¶
Overview ¶
Package appapi is mcloud's client for the platform's apps API: an app's logs from Loki, its metrics from Prometheus, and the platform's alerts about it. The maxcloud controller serves it next to the discovery document (controller/internal/appapi), and answers only an app's owners and admins: mcloud sends the same token its kubeconfig does.
Index ¶
Constants ¶
const ( Logs = "logs" Metrics = "metrics" Alerts = "alerts" )
Features the API may offer (the discovery document lists them).
Variables ¶
var ErrForbidden = errors.New("forbidden")
ErrForbidden: the API refused (not one of the app's owners).
Functions ¶
This section is empty.
Types ¶
type Alert ¶
type Alert struct {
Name string `json:"name"`
State string `json:"state"` // pending or firing
Severity string `json:"severity,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
ActiveAt *time.Time `json:"activeAt,omitempty"`
Value string `json:"value,omitempty"`
Labels map[string]string `json:"labels"`
}
Alert is one of the platform's alerts about the app.
type AlertsResponse ¶
AlertsResponse lists the active alerts.
type Client ¶
Client calls the API. Base is the apps API's URL (https://maxcloud-api.gronblom.dev/api/v1/apps/); HTTP adds the bearer token.
type JobMetrics ¶
JobMetrics are the app's Jobs now.
type LogEntry ¶
type LogEntry struct {
Time time.Time `json:"time"`
Pod string `json:"pod"`
Container string `json:"container"`
Line string `json:"line"`
}
LogEntry is one line.
type LogQuery ¶
type LogQuery struct {
Since, Until time.Time
Pod string
Container string
AllContainers bool
Limit int
}
LogQuery picks lines: a range (Since before Until; zero Until is now), pods matching Pod (a regular expression, anchored), one Container or every one but Knative's queue-proxy (unless AllContainers), and at most Limit lines, the newest.
type LogsResponse ¶
type LogsResponse struct {
App string `json:"app"`
Start time.Time `json:"start"`
End time.Time `json:"end"`
Entries []LogEntry `json:"entries"`
Limited bool `json:"limited"`
}
LogsResponse: the newest lines in the range, oldest first; Limited says there were more.
type MetricsResponse ¶
type MetricsResponse struct {
App string `json:"app"`
Window string `json:"window"`
At time.Time `json:"at"`
Services []ServiceMetrics `json:"services"`
Queues []QueueMetrics `json:"queues"`
Jobs JobMetrics `json:"jobs"`
}
MetricsResponse is an app's metrics over a window.
type QueueMetrics ¶
type QueueMetrics struct {
Name string `json:"name"`
Kind string `json:"kind"`
Backlog float64 `json:"backlog"`
}
QueueMetrics is a queue function's backlog, as KEDA last read it.
type ServiceMetrics ¶
type ServiceMetrics struct {
Name string `json:"name"`
Requests float64 `json:"requests"`
RequestsPerSecond float64 `json:"requestsPerSecond"`
Errors float64 `json:"errors"`
ErrorRatio *float64 `json:"errorRatio"`
P95Seconds *float64 `json:"p95Seconds"`
Pods *float64 `json:"pods"`
PodsWanted *float64 `json:"podsWanted,omitempty"`
}
ServiceMetrics are one Knative service's requests over the window. Pointers are null when there's nothing to say (no requests, no pods reported).