diagnostics

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinMaxRecords        = 1
	MaxMaxRecords        = 1000
	DefaultKQLMaxRecords = 100
)

KQL query validation constants

View Source
const (
	MaxLogRetentionDays   = 7
	MaxQueryRangeDuration = 24 * time.Hour
	DefaultMaxRecords     = 100
	MaxAllowedRecords     = 1000
)

Constants for diagnostics configuration

Variables

This section is empty.

Functions

func BuildSafeKQLQuery

func BuildSafeKQLQuery(category, logLevel string, maxRecords int, clusterResourceID string, isResourceSpecific bool) (string, error)

BuildSafeKQLQuery builds pre-validated KQL queries to prevent injection, scoped to specific AKS cluster Supports both Azure Diagnostics and Resource-specific destination tables Returns an error if query building fails

func CalculateTimespan

func CalculateTimespan(startTime, endTime string) (string, error)

CalculateTimespan converts start/end times to Azure CLI timespan format

func ExtractWorkspaceGUIDFromDiagnosticSettings

func ExtractWorkspaceGUIDFromDiagnosticSettings(subscriptionID, resourceGroup, clusterName string, azClient *azureclient.AzureClient, cfg *config.ConfigData) (string, error)

ExtractWorkspaceGUIDFromDiagnosticSettings extracts workspace GUID from diagnostic settings

func FindDiagnosticSettingForCategory

func FindDiagnosticSettingForCategory(subscriptionID, resourceGroup, clusterName, logCategory string, azClient *azureclient.AzureClient, cfg *config.ConfigData) (string, bool, error)

FindDiagnosticSettingForCategory finds the first diagnostic setting that has the specified log category enabled Returns the workspace ID and whether it uses resource-specific tables

func GetControlPlaneDiagnosticSettingsHandler

func GetControlPlaneDiagnosticSettingsHandler(azClient *azureclient.AzureClient, cfg *config.ConfigData) tools.ResourceHandler

GetControlPlaneDiagnosticSettingsHandler returns handler for diagnostic settings tool

func GetControlPlaneLogsHandler

func GetControlPlaneLogsHandler(azClient *azureclient.AzureClient, cfg *config.ConfigData) tools.ResourceHandler

GetControlPlaneLogsHandler returns handler for logs querying tool

func GetMaxRecords

func GetMaxRecords(params map[string]interface{}) int

GetMaxRecords extracts and validates the max_records parameter

func HandleControlPlaneDiagnosticSettings

func HandleControlPlaneDiagnosticSettings(params map[string]interface{}, azClient *azureclient.AzureClient, cfg *config.ConfigData) (string, error)

HandleControlPlaneDiagnosticSettings checks diagnostic settings for AKS cluster

func HandleControlPlaneLogs

func HandleControlPlaneLogs(params map[string]interface{}, azClient *azureclient.AzureClient, cfg *config.ConfigData) (string, error)

HandleControlPlaneLogs queries specific control plane logs

func ValidateControlPlaneLogsParams

func ValidateControlPlaneLogsParams(params map[string]interface{}) error

ValidateControlPlaneLogsParams validates all parameters for control plane logs query

func ValidateKQLQueryParams

func ValidateKQLQueryParams(category, logLevel string, maxRecords int, clusterResourceID string, tableMode TableMode) error

ValidateKQLQueryParams validates all parameters for KQL query builder

func ValidateTimeRange

func ValidateTimeRange(startTime string, params map[string]interface{}) error

ValidateTimeRange validates start and end time parameters

Types

type KQLQueryBuilder

type KQLQueryBuilder struct {
	// contains filtered or unexported fields
}

KQLQueryBuilder builds KQL queries for AKS control plane logs

func NewKQLQueryBuilder

func NewKQLQueryBuilder(category, logLevel string, maxRecords int, clusterResourceID string, tableMode TableMode) (*KQLQueryBuilder, error)

NewKQLQueryBuilder creates a new KQL query builder instance

func (*KQLQueryBuilder) Build

func (q *KQLQueryBuilder) Build() (string, error)

Build constructs the complete KQL query

type LogLevelMapping

type LogLevelMapping struct {
	AzureDiagnosticsPrefix string // Prefix used in Azure Diagnostics log_s field
	ResourceSpecificLevel  string // Level value used in resource-specific tables
}

LogLevelMapping defines the mapping between log levels and their representations

type TableMode

type TableMode int

TableMode represents the type of table being used

const (
	AzureDiagnosticsMode TableMode = iota
	ResourceSpecificMode
)

Jump to

Keyboard shortcuts

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