diff --git a/go/core/internal/httpserver/handlers/substrate.go b/go/core/internal/httpserver/handlers/substrate.go index 84872f0b85..dddb2e6b9c 100644 --- a/go/core/internal/httpserver/handlers/substrate.go +++ b/go/core/internal/httpserver/handlers/substrate.go @@ -13,6 +13,7 @@ import ( "github.com/kagent-dev/kagent/go/core/internal/httpserver/errors" "github.com/kagent-dev/kagent/go/core/pkg/auth" "github.com/kagent-dev/kagent/go/core/pkg/sandboxbackend/substrate" + "k8s.io/apimachinery/pkg/api/meta" utilvalidation "k8s.io/apimachinery/pkg/util/validation" "sigs.k8s.io/controller-runtime/pkg/client" ctrllog "sigs.k8s.io/controller-runtime/pkg/log" @@ -110,10 +111,16 @@ func (h *SubstrateHandler) listSubstrateCRs(ctx context.Context, namespace strin wpList := &atev1alpha1.WorkerPoolList{} if err := h.KubeClient.List(ctx, wpList, listOpts...); err != nil { + if meta.IsNoMatchError(err) { + return nil, nil, nil + } return nil, nil, err } tmplList := &atev1alpha1.ActorTemplateList{} if err := h.KubeClient.List(ctx, tmplList, listOpts...); err != nil { + if meta.IsNoMatchError(err) { + return nil, nil, nil + } return nil, nil, err } diff --git a/helm/agents/observability/templates/agent.yaml b/helm/agents/observability/templates/agent.yaml index 8d7a05a101..f602ad71e3 100644 --- a/helm/agents/observability/templates/agent.yaml +++ b/helm/agents/observability/templates/agent.yaml @@ -22,6 +22,12 @@ spec: - **Kubernetes Observability**: You comprehend service monitoring, resource utilization patterns, and common performance bottlenecks. - **Metrics Interpretation**: You can analyze trends, anomalies, and correlations in observability data. - **Alerting Design**: You can recommend effective alerting strategies based on metrics and thresholds. + {{- with .Values.grafana }}{{- if .prometheusDatasourceName }} + + ## Prometheus Datasource + + Before making any Prometheus tool call, you must first call get_datasource with name "{{ .prometheusDatasourceName }}" to resolve the datasource UID. Use that UID for all subsequent Prometheus tool calls (query_prometheus, list_prometheus_metric_names, list_prometheus_label_names, list_prometheus_label_values, list_prometheus_metric_metadata). + {{- end }}{{- end }} {{ `{{include "builtin/kubernetes-context"}}` }} @@ -94,8 +100,7 @@ spec: - get_sift_analysis - get_oncall_shift - get_incident - - get_datasource_by_uid - - get_datasource_by_name + - get_datasource - get_dashboard_panel_queries - get_dashboard_by_uid - get_current_oncall_users diff --git a/helm/agents/observability/values.yaml b/helm/agents/observability/values.yaml index 1cfd5eeaf3..871a6ce4cb 100644 --- a/helm/agents/observability/values.yaml +++ b/helm/agents/observability/values.yaml @@ -15,3 +15,8 @@ resources: memory: 1Gi compaction: {} + +# -- Optional Grafana datasource name for Prometheus (e.g. "Prometheus"). When set, the agent +# uses this datasource name for all Prometheus queries instead of discovering it at runtime. +grafana: + prometheusDatasourceName: ""