Documentation
¶
Index ¶
- Constants
- Variables
- type Backend
- func (b *Backend) Action(ref Ref, action string, _ map[string]any) (map[string]any, error)
- func (b *Backend) Configure(s Settings)
- func (b *Backend) Delete(ref Ref) error
- func (b *Backend) DeleteInGroup(rg string)
- func (b *Backend) FindWorkspace(idOrName string) (*Workspace, bool)
- func (b *Backend) Get(ref Ref) (map[string]any, error)
- func (b *Backend) Ingest(ruleID, stream string, records []map[string]any) *apiError
- func (b *Backend) List(ref Ref) ([]map[string]any, error)
- func (b *Backend) ListDataCollectionEndpoints(host string) []map[string]any
- func (b *Backend) ListDataCollectionRules(host string) []map[string]any
- func (b *Backend) ListWorkspaceTables(idOrName string) ([]map[string]any, error)
- func (b *Backend) ListWorkspaces() []map[string]any
- func (b *Backend) Patch(ref Ref, body map[string]any) (map[string]any, error)
- func (b *Backend) Put(ref Ref, body map[string]any) (map[string]any, error)
- func (b *Backend) QueryJSON(idOrName string, req QueryRequest) (int, any)
- func (b *Backend) QueryResource(resourceID string, req QueryRequest, withStats bool) (*QueryResponse, *apiError)
- func (b *Backend) QueryWorkspace(idOrName string, req QueryRequest, withStats bool) (*QueryResponse, *apiError)
- func (b *Backend) Reset()
- func (b *Backend) Restore(ctx context.Context, data []byte) error
- func (b *Backend) SetClock(now func() time.Time)
- func (b *Backend) Snapshot(ctx context.Context) []byte
- type Column
- type ConfigProvider
- type DCE
- type DCR
- type Handler
- func (h *Handler) ExtractOperation(c *echo.Context) string
- func (h *Handler) ExtractResource(c *echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Shutdown(ctx context.Context)
- func (h *Handler) Snapshot(ctx context.Context) []byte
- func (h *Handler) StartWorker(ctx context.Context) error
- type Provider
- type QueryRequest
- type QueryResponse
- type Ref
- type Settings
- type Table
- type Workspace
Constants ¶
const DefaultPort = 10013
DefaultPort is the Azure Monitor Logs HTTPS listener (query and ingestion APIs).
Variables ¶
var ( ErrNilAppContext = errors.New("azuremonitor: nil app context") ErrNotFound = errors.New("azuremonitor: resource not found") ErrConflict = errors.New("azuremonitor: resource conflict") ErrInvalid = errors.New("azuremonitor: invalid request") ErrUnsupported = errors.New("azuremonitor: unsupported resource type") )
Sentinel errors returned by the backend.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend holds workspaces, data collection endpoints and rules.
func (*Backend) Action ¶
Action runs a POST action on a workspace (sharedKeys, listKeys, regenerateSharedKey).
func (*Backend) DeleteInGroup ¶
DeleteInGroup removes every resource of the resource group.
func (*Backend) FindWorkspace ¶
FindWorkspace resolves a customer ID, workspace name or ARM resource ID.
func (*Backend) Ingest ¶
Ingest stores the records of one upload. Records are decoded JSON objects (numbers as json.Number).
func (*Backend) List ¶
List returns every resource of the ref's type under the subscription, resource group or parent.
func (*Backend) ListDataCollectionEndpoints ¶
ListDataCollectionEndpoints returns every data collection endpoint, advertising endpoints for host.
func (*Backend) ListDataCollectionRules ¶
ListDataCollectionRules returns every data collection rule, advertising endpoints for host.
func (*Backend) ListWorkspaceTables ¶
ListWorkspaceTables returns the ARM body of every table of the workspace named by id, customer id or name.
func (*Backend) ListWorkspaces ¶
ListWorkspaces returns the ARM body of every workspace across subscriptions.
func (*Backend) QueryJSON ¶
func (b *Backend) QueryJSON(idOrName string, req QueryRequest) (int, any)
QueryJSON runs a query against one workspace and returns the HTTP status and JSON-ready body the data-plane API would answer with (the error envelope on failure).
func (*Backend) QueryResource ¶
func (b *Backend) QueryResource(resourceID string, req QueryRequest, withStats bool) (*QueryResponse, *apiError)
QueryResource runs a resource-centric query.
func (*Backend) QueryWorkspace ¶
func (b *Backend) QueryWorkspace(idOrName string, req QueryRequest, withStats bool) (*QueryResponse, *apiError)
QueryWorkspace runs a query against one workspace.
func (*Backend) Restore ¶
Restore loads backend state from a snapshot. It implements persistence.Persistable.
type Column ¶
type Column struct {
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description,omitempty"`
DisplayName string `json:"displayName,omitempty"`
}
Column is one table or stream column; Type is a KQL type name.
type ConfigProvider ¶
type ConfigProvider interface {
GetAzureMonitorSettings() Settings
}
ConfigProvider extracts the Azure Monitor Logs settings from the AppContext config.
type DCE ¶
type DCE struct {
Created time.Time `json:"created"`
Tags map[string]string `json:"tags"`
Props map[string]any `json:"props"`
Name string `json:"name"`
Sub string `json:"sub"`
RG string `json:"rg"`
Location string `json:"location"`
Kind string `json:"kind"`
ImmutableID string `json:"immutableId"`
}
DCE is a data collection endpoint.
type DCR ¶
type DCR struct {
Created time.Time `json:"created"`
Tags map[string]string `json:"tags"`
Props map[string]any `json:"props"`
Identity map[string]any `json:"identity,omitempty"`
Name string `json:"name"`
Sub string `json:"sub"`
RG string `json:"rg"`
Location string `json:"location"`
Kind string `json:"kind"`
ImmutableID string `json:"immutableId"`
}
DCR is a data collection rule.
type Handler ¶
type Handler struct {
Backend *Backend
// Issuer verifies bearer token signatures when Settings.ValidateTokens is set.
Issuer *aadauth.Issuer
// Settings holds the listener configuration.
Settings Settings
// Port is the fixed TCP port StartWorker binds.
Port int
// contains filtered or unexported fields
}
Handler serves the Logs Ingestion and Logs Query APIs on a dedicated HTTPS listener.
func NewHandler ¶
NewHandler creates a Handler.
func (*Handler) ExtractOperation ¶
ExtractOperation names the operation for metrics.
func (*Handler) ExtractResource ¶
ExtractResource returns the request path for metrics.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations lists the data-plane operations.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the Echo handler for the Azure Monitor Logs APIs.
func (*Handler) MatchPriority ¶
MatchPriority is irrelevant because RouteMatcher never matches.
func (*Handler) RouteMatcher ¶
RouteMatcher never matches: Azure Monitor Logs runs on its own listener.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for Azure Monitor Logs.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init builds the backend and handler; the port is bound by Handler.StartWorker.
type QueryRequest ¶
type QueryRequest struct {
Query string `json:"query"`
Timespan string `json:"timespan"`
Workspaces []string `json:"workspaces"`
}
QueryRequest is the body of a query call.
type QueryResponse ¶
type QueryResponse struct {
Statistics map[string]any `json:"statistics,omitempty"`
Tables []resultTable `json:"tables"`
}
QueryResponse is the documented tables/columns/rows result.
type Ref ¶
type Ref struct {
// Host is the request host (no port) used to build advertised endpoints.
Host string
Sub string
RG string
Namespace string
Types []string
Names []string
}
Ref addresses an ARM resource served by this backend.
type Settings ¶
type Settings struct {
TLSCertFile string `` //nolint:lll // config struct tags are intentionally verbose
/* 248-byte string literal not displayed */
TLSKeyFile string `` //nolint:lll // config struct tags are intentionally verbose
/* 142-byte string literal not displayed */
Advertise string `` //nolint:lll // config struct tags are intentionally verbose
/* 233-byte string literal not displayed */
Port int `` //nolint:lll // config struct tags are intentionally verbose
/* 264-byte string literal not displayed */
ValidateTokens bool `` //nolint:lll // config struct tags are intentionally verbose
/* 264-byte string literal not displayed */
StrictIngest bool `` //nolint:lll // config struct tags are intentionally verbose
/* 264-byte string literal not displayed */
}
Settings is the Kong-embedded configuration of the Azure Monitor Logs emulator.
func DefaultSettings ¶
func DefaultSettings() Settings
DefaultSettings returns the settings used when no ConfigProvider exists.
type Table ¶
type Table struct {
Created time.Time `json:"created"`
Name string `json:"name"`
Plan string `json:"plan"`
Description string `json:"description,omitempty"`
Columns []Column `json:"columns"`
Rows [][]any `json:"-"`
Retention int `json:"retention"`
TotalRet int `json:"totalRetention"`
Custom bool `json:"custom"`
}
Table is a workspace table with its rows. Cells use engine types (see kql.Rel).
type Workspace ¶
type Workspace struct {
Created time.Time `json:"created"`
Modified time.Time `json:"modified"`
SKUUpdated time.Time `json:"skuUpdated"`
Tags map[string]string `json:"tags"`
Props map[string]any `json:"props"`
Tables map[string]*Table `json:"-"`
Sub string `json:"sub"`
RG string `json:"rg"`
Location string `json:"location"`
CustomerID string `json:"customerId"`
SKU string `json:"sku"`
Primary string `json:"primaryKey"`
Secondary string `json:"secondaryKey"`
Name string `json:"name"`
Retention int `json:"retention"`
}
Workspace is a Log Analytics workspace.