appapi

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	Logs    = "logs"
	Metrics = "metrics"
	Alerts  = "alerts"
)

Features the API may offer (the discovery document lists them).

Variables

View Source
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

type AlertsResponse struct {
	App    string  `json:"app"`
	Alerts []Alert `json:"alerts"`
}

AlertsResponse lists the active alerts.

type Client

type Client struct {
	Base string
	HTTP *http.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.

func (*Client) Alerts

func (c *Client) Alerts(ctx context.Context, app string) (*AlertsResponse, error)

Alerts reads the platform's active alerts about an app.

func (*Client) Logs

func (c *Client) Logs(ctx context.Context, app string, q LogQuery) (*LogsResponse, error)

Logs reads an app's logs from Loki.

func (*Client) Metrics

func (c *Client) Metrics(ctx context.Context, app, window string) (*MetricsResponse, error)

Metrics reads an app's metrics over window (e.g. 1h, 7d).

type JobMetrics

type JobMetrics struct {
	Running float64 `json:"running"`
	Failed  float64 `json:"failed"`
}

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).

Jump to

Keyboard shortcuts

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