Skip to content
Open
Changes from 2 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
12 changes: 9 additions & 3 deletions tools/loki.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ type ListLokiLabelValuesParams struct {
LabelName string `json:"labelName" jsonschema:"required,description=The name of the label to retrieve values for (e.g. 'app'\\, 'env'\\, 'pod')"`
StartRFC3339 string `json:"startRfc3339,omitempty" jsonschema:"description=Optionally\\, the start time of the query in RFC3339 format (defaults to 1 hour ago)"`
EndRFC3339 string `json:"endRfc3339,omitempty" jsonschema:"description=Optionally\\, the end time of the query in RFC3339 format (defaults to now)"`
Matchers string `json:"matchers"`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @rahulvijil,

thanks for your contribution. Would you mind adding two things to this matchers prop:

  1. omitempty
  2. A description that would help the LLM understand what this parameter is used for.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the description

}

// listLokiLabelValues lists all values for a specific label in a Loki datasource
Expand All @@ -265,16 +266,21 @@ func listLokiLabelValues(ctx context.Context, args ListLokiLabelValuesParams) ([
return nil, fmt.Errorf("creating Loki client: %w", err)
}

// Use the client's fetchData method
urlPath := fmt.Sprintf("/loki/api/v1/label/%s/values", args.LabelName)

// Manually include matchers in query string if provided
if args.Matchers != "" {
encoded := url.QueryEscape(args.Matchers)
urlPath = fmt.Sprintf("%s?query=%s", urlPath, encoded)
}

// Call the original fetchData with start/end as before
result, err := client.fetchData(ctx, urlPath, args.StartRFC3339, args.EndRFC3339)
if err != nil {
return nil, err
return nil, fmt.Errorf("fetching label values: %w", err)
}

if len(result) == 0 {
Comment on lines 295 to 306

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these changes needed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not actually, I will revert fmt.Errorf("fetching label values: %w", err) to err

// Return empty slice instead of nil
return []string{}, nil
}

Expand Down