Code Monkey home page Code Monkey logo

Comments (5)

Vamic avatar Vamic commented on August 18, 2024 1

I imagine you could use variables and then have the same UI as headers for setting the value of each of the variables, data source config could have all the default values, and then you can override them in the query editor.

from grafana-json-datasource.

marcusolsson avatar marcusolsson commented on August 18, 2024 1

Appending would also make sense from the perspective of permissions.

You could set up data sources where the administrator wants to only allow access to resources under a certain path. For example, https://example.com/api/tenants/abc123. Allowing the users to replace the path completely would prevent this use case.

I think I have enough to start working on this. Thanks for helping me hash this out!

Also, good point about replacing // with /. I'll make sure to add it 👍

from grafana-json-datasource.

marcusolsson avatar marcusolsson commented on August 18, 2024

It's been asked a few times, and I can see how it would be a useful feature. I'm not sure how this would work yet though.

  1. Add variable support to the URL: This would give you a lot of freedom. You could create https://api.example.com/${resource}, or even https://${environment}.example.com. You wouldn't be able to test the data source, or to use it in Explore, or anywhere where variables aren't available.
  2. Set path in query editor: This would add a field in the query editor that would be interpolated and added to the URL. Would this append to the path set in the data source config, or would it override it? Probably the latter.

I'd love more ideas on how you'd like this to work.

from grafana-json-datasource.

marcusolsson avatar marcusolsson commented on August 18, 2024

I think I'd like to use the built-in variables for this, rather than creating variables specifically for this data source (not sure if that's what you meant).

I'm leaning towards only making this configurable in the query editor to start with. A text field that would replace the path set by the data source.

  • URL in data source config: https://example.com/api
  • Path in query editor: /v2/api/${resource}

Would result in https://example.com/v2/api/orders (when resource is order).

Another option would be to support appending a path to the URL:

  • URL in data source config: https://example.com/v2/api
  • Path in query editor: /${resource}/list

Would result in https://example.com/v2/api/orders/list

This sounds like it would solve your use case, while at the same time leaving options open for whether we want to be able to add this to the data source config?

from grafana-json-datasource.

Vamic avatar Vamic commented on August 18, 2024

Sure, that will work.
Appending makes the most sense to me but if you want the data source to have a default path replacing would be the way to go without needing config in the data source.

As an aside, this isn't in my use case or anything but if a variable is empty you might want to allow it to replace the // with /. Like if you have a variable for order_id and its empty it'll grab all orders by calling /api/orders/details instead of /api/orders//details.

from grafana-json-datasource.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.