Skip to content

Conversation

@bendk
Copy link
Contributor

@bendk bendk commented Dec 9, 2025

Initial commit for the generate-rust-dashboards tool. This auto-generates Grafana dashboards for teams that own Rust Components. There's still a lot of work to do, but this feels like a good start.

Pull Request checklist

  • Breaking changes: This PR follows our breaking change policy
    • This PR follows the breaking change policy:
      • This PR has no breaking API changes, or
      • There are corresponding PRs for our consumer applications that resolve the breaking changes and have been approved
  • Quality: This PR builds and tests run cleanly
    • Note:
      • For changes that need extra cross-platform testing, consider adding [ci full] to the PR title.
      • If this pull request includes a breaking change, consider cutting a new release after merging.
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry in CHANGELOG.md or an explanation of why it does not need one
    • Any breaking changes to Swift or Kotlin binding APIs are noted explicitly
  • Dependencies: This PR follows our dependency management guidelines
    • Any new dependencies are accompanied by a summary of the due diligence applied in selecting them.

@bendk bendk requested a review from skhamis December 9, 2025 22:17
@bendk
Copy link
Contributor Author

bendk commented Dec 9, 2025

This tool generates JSON files, which devs can then upload to the Grafana import page. Here's examples from the current config:

There's a bunch of code here and probably lots of opportunities to improve it. I guess the main question is if this is leading us down a path we'll regret in the future. For example are devs going to want to hand-customize their dashboards, which will then be lost if they re-generate and re-import the JSON.

This doesn't handle alerting. AFAICT, that needs to be set up manually.

@bendk bendk force-pushed the push-qvnvpvqlkqlq branch 3 times, most recently from 2d7b144 to bc49e7b Compare December 9, 2025 23:05
Copy link
Contributor

@skhamis skhamis left a comment

Choose a reason for hiding this comment

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

Super cool! This is an amazing start and I know it's proto-typy so i didn't want to block super hard on anything but just a few comments/concerns. However majority of this patch looks great, Nice job!!

.select
.extend([format!("q[OFFSET({quantile_index})] as amount")]);
}
Some(amount) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there scenarios where amount could be 0 here? Is there a way to avoid a divide-by-0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

value_divisor comes from the team_config.rs file directly, so as long as devs don't put in a 0 we should be okay there.

hide: VariableHide::Variable,
datasource: Datasource::bigquery(),
query: QueryVariableQuery::from_sql(
r#"SELECT IF(STRPOS('${Filters}', '=') <> 0, REPLACE(REPLACE('${Filters}', '",', '" AND '), '\n', '\\n'), 'true')"#,
Copy link
Contributor

Choose a reason for hiding this comment

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

If i'm understanding correctly this might make some of the queries vulnerable here where it's used in {filter_sql} directly into the SQL statement (injection)? Idk how Grafana handles some of these but maybe more of a warning or something here.

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, this was fairly scary to me too, but I convinced myself that it was okay. If the user is on a dashboard, then they should have already authorized themselves as a Mozilla employee. Also, you can always create your own dashboard and run whatever query you want. The best attack vector I could see would be some of phishing attack where an outside person sent a Mozilla employee a link to one of our dashboards, but that doesn't seem very likely. Still, I do really hate the way this works and wish there could have been a cleaner way.

I'll add a comment about this, maybe we could figure out something better in the future.

Initial commit for the `generate-rust-dashboards` tool.  This
auto-generates Grafana dashboards for teams that own Rust Components.
There's still a lot of work to do, but this feels like a good start.
@bendk bendk force-pushed the push-qvnvpvqlkqlq branch from bc49e7b to 18231e1 Compare December 22, 2025 15:47
@bendk bendk requested a review from skhamis December 22, 2025 15:47
@bendk
Copy link
Contributor Author

bendk commented Dec 22, 2025

Thanks! I fixed the bugs you pointed out and added some comments for that filter query. If you don't feel good about including that, we could just remove it and find a different way to filter the records.

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.

2 participants