kiali

package
v0.0.57 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultRateInterval is the default rate interval for fetching error rates and metrics.
	// This value is used when rateInterval is not explicitly provided in API calls.
	DefaultRateInterval    = "10m"
	DefaultGraphType       = "versionedApp"
	DefaultDuration        = "30m"
	DefaultStep            = "15"
	DefaultDirection       = "outbound"
	DefaultReporter        = "source"
	DefaultRequestProtocol = "http"
	DefaultQuantiles       = "0.5,0.95,0.99,0.999"
	DefaultLimit           = "100"
	DefaultTail            = "100"

	// Default graph parameters
	DefaultIncludeIdleEdges   = "false"
	DefaultInjectServiceNodes = "true"
	DefaultBoxBy              = "cluster,namespace,app"
	DefaultAmbientTraffic     = "none"
	DefaultAppenders          = "deadNode,istio,serviceEntry,meshCheck,workloadEntry,health"
	DefaultRateGrpc           = "requests"
	DefaultRateHttp           = "requests"
	DefaultRateTcp            = "sent"

	// Default mesh status parameters
	DefaultIncludeGateways  = "false"
	DefaultIncludeWaypoints = "false"
)

Default values for Kiali API parameters shared across this package.

View Source
const (
	// MeshGraph is the Kiali API path that returns the mesh graph/status.
	AuthInfoEndpoint          = "/api/auth/info"
	MeshGraphEndpoint         = "/api/mesh/graph"
	GraphEndpoint             = "/api/namespaces/graph"
	HealthEndpoint            = "/api/clusters/health"
	IstioConfigEndpoint       = "/api/istio/config"
	IstioObjectEndpoint       = "/api/namespaces/%s/istio/%s/%s/%s/%s"
	IstioObjectCreateEndpoint = "/api/namespaces/%s/istio/%s/%s/%s"
	NamespacesEndpoint        = "/api/namespaces"
	PodDetailsEndpoint        = "/api/namespaces/%s/pods/%s"
	PodsLogsEndpoint          = "/api/namespaces/%s/pods/%s/logs"
	ServicesEndpoint          = "/api/clusters/services"
	ServiceDetailsEndpoint    = "/api/namespaces/%s/services/%s"
	ServiceMetricsEndpoint    = "/api/namespaces/%s/services/%s/metrics"
	AppTracesEndpoint         = "/api/namespaces/%s/apps/%s/traces"
	ServiceTracesEndpoint     = "/api/namespaces/%s/services/%s/traces"
	WorkloadTracesEndpoint    = "/api/namespaces/%s/workloads/%s/traces"
	WorkloadsEndpoint         = "/api/clusters/workloads"
	WorkloadDetailsEndpoint   = "/api/namespaces/%s/workloads/%s"
	WorkloadMetricsEndpoint   = "/api/namespaces/%s/workloads/%s/metrics"
	ValidationsEndpoint       = "/api/istio/validations"
)

Kiali API endpoint paths shared across this package.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppHealth

type AppHealth struct {
	WorkloadStatuses []WorkloadStatus `json:"workloadStatuses"`
	Requests         RequestHealth    `json:"requests"`
}

AppHealth contains health information for an app

type ClustersNamespaceHealth

type ClustersNamespaceHealth struct {
	AppHealth      map[string]NamespaceAppHealth      `json:"namespaceAppHealth"`
	ServiceHealth  map[string]NamespaceServiceHealth  `json:"namespaceServiceHealth"`
	WorkloadHealth map[string]NamespaceWorkloadHealth `json:"namespaceWorkloadHealth"`
}

ClustersNamespaceHealth matches Kiali's response structure

type Config

type Config struct {
	Url                  string `toml:"url"`
	Insecure             bool   `toml:"insecure,omitempty"`
	CertificateAuthority string `toml:"certificate_authority,omitempty"`
}

Config holds Kiali toolset configuration

func (*Config) Validate

func (c *Config) Validate() error

type EntityHealthCounts

type EntityHealthCounts struct {
	Apps      HealthCounts `json:"apps"`
	Services  HealthCounts `json:"services"`
	Workloads HealthCounts `json:"workloads"`
}

EntityHealthCounts contains health counts for all entity types

type GetMeshGraphResponse

type GetMeshGraphResponse struct {
	Graph             json.RawMessage    `json:"graph,omitempty"`
	MeshStatus        json.RawMessage    `json:"mesh_status,omitempty"`
	Namespaces        json.RawMessage    `json:"namespaces,omitempty"`
	MeshHealthSummary *MeshHealthSummary `json:"mesh_health_summary,omitempty"` // Aggregated summary computed from health data
	Errors            map[string]string  `json:"errors,omitempty"`
}

GetMeshGraphResponse contains the combined response from multiple Kiali API endpoints. Note: Health data is fetched from Kiali's health API and used internally to compute MeshHealthSummary, but the raw health data is not included in the response to reduce payload size. MeshHealthSummary contains all the key aggregated metrics needed for mesh health overview.

type HealthCounts

type HealthCounts struct {
	Total     int `json:"total"`
	Healthy   int `json:"healthy"`
	Degraded  int `json:"degraded"`
	Unhealthy int `json:"unhealthy"`
	NotReady  int `json:"notReady"`
}

HealthCounts represents health status counts

type IstioConfigListResponse

type IstioConfigListResponse struct {
	Configs     json.RawMessage `json:"configs"`
	Validations json.RawMessage `json:"validations"`
}

type Kiali

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

func NewKiali

func NewKiali(configProvider api.ExtendedConfigProvider, kubernetes *rest.Config) *Kiali

NewKiali creates a new Kiali instance

func (*Kiali) AppTraces

func (k *Kiali) AppTraces(ctx context.Context, namespace string, app string, queryParams map[string]string) (string, error)

AppTraces returns distributed tracing data for a specific app in a namespace. Parameters:

  • namespace: the namespace containing the app
  • app: the name of the app
  • queryParams: optional query parameters map for filtering traces (e.g., "startMicros", "endMicros", "limit", "minDuration", "tags", "clusterName")

func (*Kiali) GetMeshGraph

func (k *Kiali) GetMeshGraph(ctx context.Context, namespaces []string, queryParams map[string]string) (string, error)

GetMeshGraph fetches multiple Kiali endpoints in parallel and returns a combined response. Each field in the response corresponds to one API call result. - graph: /api/namespaces/graph (optionally filtered by namespaces) - mesh_status: /api/mesh/graph - namespaces: /api/namespaces - mesh_health_summary: computed from /api/clusters/health (health data is fetched but not included in response)

func (*Kiali) Graph

func (k *Kiali) Graph(ctx context.Context, namespaces []string, queryParams map[string]string) (string, error)

Graph calls the Kiali graph API using the provided Authorization header value. `namespaces` may contain zero, one or many namespaces. If empty, the API may return an empty graph or the server default, depending on Kiali configuration.

func (*Kiali) Health

func (k *Kiali) Health(ctx context.Context, namespaces string, queryParams map[string]string) (string, error)

Health returns health status for apps, workloads, and services across namespaces. Parameters:

  • namespaces: comma-separated list of namespaces (optional, if empty returns health for all accessible namespaces)
  • queryParams: optional query parameters map for filtering health data (e.g., "type", "rateInterval", "queryTime")
  • type: health type - "app", "service", or "workload" (default: "app")
  • rateInterval: rate interval for fetching error rate (default: DefaultRateInterval, which is "10m")
  • queryTime: Unix timestamp for the prometheus query (optional)

func (*Kiali) IstioConfig

func (k *Kiali) IstioConfig(ctx context.Context, action string, namespace string, group string, version string, kind string, name string, jsonData string) (string, error)

IstioConfig calls the Kiali Istio config API to get all Istio objects in the mesh. Returns the full YAML resources and additional details about each object.

func (*Kiali) ListNamespaces

func (k *Kiali) ListNamespaces(ctx context.Context) (string, error)

ListNamespaces calls the Kiali namespaces API using the provided Authorization header value. Returns all namespaces in the mesh that the user has access to.

func (*Kiali) MeshStatus

func (k *Kiali) MeshStatus(ctx context.Context) (string, error)

MeshStatus calls the Kiali mesh graph API to get the status of mesh components. This returns information about mesh components like Istio, Kiali, Grafana, Prometheus and their interactions, versions, and health status.

func (*Kiali) PodLogs

func (k *Kiali) PodLogs(ctx context.Context, namespace string, podName string, container string, workload string, duration string, maxLines string) (string, error)

PodLogs returns logs for a specific pod using the Kiali API endpoint. Parameters:

  • namespace: the namespace containing the pod
  • podName: the name of the pod
  • container: container name (optional, will be auto-detected if not provided)
  • workload: workload name (optional)
  • duration: time duration (e.g., "5m", "1h") - optional
  • maxLines: maximum number of lines to return - optional

func (*Kiali) ServiceDetails

func (k *Kiali) ServiceDetails(ctx context.Context, namespace string, service string) (string, error)

ServiceDetails returns the details for a specific service in a namespace.

func (*Kiali) ServiceMetrics

func (k *Kiali) ServiceMetrics(ctx context.Context, namespace string, service string, queryParams map[string]string) (string, error)

ServiceMetrics returns the metrics for a specific service in a namespace. Parameters:

  • namespace: the namespace containing the service
  • service: the name of the service
  • queryParams: optional query parameters map for filtering metrics (e.g., "duration", "step", "rateInterval", "direction", "reporter", "filters[]", "byLabels[]", etc.)

func (*Kiali) ServiceTraces

func (k *Kiali) ServiceTraces(ctx context.Context, namespace string, service string, queryParams map[string]string) (string, error)

ServiceTraces returns distributed tracing data for a specific service in a namespace. Parameters:

  • namespace: the namespace containing the service
  • service: the name of the service
  • queryParams: optional query parameters map for filtering traces (e.g., "startMicros", "endMicros", "limit", "minDuration", "tags", "clusterName")

func (*Kiali) ServicesList

func (k *Kiali) ServicesList(ctx context.Context, namespaces string) (string, error)

ServicesList returns the list of services across specified namespaces.

func (*Kiali) TraceDetails

func (k *Kiali) TraceDetails(ctx context.Context, traceId string) (string, error)

TraceDetails returns detailed information for a specific trace by its ID. Parameters:

  • traceId: the unique identifier of the trace

func (*Kiali) ValidationsList

func (k *Kiali) ValidationsList(ctx context.Context, namespaces []string) (string, error)

ValidationsList calls the Kiali validations API using the provided Authorization header value. `namespaces` may contain zero, one or many namespaces. If empty, returns validations from all namespaces.

func (*Kiali) WorkloadDetails

func (k *Kiali) WorkloadDetails(ctx context.Context, namespace string, workload string) (string, error)

WorkloadDetails returns the details for a specific workload in a namespace.

func (*Kiali) WorkloadLogs

func (k *Kiali) WorkloadLogs(ctx context.Context, namespace string, workload string, container string, duration string, maxLines string) (string, error)

WorkloadLogs returns logs for a specific workload's pods in a namespace. This method first gets workload details to find associated pods, then retrieves logs for each pod. Parameters:

  • namespace: the namespace containing the workload
  • workload: the name of the workload
  • container: container name (optional, will be auto-detected if not provided)
  • duration: time duration (e.g., "5m", "1h") - optional
  • maxLines: maximum number of lines to return - optional

func (*Kiali) WorkloadMetrics

func (k *Kiali) WorkloadMetrics(ctx context.Context, namespace string, workload string, queryParams map[string]string) (string, error)

WorkloadMetrics returns the metrics for a specific workload in a namespace. Parameters:

  • namespace: the namespace containing the workload
  • workload: the name of the workload
  • queryParams: optional query parameters map for filtering metrics (e.g., "duration", "step", "rateInterval", "direction", "reporter", "filters[]", "byLabels[]", etc.)

func (*Kiali) WorkloadTraces

func (k *Kiali) WorkloadTraces(ctx context.Context, namespace string, workload string, queryParams map[string]string) (string, error)

WorkloadTraces returns distributed tracing data for a specific workload in a namespace. Parameters:

  • namespace: the namespace containing the workload
  • workload: the name of the workload
  • queryParams: optional query parameters map for filtering traces (e.g., "startMicros", "endMicros", "limit", "minDuration", "tags", "clusterName")

func (*Kiali) WorkloadsList

func (k *Kiali) WorkloadsList(ctx context.Context, namespaces string) (string, error)

WorkloadsList returns the list of workloads across specified namespaces.

type MeshHealthSummary

type MeshHealthSummary struct {
	OverallStatus    string                      `json:"overallStatus"` // HEALTHY, DEGRADED, UNHEALTHY
	Availability     float64                     `json:"availability"`  // Percentage 0-100
	TotalErrorRate   float64                     `json:"totalErrorRate"`
	NamespaceCount   int                         `json:"namespaceCount"`
	EntityCounts     EntityHealthCounts          `json:"entityCounts"`
	NamespaceSummary map[string]NamespaceSummary `json:"namespaceSummary"`
	TopUnhealthy     []UnhealthyEntity           `json:"topUnhealthy,omitempty"`
	Timestamp        string                      `json:"timestamp"`
	RateInterval     string                      `json:"rateInterval"`
}

MeshHealthSummary represents aggregated health across the mesh

type NamespaceAppHealth

type NamespaceAppHealth map[string]AppHealth

NamespaceAppHealth is a map of app name to health

type NamespaceServiceHealth

type NamespaceServiceHealth map[string]ServiceHealth

NamespaceServiceHealth is a map of service name to health

type NamespaceSummary

type NamespaceSummary struct {
	Status       string       `json:"status"`
	Availability float64      `json:"availability"`
	ErrorRate    float64      `json:"errorRate"`
	Apps         HealthCounts `json:"apps"`
	Services     HealthCounts `json:"services"`
	Workloads    HealthCounts `json:"workloads"`
}

NamespaceSummary contains health summary for a namespace

type NamespaceWorkloadHealth

type NamespaceWorkloadHealth map[string]WorkloadHealth

NamespaceWorkloadHealth is a map of workload name to health

type RequestHealth

type RequestHealth struct {
	Inbound           map[string]map[string]float64 `json:"inbound"`
	Outbound          map[string]map[string]float64 `json:"outbound"`
	HealthAnnotations map[string]string             `json:"healthAnnotations"`
}

RequestHealth holds request health metrics

type ServiceHealth

type ServiceHealth struct {
	Requests RequestHealth `json:"requests"`
}

ServiceHealth contains health information for a service

type UnhealthyEntity

type UnhealthyEntity struct {
	Type      string  `json:"type"` // app, service, workload
	Namespace string  `json:"namespace"`
	Name      string  `json:"name"`
	Status    string  `json:"status"`
	Issue     string  `json:"issue"`
	ErrorRate float64 `json:"errorRate,omitempty"`
}

UnhealthyEntity represents an unhealthy entity

type WorkloadHealth

type WorkloadHealth struct {
	WorkloadStatus *WorkloadStatus `json:"workloadStatus"`
	Requests       RequestHealth   `json:"requests"`
}

WorkloadHealth contains health information for a workload

type WorkloadStatus

type WorkloadStatus struct {
	Name              string `json:"name"`
	DesiredReplicas   int32  `json:"desiredReplicas"`
	CurrentReplicas   int32  `json:"currentReplicas"`
	AvailableReplicas int32  `json:"availableReplicas"`
	SyncedProxies     int32  `json:"syncedProxies"`
}

WorkloadStatus represents workload replica status

Jump to

Keyboard shortcuts

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