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

Exposed service logs view #498

Closed
wants to merge 1 commit into from

Conversation

kozhuhds
Copy link

@kozhuhds kozhuhds commented Jul 2, 2024

Exposed service logs view for other Grafana plugins to consume.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@@ -3,6 +3,7 @@
"type": "app",
"name": "Logs",
"id": "grafana-lokiexplore-app",
"preload": true,
Copy link

Choose a reason for hiding this comment

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

Do we need preload:true when exposing components? (I used to think this was for non-hook component extensions only)

Copy link
Author

Choose a reason for hiding this comment

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

yeah, I think so. It doesn't work for me without preload: true.

Copy link

Choose a reason for hiding this comment

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

Interesting, might need some insights from @leventebalogh, also whether we need to specify the extension in the plugin.json

Copy link

@leeoniya leeoniya Jul 2, 2024

Choose a reason for hiding this comment

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

please take a look at this thread before proceeding with preload: true. ideally we can avoid introducing this rather than trying to undo it later.

https://raintank-corp.slack.com/archives/C077S1MP40M/p1719937543634869

Copy link

Choose a reason for hiding this comment

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

Thanks @leeoniya, looks like no need for preload: true is supported in 11.1.0, and it requires the plugin.json metadata as mentioned by @sympatheticmoose in the thread:

we'd tried a metadata extractor approach which proved unviable, but theres alternatives by just having the information manually added to plugin.json etc

Choose a reason for hiding this comment

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

@jarben @leeoniya

Unfortunately we currently need the preload: true flag. It's true, that we are working on only loading plugins when they are used (extensions or normal plugin usage), but the PR is not yet merged and deployed.

ideally we can avoid introducing this rather than trying to undo it later.

Yeah, I agree that this would be ideal, however unfortunately we cannot avoid it for now. Regarding undoing it later: once the PR mentioned above is merged preload: true won't have an effect, which means that even though we still need to do clean ups in the plugin.json, it won't affect performance.

we need to specify the extension in the plugin.json

Yes, that would be great, thanks. (We can only preload plugins properly if we know what they are exposing.)

Copy link

Choose a reason for hiding this comment

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

Thanks @leventebalogh ! So is this PR just a prerequisite? Or is it for Grafana extensions only, not plugin extensions?

once the grafana/grafana#86624 is merged preload: true won't have an effect, which means that even though we still need to do clean ups in the plugin.json, it won't affect performance.

Makes me think that the cloud-home-app also uses preload:true to be able to show notification banners anywhere in Grafana, not just after the plugin is loaded. How would we handle this use case if preload:true doesn't work anymore?

Choose a reason for hiding this comment

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

Exactly @jarben, that PR was only a prerequisite, it still relies on preload: true (here), but the preloading doesn't block the Grafana app boot process anymore. :)

Makes me think that the cloud-home-app also uses preload:true to be able to show notification banners anywhere in Grafana, not just after the plugin is loaded. How would we handle this use case if preload:true doesn't work anymore?

Yea, I guess plugins like like this will still need to be preloaded (cloud-home-app is an exception already). What would be good if they wouldn't block the boot process at least, but unfortunately we couldn't do that with the cloud-home-app, as one of the external libraries it's using is causing weird bugs if it is initialised after Grafana has loaded.

Copy link

Choose a reason for hiding this comment

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

Thanks @leventebalogh, great to see the cloud-home-app exception was considered in the PR.
Do you remember which library caused the issue? @grafana/cloud-ab-testing?

Choose a reason for hiding this comment

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

Exactly, it's the third-party library that it is using for A/B testing. (The issue is that it's somehow causing a re-rendering of the whole AppChrome in case it's not loaded before Grafana boots up. I was trying to debug it, but couldn't find the root cause during a time-box.)

},
],
initialFilters,
initialDS,
Copy link

Choose a reason for hiding this comment

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

What happens when this is empty when optional?

Copy link
Author

Choose a reason for hiding this comment

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

this is a really good question, and I would say a more global one.
Explore logs app has 2 modes: 'service_selection' | 'service_details'. Not sure I can imagine the situation where we need to "embed" and start from service_selection view. So my initial idea was to use only service_details view with a particular service_name filter filled (this is a condition to have this mode opened, otherwise explore logs app redirects to service_selection). I am thinking about sticking to this (and this made me think about some other changes - like I need to disable removing service_name filter for example) wdyt @jarben ?

so answering your question:

  1. If initialFilters are empty and the mode is service_details currently it just redirects to explore logs app with service_selection view enabled.
  2. If initialDS is empty it applies the default one.

Copy link

Choose a reason for hiding this comment

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

Interesting, thanks for all the details @kozhuhds! So the question is whether to make the extension generic or specific to a service?

  • If generic, making the mode as a param would make sense so users can explicitly choose service_selection if that's what they want.
  • if service-specific, what if we rename the extension to explore-service-logs/v1 and make the service_name param required? (we can also make an extension such as explore-services)

],
initialFilters,
initialDS,
mode: 'service_details',
Copy link

Choose a reason for hiding this comment

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

Should this be a prop?

@gtk-grafana
Copy link
Contributor

Please note that this PR will probably need some updates after the #477 is merged

@kozhuhds
Copy link
Author

kozhuhds commented Jul 2, 2024

yeah, after #477 is merged it is becoming a way harder to expose the service logs view since now it contains browser history pushes/redirects everywhere. Not sure how to approach this since at the end of the day it will be just a copy of existing scene components (but without redirects)

cc @gtk-grafana @jarben

@jarben
Copy link

jarben commented Jul 2, 2024

yeah, after #477 is merged it is becoming a way harder to expose the service logs view since now it contains browser history pushes/redirects everywhere. Not sure how to approach this since at the end of the day it will be just a copy of existing scene components (but without redirects)

cc @gtk-grafana @jarben

Outch

@gtk-grafana
Copy link
Contributor

gtk-grafana commented Jul 2, 2024

yeah, after #477 is merged it is becoming a way harder to expose the service logs view since now it contains browser history pushes/redirects everywhere. Not sure how to approach this since at the end of the day it will be just a copy of existing scene components (but without redirects)

I'll discuss this with the squad tomorrow morning, but with #477 we were addressing user feedback that it's super frustrating that the entire app has a single entry in the browser history, i.e. going back in history would delete everything you did in the app and take you to the last page before entering the app, and there's no way to go forward again after going back so users were forced to manually re-add their filters every time they went back.

I would expect that this would work the same way as split panes in explore, where url parameters are stored in an array of panes, and state changes are pushed to location history and can be traversed in the same order as the user's actions in the any of the panes. This should allow the embedding application to sync state between panes without degrading the UX.

The only functional part of the URL right now is the slug (last part of the path), I imagine it wouldn't be too much work to update the code to store/retrieve the slug from the search parameters instead.

Is there a design doc for embedding scene apps within other apps/core?

@jarben
Copy link

jarben commented Jul 2, 2024

yeah, after #477 is merged it is becoming a way harder to expose the service logs view since now it contains browser history pushes/redirects everywhere. Not sure how to approach this since at the end of the day it will be just a copy of existing scene components (but without redirects)

I'll discuss this with the squad tomorrow morning, but with #477 we were addressing user feedback that it's super frustrating that the entire app has a single entry in the browser history, i.e. going back in history would delete everything you did in the app and take you to the last page before entering the app, and there's no way to go forward again after going back so users were forced to manually re-add their filters every time they went back.

I would expect that this would work the same way as split panes in explore, where url parameters are stored in an array of panes, and state changes are pushed to location history and can be traversed in the same order as the user's actions in the any of the panes. This should allow the embedding application to sync state between panes without degrading the UX.

The only functional part of the URL right now is the slug (last part of the path), I imagine it wouldn't be too much work to update the code to store/retrieve the slug from the search parameters instead.

Is there a design doc for embedding scene apps within other apps/core?

An option is also if the extension does its own routing using extension params by bypassing the url routing and using components directly..

@kozhuhds
Copy link
Author

kozhuhds commented Jul 5, 2024

hey, prepared a product DNA for this feature.

@jarben @gtk-grafana

@gtk-grafana
Copy link
Contributor

I created an issue for this: #530, I'm going close out this PR and move the discussion there as I think this is a bigger lift then anticipated and will require some planning and collaboration with the other explore app squads.

@gtk-grafana gtk-grafana closed this Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants