Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ In case multi-cluster support is enabled (default) and you have access to multip
- `graphType` (`string`) - Type of graph to return: 'versionedApp', 'app', 'service', 'workload', 'mesh'. Default: 'versionedApp'
- `namespace` (`string`) - Optional single namespace to include in the graph (alternative to namespaces)
- `namespaces` (`string`) - Optional comma-separated list of namespaces to include in the graph
- `rateInterval` (`string`) - Rate interval for fetching (e.g., '10m', '5m', '1h'). Default: '60s'
- `rateInterval` (`string`) - Rate interval for fetching (e.g., '10m', '5m', '1h'). Default: '10m'

- **kiali_manage_istio_config** - Manages Istio configuration objects (Gateways, VirtualServices, etc.). Can list (objects and validations), get, create, patch, or delete objects
- `action` (`string`) **(required)** - Action to perform: list, get, create, patch, or delete
Expand All @@ -374,7 +374,7 @@ In case multi-cluster support is enabled (default) and you have access to multip
- `duration` (`string`) - Time range to get metrics for (optional string - if provided, gets metrics; if empty, get default 1800s).
- `namespace` (`string`) **(required)** - Namespace to get resources from
- `quantiles` (`string`) - Comma-separated list of quantiles for histogram metrics (e.g., '0.5,0.95,0.99'). Optional
- `rateInterval` (`string`) - Rate interval for metrics (e.g., '1m', '5m'). Optional, defaults to '1m'
- `rateInterval` (`string`) - Rate interval for metrics (e.g., '1m', '5m'). Optional, defaults to '10m'
- `reporter` (`string`) - Metrics reporter: 'source', 'destination', or 'both'. Optional, defaults to 'source'
- `requestProtocol` (`string`) - Filter by request protocol (e.g., 'http', 'grpc', 'tcp'). Optional
- `resource_name` (`string`) **(required)** - Name of the resource to get details for (optional string - if provided, gets details; if empty, lists all).
Expand Down
8 changes: 8 additions & 0 deletions pkg/kiali/defaults.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package kiali

// Default values for Kiali API parameters shared across this package.
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"
)
28 changes: 19 additions & 9 deletions pkg/kiali/get_mesh_graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,24 @@ import (
"sync"
)

// 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 GetMeshGraphResponse struct {
Graph json.RawMessage `json:"graph,omitempty"`
Health json.RawMessage `json:"health,omitempty"`
MeshStatus json.RawMessage `json:"mesh_status,omitempty"`
Namespaces json.RawMessage `json:"namespaces,omitempty"`
Errors map[string]string `json:"errors,omitempty"`
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"`
}

// 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)
// - health: /api/clusters/health (optionally filtered by namespaces and queryParams)
// - status(mesh):/api/mesh/graph
// - 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 (k *Kiali) GetMeshGraph(ctx context.Context, namespaces []string, queryParams map[string]string) (string, error) {
cleaned := make([]string, 0, len(namespaces))
for _, ns := range namespaces {
Expand Down Expand Up @@ -51,7 +55,7 @@ func (k *Kiali) GetMeshGraph(ctx context.Context, namespaces []string, queryPara
resp.Graph = data
}()

// Health
// Health - compute MeshHealthSummary inside the goroutine
go func() {
defer wg.Done()
data, err := k.getHealth(ctx, cleaned, queryParams)
Expand All @@ -61,7 +65,13 @@ func (k *Kiali) GetMeshGraph(ctx context.Context, namespaces []string, queryPara
errorsMu.Unlock()
return
}
resp.Health = data
// Compute mesh health summary from health data
if len(data) > 0 {
summary := computeMeshHealthSummary(data, cleaned, queryParams)
if summary != nil {
resp.MeshHealthSummary = summary
}
}
}()

// Mesh status
Expand Down
2 changes: 1 addition & 1 deletion pkg/kiali/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (k *Kiali) Graph(ctx context.Context, namespaces []string, queryParams map[
q := u.Query()
// Static graph parameters per requirements
// Defaults with optional overrides via queryParams
duration := "60s"
duration := DefaultRateInterval
graphType := "versionedApp"
if v, ok := queryParams["rateInterval"]; ok && strings.TrimSpace(v) != "" {
duration = strings.TrimSpace(v)
Expand Down
10 changes: 7 additions & 3 deletions pkg/kiali/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
// - 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: "1m")
// - rateInterval: rate interval for fetching error rate (default: DefaultRateInterval, which is "10m")
// - queryTime: Unix timestamp for the prometheus query (optional)
func (k *Kiali) Health(ctx context.Context, namespaces string, queryParams map[string]string) (string, error) {
// Build query parameters
Expand All @@ -34,14 +34,18 @@ func (k *Kiali) Health(ctx context.Context, namespaces string, queryParams map[s
}
}

// Ensure health "type" aligns with graphType (versionedApp -> app)
// Ensure health "type" aligns with graphType (versionedApp -> app, mesh -> app)
// The Kiali health API only accepts "app", "service", or "workload" as valid types
healthType := "app"
if gt, ok := queryParams["graphType"]; ok && strings.TrimSpace(gt) != "" {
v := strings.TrimSpace(gt)
if strings.EqualFold(v, "versionedApp") {
healthType = "app"
} else {
} else if v == "workload" || v == "service" {
healthType = v
} else {
// For "mesh" or any other graphType, default to "app"
healthType = "app"
}
}
q.Set("type", healthType)
Expand Down
Loading