Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explore: Add range option to internal data links #64063

Merged
merged 2 commits into from Mar 14, 2023

Conversation

connorlindsey
Copy link
Contributor

@connorlindsey connorlindsey commented Mar 2, 2023

What is this feature?

Adds an optional range to internal data links and uses it in field overrides if present.

Why do we need this feature?

The app o11y plugin links from a dashboard in the plugin to logs in Explore and needs a way to keep the time range the same. This will let us add the time range to the internal link config like so:

errorField.config = {
  ...errorField.config,
  unit: 'string',
  links: [
    {
      title: 'Logs',
      url: '',
      targetBlank: true,
      internal: {
        datasourceUid: lokiDs.uid,
        datasourceName: lokiDs.name,
        range: ctx.timeRange,
        query: {
          refId: '',
          expr: `{app="${ctx.appName}"} |~ "\${__value.raw}"`,
          queryType: 'range',
        },
      },
    },
  ],
};

Relates to https://github.com/grafana/app-o11y-kwl/issues/174

@connorlindsey connorlindsey self-assigned this Mar 2, 2023
@connorlindsey connorlindsey requested review from a team as code owners March 2, 2023 18:45
@connorlindsey connorlindsey requested review from tskarhed, ashharrison90 and academo and removed request for a team March 2, 2023 18:45
@connorlindsey connorlindsey requested review from a team and removed request for a team March 2, 2023 18:47
@Elfo404
Copy link
Member

Elfo404 commented Mar 3, 2023

sounds reasonable to me 👍

@connorlindsey connorlindsey added this to the 9.5.0 milestone Mar 3, 2023
@@ -451,7 +451,7 @@ export const getLinksSupplier =
internalLink: link.internal,
scopedVars: variables,
field,
range: {} as any,
range: link.internal.range ?? ({} as any),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it the same range as in the panel? If yes, could we pass the range from PanelQueryRunner? e.g.:

 series: applyFieldOverrides({
+    timeRange: data.timeRange,
     timeZone: data.request?.timezone ?? 'browser',
     data: processedData.series,
     ...fieldConfig!,
   }),

And later pass the range to getLinksSupplier.

This way it could work for any data link, without a need to pass the range in the config. Not sure if that would work for your use case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it is the same time range although the plugin uses the PanelRenderer which calls useFieldOverrides and doesn't run PanelQueryRunner, so I don't think that'd work for our situation. Maybe scenes will fix this out of the box.

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

Successfully merging this pull request may close these issues.

None yet

4 participants