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

Automatically provision metrics dashboards? #151

Closed
gabriel-v opened this issue Jan 30, 2023 · 4 comments
Closed

Automatically provision metrics dashboards? #151

gabriel-v opened this issue Jan 30, 2023 · 4 comments

Comments

@gabriel-v
Copy link
Contributor

gabriel-v commented Jan 30, 2023

I was looking at the "Querying Metrics" documentation page and I am wondering how to automatically provision dashboard from the configuration YML file.

This would be similar to how Grafana loads dashboard from folders, encoded as JSON.

The documentation page mentions examples like this:

metrics:
  - api.user_cache.hits as $hits
  - api.user_cache.misses as $misses
query:
  - per_min($hits) as hits
  - per_min($misses) as misses
  - hits / (hits + misses) as hit_rate

...but I don't see in the configuration file definition how they are used. I suppose these are actually instructions for clicking in the UI, not code samples?

Questions:

  • is there a way to automatically provision metrics dashboards?
  • if not, would I achieve this effect by dumping and loading some SQL from the uptrace sqlite database? Which tables?
  • would you be interested in a pull request that adds automatic dashboard provisioning? Something like
projects:
  - id: 2
    name: dashboards
    token: x
    pinned_attrs:
      - x
    group_by_env: false
    group_funcs_by_service: false
    metrics_dashboards:
      dashboard1:
        type: grid  # | table
        description: example dashboard
        options:
          chart-type: stacked-bar   # | line-chart | area-chart | etc
        metrics:
          - api.user_cache.hits as $hits
          - api.user_cache.misses as $misses
        query:
          - per_min($hits) as hits
          - per_min($misses) as misses
          - hits / (hits + misses) as hit_rate

Thank you!

@gabriel-v
Copy link
Contributor Author

I did a sqlite3 dump here: https://gist.github.com/gabriel-v/0ba9f15d62dd9a5aec5e1f1a475b5b84

I see relevant tables here:

  • metrics
  • dash_entries
  • dash_gauges

Guess I'll truncate & repopulate these 3 on every container boot from a template.

@gabriel-v
Copy link
Contributor Author

Sql dumping and loading works great.

But I found this tooltip for the auto-generated dashboards:

Screenshot from 2023-01-30 17-49-08

This means there's a way to configure our own templates, or are they hard-coded in the go implementation?

@vmihailenco
Copy link
Member

vmihailenco commented Feb 2, 2023

Hey @gabriel-v,

We have dashboard templates here: https://github.com/uptrace/uptrace/tree/master/config/dashboard-templates. You can add your templates there and Uptrace will pick them up when it is restarted.

Uptrace keeps those templates in memory and automatically provisions a dashboard when it receives a metric that is used in the template, for example, "HTTP: Server" dashboard will be created when http.server.duration metric is created.

We have lots of plans for dashboard templates:

  • allow to share/export existing dashboards via YAML config
  • allow to import dashboards from a file/URL
  • probably have a collection of templates at uptrace.dev site with some popularity/rating
  • Uptrace should not create dashboards automatically and instead user must create dashboards manually from a list of available templates. Otherwise, there are too many dashboards that people might not want.

If you willing to help with this work, let's connect via Telegram / Slack to discuss details.

@gabriel-v
Copy link
Contributor Author

We have dashboard templates here: https://github.com/uptrace/uptrace/tree/master/config/dashboard-templates. You can add your templates there and Uptrace will pick them up when it is restarted.

That's exactly what I was looking for! I missed that section of your code.

I wanted to add a reference to everything you just said in your docs page on Metrics and also referenced here and as a separate "Managing Dashboards" section here, but I don't see documentation sources on GitHub where to send PR.

We have lots of plans for dashboard templates: allow to share/export existing dashboards via YAML config

Yes, that sounds like it would close the loop where you edit the dashboard, save the yaml and push the changes back to the servers.

I'll get in touch next week about contributing this feature.

Closing issue: it works

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

No branches or pull requests

2 participants