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

Find MetricName used by Datasource #88

Open
jared-kupidura-simplisafe opened this issue Sep 19, 2023 · 6 comments
Open

Find MetricName used by Datasource #88

jared-kupidura-simplisafe opened this issue Sep 19, 2023 · 6 comments
Labels
pitch A pitch for a new feature

Comments

@jared-kupidura-simplisafe

First off, this tools is great. I am trying to use it to get every MetricName associated with a specific datasource. I was wondering if this was possible through the current setup but cant find the input combo? Looking for something like, if datasource name is 'CloudWatch', list all of the MetricsNames used in any panel in Grafana.

@amotl
Copy link
Contributor

amotl commented Sep 19, 2023

Dear Jared,

thank you for writing in. Your proposal sounds like a good idea to be tackled by grafana-wtf. I can't promise anything, but maybe someone from the community will pick it up for implementation.

As I am not working with grafana-wtf on a daily basis, can I ask for further guidance on your request to get us on the same page? I mean, if we would already have the feature to inquire data source items in all dashboard panels, how far away would be filtering that by datasource name?

Or are you actually looking at filtering that output by database type instead?

With kind regards,
Andreas.

@amotl
Copy link
Contributor

amotl commented Sep 19, 2023

What about this kind of inquiry, combining grafana-wtf with jq?

It discovers used datasources by name, and reports about the spots (dashboards) where those are used. Do you need the report to drill down into more details, down to the metrics level, or would that be satisfactory already?

grafana-wtf explore datasources --format=json | \
  jq '.used[] | select(.datasource.name == "weewx_097287c4_6fb0_4aeb_a095_00d65ecb15f7")'
{
  "datasource": {
    "uid": null,
    "name": "weewx_097287c4_6fb0_4aeb_a095_00d65ecb15f7",
    "type": "influxdb",
    "url": "http://localhost:8086/"
  },
  "dashboards": [
    {
      "title": "weewx 097287c4-6fb0-4aeb-a095-00d65ecb15f7 automatic",
      "uid": "000000190",
      "path": "/grafana/d/000000190/weewx-097287c4-6fb0-4aeb-a095-00d65ecb15f7-automatic",
      "url": "https://swarm.hiveeyes.org/grafana/d/000000190/weewx-097287c4-6fb0-4aeb-a095-00d65ecb15f7-automatic"
    },
    {
      "title": "Wetter in Leoni",
      "uid": "000000191",
      "path": "/grafana/d/000000191/wetter-in-leoni",
      "url": "https://swarm.hiveeyes.org/grafana/d/000000191/wetter-in-leoni"
    },
    {
      "title": "weewx-097287c4-6fb0-4aeb-a095-00d65ecb15f7",
      "uid": "w-kZrPmiz",
      "path": "/grafana/d/w-kZrPmiz/weewx-097287c4-6fb0-4aeb-a095-00d65ecb15f7",
      "url": "https://swarm.hiveeyes.org/grafana/d/w-kZrPmiz/weewx-097287c4-6fb0-4aeb-a095-00d65ecb15f7"
    }
  ]
}

Or are you actually looking at filtering that output by database type instead?

The example can easily be adjusted to filter by type instead, so that would be covered already.

select(.datasource.type == "foobar")

@amotl
Copy link
Contributor

amotl commented Sep 19, 2023

Do you need the report to drill down into more details, down to the metrics level?

grafana-wtf find mostly yields massive output, but may offer a better chance to learn about details slightly beyond the dashboard entity level, because it also informs you about details down to the panels and metrics (targets) levels.

grafana-wtf find weewx_097287c4_6fb0_4aeb_a095_00d65ecb15f7

Let me know about any improvements which could support your use case better. As the acquisition and querying machinery is in place already, adding more features on the level you are asking for would most probably only need a bit of data structure wrangling, and/or adjusting output templates.

@jared-kupidura-simplisafe
Copy link
Author

Yes, i would need more information about the panels in the dashboard to be able to pull out what metricName is being used with that datasource. I did get a great list of dashboards and which panels are using the datasource, just not enough information to parse that into jq to pull out the details i need.

@amotl
Copy link
Contributor

amotl commented Sep 21, 2023

Dear Jared,

you may want to have a look at the new --data-details option to explore dashboards, effectively adding a details slot to the output data, which conveys more information. See GH-89.

Setup

It is not released yet, but you can use this command to install the development version of the package.

pip install --upgrade 'git+https://github.com/panodata/grafana-wtf'

If you are using the Docker image, you may want to use the nightly tag for the same purposes of running the preview version.

Usage

When combining it with jq in this way, you can generate a flat list of all data queries used within all dashboards:

grafana-wtf explore dashboards --data-details --format=json | \
    jq -r '.[].details | values[] | .[].query // "null"'

Outlook

Let us know if that goes into the right direction, and/or if you need any improvements. If you think the raw output data is all you need, and will come up with a corresponding jq-based query to fit your needs, please share it back with us, so we can add it to the documentation as another example.

With kind regards,
Andreas.

@amotl
Copy link
Contributor

amotl commented Oct 3, 2023

Hi again,

we just released grafana-wtf 0.16.0, where the command outlined above should work, see also #70 (comment).

With kind regards,
Andreas.

@amotl amotl added the pitch A pitch for a new feature label Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pitch A pitch for a new feature
Projects
None yet
Development

No branches or pull requests

2 participants