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

Add more filters in panel title #20

Closed
Seraf opened this issue Oct 19, 2015 · 10 comments
Closed

Add more filters in panel title #20

Seraf opened this issue Oct 19, 2015 · 10 comments

Comments

@Seraf
Copy link

Seraf commented Oct 19, 2015

Hello,

hubot graf db graphite-carbon-metrics:cpu - Get only the panels containing "cpu" (case insensitive) in the title
A great improvement could be to search for cpu&memory or cpu&<text>

My use case here, is that I have a row with a panel for each host. I would like to be able to display this panel but only for a host (as I don't use host var for this dashboard)

What do you think about this ?

Thanks

@stephenyeargin
Copy link
Owner

I think this would work, but I'm not 100% sure on how to best do this for the user as far as the syntax for the commands. I'm presuming & would not be permitted in a particular panel's name?

@Seraf
Copy link
Author

Seraf commented Oct 19, 2015

@stephenyeargin It's actually not working. I was saying & but as it's used in the url it may be a bad idea. I was thinking about an operator to do some filtering. Maybe use the comma as a separator for an AND operator, and consider that everything between the : and the whitespace is a list of terms that should appear in the panel title ?

@stephenyeargin
Copy link
Owner

(Sorry, meant "could work" ... would definitely require some work to do it.)

@Tenzer
Copy link
Collaborator

Tenzer commented Oct 19, 2015

I'm slightly against this, mostly because the syntax for Hubot just would get more and more difficult to parse and remember. Perhaps you instead could use the number of the graph on the dashboard to show the graph you want?

@stephenyeargin
Copy link
Owner

Spit-balling some thoughts:

So if I understand the goal, it is to return more than one graph panel in a particular dashboard matching on a string. I agree with @Tenzer that there's a need to keep the syntax as easy to follow as possible -- It's already a bit of a challenge to handle templating and panel declarations as it is.

Perhaps a compromise would be to have a command that could fuzzy search through the entirety of your Grafana install for a particular panel title. Ideally, this would be exposed via an API in Grafana (I don't believe any such thing exists yet). The search results would give you the dashboard and numeric key for normal lookup. From there, you could save it in with hubot-alias for any graph you refer to frequently.

@Seraf
Copy link
Author

Seraf commented Oct 24, 2015

Hello, the goal is not to play wih multiple graf but allow to have more
search option than a keyword. The goal is to be able to search something
like "keyword1 AND keyword. I agree that it can be done on both side,
on the api (and it probably will be better) and on frontend by filtering on
all result.

Of course it should be able to return one or multiple graphs acccording the
search

Le sam. 24 oct. 2015 06:38, Stephen Yeargin notifications@github.com a
écrit :

Spit-balling some thoughts:

So if I understand the goal, it is to return more than one graph panel in
a particular dashboard matching on a string. I agree with @Tenzer
https://github.com/Tenzer that there's a need to keep the syntax as
easy to follow as possible -- It's already a bit of a challenge to handle
templating and panel declarations as it is.

Perhaps a compromise would be to have a command that could fuzzy search
through the entirety of your Grafana install for a particular panel title.
Ideally, this would be exposed via an API in Grafana (I don't believe any
such thing exists yet). The search results would give you the dashboard and
numeric key for normal lookup. From there, you could save it in with
hubot-alias for any graph you refer to frequently.


Reply to this email directly or view it on GitHub
#20 (comment)
.

@stephenyeargin
Copy link
Owner

So there is this: http://docs.grafana.org/reference/http_api/#search-dashboards

We could implement a hubot graf search <term> [tag:<tag>] endpoint that queries against the spec. That would allow any of the native search capability (within Grafana) to be leveraged.


Search Dashboards

GET /api/search/

Status Codes:

  • query – Search Query
  • tags – Tags to use
  • starred – Flag indicating if only starred Dashboards should be returned
  • tagcloud - Flag indicating if a tagcloud should be returned

Example Request:

    GET /api/search?query=MyDashboard&starred=true&tag=prod HTTP/1.1
    Accept: application/json
    Content-Type: application/json
    Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

    HTTP/1.1 200
    Content-Type: application/json

    [
        {
            "id":1,
            "title":"Production Overview",
            "uri":"db/production-overview",
            "type":"dash-db",
            "tags":[],
            "isStarred":false
        }
    ]

@Seraf
Copy link
Author

Seraf commented Oct 24, 2015

That makes sense, but does it limit to dashboard only ?

stephenyeargin added a commit that referenced this issue Oct 26, 2015
Related to #20

There is an API endpoint that accepts a query string to search available dashboards. Rather than re-invent the wheel, this adds two new calls to leverage that endpoint. This prevents a user from haivng to always use `hubot graf list` to get the entire list of the dashboards in order to query one of them.

- `hubot graf search <term>` will translate to `/api/search/?query=<term>` and return dashboards that have titles that match specified term
- `hubot graf list <tag>` will translate to `/api/search/?tag=<tag>` and return dashboards that match the specified tag
@stephenyeargin
Copy link
Owner

It appears that it will only search the dashboard (for now). Perhaps in the future it will be able to match on more than the Dashboard title when the API supports it (returning individual panel indexes).

I've opened #22 that will leverage that endpoint a bit better.

@stephenyeargin
Copy link
Owner

We implemented a search feature not too long after this was opened. I believe we tackled the easier feature and left the more complex notation for searching individual panels out. Calling this closed, but can be filed as a new, specific request for how you would want to interact with the bot.

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

No branches or pull requests

3 participants