stephenyeargin / hubot-grafana

📈🤖 Query Grafana dashboards
http://docs.grafana.org/tutorials/hubot_howto/
MIT License
154 stars 48 forks source link

Upgrade from 2.5.2 to 3.0.1: dashboards can't be accessed by slug anymore #140

Closed KeesCBakker closed 2 years ago

KeesCBakker commented 2 years ago

👋 Hi, first of all: great plugin for Hubot! We have been using it for a while now and it helps us a lot.

After upgrading I noticed I got messages like: Try your query again with RYWWhopGk instead of jarvis-sre-dashboard-by-kz

As we use a generator the RYWWhopGk will change over time, so we've became used to using the slug jarvis-sre-dashboard-by-kz. Is there a way for us to keep using commands like graf db jarvis-sre-dashboard-by-kz:panel-2 now-1h now width=1400. Is there a config value to reactivate this feature again? I would be willing to implement it myself if needed.

Is your feature request related to a problem? Please describe. Version 3 seems to use an ID, version 2 allows the slug of a dashboard.

Describe the solution you'd like I would love to have an environment flag to enable the feature again.

Describe alternatives you've considered Nothing so far, but would love to contribute.

Additional context N/A

KeesCBakker commented 2 years ago

Our version of Grafana is Grafana v7.5.5 (b5190ee547)

KeesCBakker commented 2 years ago

🤔 Looking into: https://github.com/stephenyeargin/hubot-grafana/releases/tag/v3.0.0

This version drops support for Grafana 5 or earlier, and has only been tested with Grafana 8. It also relies exclusively on the uid of the dashboard rather than the legacy slug. If you run into trouble with this version and are running an earlier version of Grafana, we suggest downgrading back to v2.5.2. We also recommend the hubot-alias package if the new UID keys are too cumbersome to remember. In the example below, the uid is 7h3u1d, and we're requesting the second panel.

stephenyeargin commented 2 years ago

@KeesCBakker Sorry for the delay. Yes, that was a tradeoff in #139 that seemed to be the best route forward. I don't like having to use a separate package because the UID's are difficult to keep up with (and the API doesn't have a way to map those requests), but we did not have a better idea at the time.

KeesCBakker commented 1 year ago

@stephenyeargin, we ended up parsing the URI to see if we could have our slugs back and it worked. We wrote some middleware for Hubot to rewrite messages that did not have the UID in them. What do you think of the approach?

Did a small write up on the topic: https://keestalkstech.com/2022/11/grafana-i-want-slugs-back-for-my-hubot-%f0%9f%98%ad/

stephenyeargin commented 1 year ago

@KeesCBakker Oh that's clever! I wouldn't have thought to hijack the Hubot message envelope to re-format the request.

I do like the idea of leveraging the search function to try and help the user find the dashboard they are looking for (without remembering or even knowing the generated slug). I'd think that it would be some order of:

1) exact match -> if no match found 2) regex match on url element for relevant piece -> if no match found 3) last ditch search to match on exact title (e.g. Application_Load_Balancers) -> if no match found 4) return error