Documentation
¶
Index ¶
- Constants
- Variables
- func ExecuteInstantQueryHandler(ctx context.Context, promClient prometheus.Loader, input InstantQueryInput) *resultutil.Result
- func ExecuteRangeQueryHandler(ctx context.Context, promClient prometheus.Loader, input RangeQueryInput) *resultutil.Result
- func GetAlertsHandler(ctx context.Context, amClient alertmanager.Loader, input AlertsInput) *resultutil.Result
- func GetBoolPtr(params map[string]any, key string) *bool
- func GetLabelNamesHandler(ctx context.Context, promClient prometheus.Loader, input LabelNamesInput) *resultutil.Result
- func GetLabelValuesHandler(ctx context.Context, promClient prometheus.Loader, input LabelValuesInput) *resultutil.Result
- func GetSeriesHandler(ctx context.Context, promClient prometheus.Loader, input SeriesInput) *resultutil.Result
- func GetSilencesHandler(ctx context.Context, amClient alertmanager.Loader, input SilencesInput) *resultutil.Result
- func GetString(params map[string]any, key, defaultValue string) string
- func ListMetricsHandler(ctx context.Context, promClient prometheus.Loader, input ListMetricsInput) *resultutil.Result
- type Alert
- type AlertStatus
- type AlertsInput
- type AlertsOutput
- type InstantQueryInput
- type InstantQueryOutput
- type InstantResult
- type LabelNamesInput
- type LabelNamesOutput
- type LabelValuesInput
- type LabelValuesOutput
- type ListMetricsInput
- type ListMetricsOutput
- type Matcher
- type ParamDef
- type ParamType
- type RangeQueryInput
- type RangeQueryOutput
- type SeriesInput
- type SeriesOutput
- type SeriesResult
- type Silence
- type SilenceStatus
- type SilencesInput
- type SilencesOutput
- type ToolDef
Constants ¶
const ( ServerPrompt = `` /* 2347-byte string literal not displayed */ ListMetricsPrompt = `` /* 843-byte string literal not displayed */ ExecuteInstantQueryPrompt = `` /* 407-byte string literal not displayed */ ExecuteRangeQueryPrompt = `` /* 593-byte string literal not displayed */ GetLabelNamesPrompt = `` /* 310-byte string literal not displayed */ GetLabelValuesPrompt = `` /* 314-byte string literal not displayed */ GetSeriesPrompt = `` /* 386-byte string literal not displayed */ GetAlertsPrompt = `` /* 1097-byte string literal not displayed */ GetSilencesPrompt = `` /* 430-byte string literal not displayed */ )
Variables ¶
var ( ListMetrics = ToolDef{ Name: "list_metrics", Description: ListMetricsPrompt, Title: "List Available Metrics", Params: []ParamDef{ { Name: "name_regex", Type: ParamTypeString, Description: "Regex pattern to filter metric names (e.g., 'http_.*', 'node_.*', 'kube.*'). This parameter is required. Don't pass in blanket regex.", Required: true, }, }, ReadOnly: true, Destructive: false, Idempotent: true, OpenWorld: true, } ExecuteInstantQuery = ToolDef{ Name: "execute_instant_query", Description: ExecuteInstantQueryPrompt, Title: "Execute Instant Query", ReadOnly: true, Destructive: false, Idempotent: true, OpenWorld: true, Params: []ParamDef{ { Name: "query", Type: ParamTypeString, Description: "PromQL query string using metric names verified via list_metrics", Required: true, }, { Name: "time", Type: ParamTypeString, Description: "Evaluation time as RFC3339 or Unix timestamp. Omit or use 'NOW' for current time.", Required: false, }, }, } ExecuteRangeQuery = ToolDef{ Name: "execute_range_query", Description: ExecuteRangeQueryPrompt, Title: "Execute Range Query", ReadOnly: true, Destructive: false, Idempotent: true, OpenWorld: true, Params: []ParamDef{ { Name: "query", Type: ParamTypeString, Description: "PromQL query string using metric names verified via list_metrics", Required: true, }, { Name: "step", Type: ParamTypeString, Description: "Query resolution step width (e.g., '15s', '1m', '1h'). Choose based on time range: shorter ranges use smaller steps.", Required: true, Pattern: `^\d+[smhdwy]$`, }, { Name: "start", Type: ParamTypeString, Description: "Start time as RFC3339 or Unix timestamp (optional)", Required: false, }, { Name: "end", Type: ParamTypeString, Description: "End time as RFC3339 or Unix timestamp (optional). Use `NOW` for current time.", Required: false, }, { Name: "duration", Type: ParamTypeString, Description: "Duration to look back from now (e.g., '1h', '30m', '1d', '2w') (optional)", Required: false, Pattern: `^\d+[smhdwy]$`, }, }, } GetLabelNames = ToolDef{ Name: "get_label_names", Description: GetLabelNamesPrompt, Title: "Get Label Names", ReadOnly: true, Destructive: false, Idempotent: true, OpenWorld: true, Params: []ParamDef{ { Name: "metric", Type: ParamTypeString, Description: "Metric name (from list_metrics) to get label names for. Leave empty for all metrics.", Required: false, }, { Name: "start", Type: ParamTypeString, Description: "Start time for label discovery as RFC3339 or Unix timestamp (optional, defaults to 1 hour ago)", Required: false, }, { Name: "end", Type: ParamTypeString, Description: "End time for label discovery as RFC3339 or Unix timestamp (optional, defaults to now)", Required: false, }, }, } GetLabelValues = ToolDef{ Name: "get_label_values", Description: GetLabelValuesPrompt, Title: "Get Label Values", ReadOnly: true, Destructive: false, Idempotent: true, OpenWorld: true, Params: []ParamDef{ { Name: "label", Type: ParamTypeString, Description: "Label name (from get_label_names) to get values for", Required: true, }, { Name: "metric", Type: ParamTypeString, Description: "Metric name (from list_metrics) to scope the label values to. Leave empty for all metrics.", Required: false, }, { Name: "start", Type: ParamTypeString, Description: "Start time for label value discovery as RFC3339 or Unix timestamp (optional, defaults to 1 hour ago)", Required: false, }, { Name: "end", Type: ParamTypeString, Description: "End time for label value discovery as RFC3339 or Unix timestamp (optional, defaults to now)", Required: false, }, }, } GetSeries = ToolDef{ Name: "get_series", Description: GetSeriesPrompt, Title: "Get Series", ReadOnly: true, Destructive: false, Idempotent: true, OpenWorld: true, Params: []ParamDef{ { Name: "matches", Type: ParamTypeString, Description: "PromQL series selector using metric names from list_metrics", Required: true, }, { Name: "start", Type: ParamTypeString, Description: "Start time for series discovery as RFC3339 or Unix timestamp (optional, defaults to 1 hour ago)", Required: false, }, { Name: "end", Type: ParamTypeString, Description: "End time for series discovery as RFC3339 or Unix timestamp (optional, defaults to now)", Required: false, }, }, } GetAlerts = ToolDef{ Name: "get_alerts", Description: GetAlertsPrompt, Title: "Get Alerts", ReadOnly: true, Destructive: false, Idempotent: true, OpenWorld: true, Params: []ParamDef{ { Name: "active", Type: ParamTypeBoolean, Description: "Filter for active alerts only (true/false, optional)", Required: false, }, { Name: "silenced", Type: ParamTypeBoolean, Description: "Filter for silenced alerts only (true/false, optional)", Required: false, }, { Name: "inhibited", Type: ParamTypeBoolean, Description: "Filter for inhibited alerts only (true/false, optional)", Required: false, }, { Name: "unprocessed", Type: ParamTypeBoolean, Description: "Filter for unprocessed alerts only (true/false, optional)", Required: false, }, { Name: "filter", Type: ParamTypeString, Description: "Label matchers to filter alerts (e.g., 'alertname=HighCPU', optional)", Required: false, }, { Name: "receiver", Type: ParamTypeString, Description: "Receiver name to filter alerts (optional)", Required: false, }, }, } GetSilences = ToolDef{ Name: "get_silences", Description: GetSilencesPrompt, Title: "Get Silences", ReadOnly: true, Destructive: false, Idempotent: true, OpenWorld: true, Params: []ParamDef{ { Name: "filter", Type: ParamTypeString, Description: "Label matchers to filter silences (e.g., 'alertname=HighCPU', optional)", Required: false, }, }, } )
All tool definitions as a single source of truth
Functions ¶
func ExecuteInstantQueryHandler ¶
func ExecuteInstantQueryHandler(ctx context.Context, promClient prometheus.Loader, input InstantQueryInput) *resultutil.Result
ExecuteInstantQueryHandler handles the execution of Prometheus instant queries.
func ExecuteRangeQueryHandler ¶
func ExecuteRangeQueryHandler(ctx context.Context, promClient prometheus.Loader, input RangeQueryInput) *resultutil.Result
ExecuteRangeQueryHandler handles the execution of Prometheus range queries.
func GetAlertsHandler ¶
func GetAlertsHandler(ctx context.Context, amClient alertmanager.Loader, input AlertsInput) *resultutil.Result
GetAlertsHandler handles the retrieval of alerts from Alertmanager.
func GetBoolPtr ¶
GetBoolPtr is a helper to extract an optional boolean parameter as a pointer
func GetLabelNamesHandler ¶
func GetLabelNamesHandler(ctx context.Context, promClient prometheus.Loader, input LabelNamesInput) *resultutil.Result
GetLabelNamesHandler handles the retrieval of label names.
func GetLabelValuesHandler ¶
func GetLabelValuesHandler(ctx context.Context, promClient prometheus.Loader, input LabelValuesInput) *resultutil.Result
GetLabelValuesHandler handles the retrieval of label values.
func GetSeriesHandler ¶
func GetSeriesHandler(ctx context.Context, promClient prometheus.Loader, input SeriesInput) *resultutil.Result
GetSeriesHandler handles the retrieval of time series.
func GetSilencesHandler ¶
func GetSilencesHandler(ctx context.Context, amClient alertmanager.Loader, input SilencesInput) *resultutil.Result
GetSilencesHandler handles the retrieval of silences from Alertmanager.
func ListMetricsHandler ¶
func ListMetricsHandler(ctx context.Context, promClient prometheus.Loader, input ListMetricsInput) *resultutil.Result
ListMetricsHandler handles the listing of available Prometheus metrics.
Types ¶
type Alert ¶
type Alert struct {
Labels map[string]string `json:"labels" jsonschema:"description=Labels of the alert"`
Annotations map[string]string `json:"annotations" jsonschema:"description=Annotations of the alert"`
StartsAt string `json:"startsAt" jsonschema:"description=Start time of the alert"`
EndsAt string `json:"endsAt,omitempty" jsonschema:"description=End time of the alert (if resolved)"`
Status AlertStatus `json:"status" jsonschema:"description=Current status of the alert"`
}
Alert represents a single alert from Alertmanager.
type AlertStatus ¶
type AlertStatus struct {
State string `json:"state" jsonschema:"description=State of the alert (active, suppressed, unprocessed)"`
SilencedBy []string `json:"silencedBy,omitempty" jsonschema:"description=List of silences that are silencing this alert"`
InhibitedBy []string `json:"inhibitedBy,omitempty" jsonschema:"description=List of alerts that are inhibiting this alert"`
}
AlertStatus represents the status of an alert.
type AlertsInput ¶
type AlertsInput struct {
Active *bool `json:"active,omitempty"`
Silenced *bool `json:"silenced,omitempty"`
Inhibited *bool `json:"inhibited,omitempty"`
Unprocessed *bool `json:"unprocessed,omitempty"`
Filter string `json:"filter,omitempty"`
Receiver string `json:"receiver,omitempty"`
}
AlertsInput defines the input parameters for GetAlertsHandler.
func BuildAlertsInput ¶
func BuildAlertsInput(args map[string]any) AlertsInput
type AlertsOutput ¶
type AlertsOutput struct {
Alerts []Alert `json:"alerts" jsonschema:"description=List of alerts from Alertmanager"`
}
AlertsOutput defines the output schema for the get_alerts tool.
type InstantQueryInput ¶
InstantQueryInput defines the input parameters for ExecuteInstantQueryHandler.
func BuildInstantQueryInput ¶
func BuildInstantQueryInput(args map[string]any) InstantQueryInput
type InstantQueryOutput ¶
type InstantQueryOutput struct {
ResultType string `json:"resultType" jsonschema:"description=The type of result returned (e.g. vector, scalar, string)"`
Result []InstantResult `json:"result" jsonschema:"description=The query results as an array of instant values"`
Warnings []string `json:"warnings,omitempty" jsonschema:"description=Any warnings generated during query execution"`
}
InstantQueryOutput defines the output schema for the execute_instant_query tool.
type InstantResult ¶
type InstantResult struct {
Metric map[string]string `json:"metric" jsonschema:"description=The metric labels"`
Value []any `json:"value" jsonschema:"description=[timestamp, value] pair for the instant query"`
}
InstantResult represents a single instant query result.
type LabelNamesInput ¶
type LabelNamesInput struct {
Metric string `json:"metric,omitempty"`
Start string `json:"start,omitempty"`
End string `json:"end,omitempty"`
}
LabelNamesInput defines the input parameters for GetLabelNamesHandler.
func BuildLabelNamesInput ¶
func BuildLabelNamesInput(args map[string]any) LabelNamesInput
type LabelNamesOutput ¶
type LabelNamesOutput struct {
Labels []string `json:"labels" jsonschema:"description=List of label names available for the specified metric or all metrics"`
}
LabelNamesOutput defines the output schema for the get_label_names tool.
type LabelValuesInput ¶
type LabelValuesInput struct {
Label string `json:"label"`
Metric string `json:"metric,omitempty"`
Start string `json:"start,omitempty"`
End string `json:"end,omitempty"`
}
LabelValuesInput defines the input parameters for GetLabelValuesHandler.
func BuildLabelValuesInput ¶
func BuildLabelValuesInput(args map[string]any) LabelValuesInput
type LabelValuesOutput ¶
type LabelValuesOutput struct {
Values []string `json:"values" jsonschema:"description=List of unique values for the specified label"`
}
LabelValuesOutput defines the output schema for the get_label_values tool.
type ListMetricsInput ¶
type ListMetricsInput struct {
NameRegex string `json:"name_regex"`
}
ListMetricsInput defines the input parameters for ListMetricsHandler.
func BuildListMetricsInput ¶
func BuildListMetricsInput(args map[string]any) ListMetricsInput
type ListMetricsOutput ¶
type ListMetricsOutput struct {
Metrics []string `json:"metrics" jsonschema:"description=List of all available metric names"`
}
ListMetricsOutput defines the output schema for the list_metrics tool.
type Matcher ¶
type Matcher struct {
Name string `json:"name" jsonschema:"description=Label name to match"`
Value string `json:"value" jsonschema:"description=Label value to match"`
IsRegex bool `json:"isRegex" jsonschema:"description=Whether the match is a regex match"`
IsEqual bool `json:"isEqual" jsonschema:"description=Whether the match is an equality match (true) or inequality match (false)"`
}
Matcher represents a label matcher for a silence.
type RangeQueryInput ¶
type RangeQueryInput struct {
Query string `json:"query"`
Step string `json:"step"`
Start string `json:"start,omitempty"`
End string `json:"end,omitempty"`
Duration string `json:"duration,omitempty"`
}
RangeQueryInput defines the input parameters for ExecuteRangeQueryHandler.
func BuildRangeQueryInput ¶
func BuildRangeQueryInput(args map[string]any) RangeQueryInput
type RangeQueryOutput ¶
type RangeQueryOutput struct {
ResultType string `json:"resultType" jsonschema:"description=The type of result returned: matrix or vector or scalar"`
Result []SeriesResult `json:"result" jsonschema:"description=The query results as an array of time series"`
Warnings []string `json:"warnings,omitempty" jsonschema:"description=Any warnings generated during query execution"`
}
RangeQueryOutput defines the output schema for the execute_range_query tool.
type SeriesInput ¶
type SeriesInput struct {
Matches string `json:"matches"`
Start string `json:"start,omitempty"`
End string `json:"end,omitempty"`
}
SeriesInput defines the input parameters for GetSeriesHandler.
func BuildSeriesInput ¶
func BuildSeriesInput(args map[string]any) SeriesInput
type SeriesOutput ¶
type SeriesOutput struct {
Series []map[string]string `` /* 127-byte string literal not displayed */
Cardinality int `json:"cardinality" jsonschema:"description=Total number of series matching the selector"`
}
SeriesOutput defines the output schema for the get_series tool.
type SeriesResult ¶
type SeriesResult struct {
Metric map[string]string `json:"metric" jsonschema:"description=The metric labels"`
Values [][]any `json:"values" jsonschema:"description=Array of [timestamp, value] pairs"`
}
SeriesResult represents a single time series result from a range query.
type Silence ¶
type Silence struct {
ID string `json:"id" jsonschema:"description=Unique identifier of the silence"`
Status SilenceStatus `json:"status" jsonschema:"description=Current status of the silence"`
Matchers []Matcher `json:"matchers" jsonschema:"description=Label matchers for this silence"`
StartsAt string `json:"startsAt" jsonschema:"description=Start time of the silence"`
EndsAt string `json:"endsAt" jsonschema:"description=End time of the silence"`
CreatedBy string `json:"createdBy" jsonschema:"description=Creator of the silence"`
Comment string `json:"comment" jsonschema:"description=Comment describing the silence"`
}
Silence represents a single silence from Alertmanager.
type SilenceStatus ¶
type SilenceStatus struct {
State string `json:"state" jsonschema:"description=State of the silence (active, pending, expired)"`
}
SilenceStatus represents the status of a silence.
type SilencesInput ¶
type SilencesInput struct {
Filter string `json:"filter,omitempty"`
}
SilencesInput defines the input parameters for GetSilencesHandler.
func BuildSilencesInput ¶
func BuildSilencesInput(args map[string]any) SilencesInput
type SilencesOutput ¶
type SilencesOutput struct {
Silences []Silence `json:"silences" jsonschema:"description=List of silences from Alertmanager"`
}
SilencesOutput defines the output schema for the get_silences tool.
type ToolDef ¶
type ToolDef struct {
Name string
Description string
Title string
Params []ParamDef
ReadOnly bool
Destructive bool
Idempotent bool
OpenWorld bool
}
ToolDef defines a tool that can be converted to different formats (MCP, Toolset, etc.)
func (ToolDef) ToServerTool ¶
func (d ToolDef) ToServerTool(handler func(api.ToolHandlerParams) (*api.ToolCallResult, error)) api.ServerTool
ToServerTool converts a ToolDef to an api.ServerTool