Skip to content

feat: add grafana investigation components#3907

Open
WashingtonKK wants to merge 25 commits intosuperplanehq:mainfrom
WashingtonKK:feat/grafana-investigation
Open

feat: add grafana investigation components#3907
WashingtonKK wants to merge 25 commits intosuperplanehq:mainfrom
WashingtonKK:feat/grafana-investigation

Conversation

@WashingtonKK
Copy link
Copy Markdown
Collaborator

@WashingtonKK WashingtonKK commented Apr 2, 2026

Closes: #3888

This expands the grafana integration by adding the following components:

  • grafana.listDataSources
  • grafana.getDataSource
  • grafana.queryLogs
  • grafana.queryTraces

Demo Video


Note

Medium Risk
Adds new Grafana workflow components and expands Grafana API interactions, plus renames QueryDataSource config (dataSourceUiddataSource) and removes the timezone field, which could break existing saved workflows or affect time-range interpretation.

Overview
Expands the Grafana integration with new workflow actions: grafana.listDataSources, grafana.getDataSource, grafana.queryLogs (LogQL/Loki), and grafana.queryTraces (TraceQL/Tempo), including example payloads and updated docs.

Updates the backend client to fetch a single data source (GetDataSource) and enriches the DataSource model (id/type/url/default), wires the new components into the integration registry, and adds validation/tests (including Tempo-type enforcement for trace queries).

Refactors grafana.queryDataSource configuration by renaming dataSourceUid to dataSource and removing the timezone field; time parsing now treats offset-less datetime values as UTC and supports additional timestamp formats.

Updates the workflow UI mappers to support the new components, align with the renamed dataSource field, and add safer Grafana query-response parsing utilities to avoid crashes on sparse/unknown outputs.

Reviewed by Cursor Bugbot for commit 2e6e67a. Bugbot is set up for automated code reviews on this repo. Configure here.

Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
@superplanehq-integration
Copy link
Copy Markdown

👋 Commands for maintainers:

  • /sp start - Start an ephemeral machine (takes ~30s)
  • /sp stop - Stop a running machine (auto-executed on pr close)

Comment thread web_src/src/pages/workflowv2/mappers/grafana/query_traces.ts Outdated
Comment thread pkg/integrations/grafana/query_logs.go
- Eliminated the timezone field from QueryDataSource, QueryLogs, and QueryTraces specifications and configurations.
- Updated related documentation to clarify that datetime values are interpreted as UTC by default.
- Adjusted tests to reflect the removal of the timezone requirement, ensuring proper handling of datetime picker values without explicit offsets.

This change simplifies the configuration and usage of Grafana query components.

Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
- Updated QueryLogs and QueryTraces components to support expr-golang values for time range specifications, allowing for more dynamic query configurations.
- Introduced new tests to validate the use of expression placeholders for time fields in query configurations.
- Added a new GetDataSourceNodeMetadata structure to encapsulate data source metadata, improving data handling in the GetDataSource integration.

This change enhances the flexibility and usability of Grafana query components, making it easier for users to define time ranges in their queries.

Signed-off-by: [Your Name] <your.email@example.com>
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Comment thread web_src/src/pages/workflowv2/mappers/grafana/get_data_source.ts Outdated
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Comment thread web_src/src/pages/workflowv2/mappers/grafana/query_logs.ts
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Comment thread pkg/integrations/grafana/query_logs.go
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
@AleksandarCole
Copy link
Copy Markdown
Collaborator

Let's just keep:

  • grafana.queryLogs
  • grafana.queryTraces

Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Comment thread pkg/integrations/grafana/grafana.go Outdated
This commit deletes the GetDataSource and ListDataSources components, along with their associated test files and example output JSON files, streamlining the Grafana integration by removing obsolete code.

Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Comment thread web_src/src/pages/workflowv2/mappers/grafana/query_logs.ts Outdated
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
@AleksandarCole AleksandarCole added the pr:stage-3/3 Ready for full, in-depth, review label Apr 15, 2026
Comment thread agent/uv.lock
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we dont need to commit this file

Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Comment thread agent/uv.lock Outdated
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Comment thread pkg/triggers/schedule/schedule.go Outdated
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b249a6e. Configure here.

componentName: string,
): EventSection[] {
return grafanaEventSections(nodes, execution, componentName, "strict");
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Duplicate buildGrafanaEventSections function definitions in base.ts

High Severity

The diff adds a second export function buildGrafanaEventSections at line 97, but one already exists at line 14 with a different signature that accepts an optional 4th options?: BuildGrafanaEventSectionsOptions parameter. Multiple existing callers (create_alert_rule.ts, update_alert_rule.ts, get_alert_rule.ts) invoke it with 4 arguments including { strict: true }. The two implementations also have different behavior — the first uses resolveGrafanaEventDisplayTimestamp (which falls back to updatedAt), while the new one uses different timestamp handling via grafanaEventSections. This duplicate will cause a TypeScript compilation error, or if it somehow compiles, the shadowed version would silently drop the options argument from all existing callers.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b249a6e. Configure here.

Timezone: stringPtr("2"),
},
timezone: "GMT+2.0 (UTC+02:00)",
timezone: "GMT+02:00 (UTC+02:00)",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unrelated schedule test changes accidentally committed

Low Severity

Changes to schedule_test.go (timezone format string updates like "GMT-5.0""GMT-05:00") are unrelated to the grafana investigation components feature. A reviewer already noted "we dont need to commit this file."

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b249a6e. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:stage-3/3 Ready for full, in-depth, review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Grafana] Expand - Investigation

3 participants