Comments (5)
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.
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.
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.
- Add variable support to the URL: This would give you a lot of freedom. You could create
https://api.example.com/${resource}
, or evenhttps://${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. - 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.
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.
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)
- Grafana API does not export panel annotations HOT 1
- Cannot see JSONAPI datasource in the plugin list HOT 1
- Chore: migrate to create plugin
- Suporte a paginação HOT 1
- Support multi-value variables HOT 1
- Dynamically adding fields for all JSON properties HOT 1
- Issue with multiple API calls from same chart HOT 1
- Grafana v9 - Button HOT 2
- README Shows Example that doesn't work at all [?(@.data > 'otherdata']
- Filtering in Jsonpath using Grafana multi-value variable? 'IN' operator supported? Or workarounds? HOT 1
- Audit and fix A11Y issues HOT 1
- Can't perform basic math with JSONata HOT 1
- Query error e.ArrayVector is not a constructor Getting this error after the new update. HOT 2
- Query error e.ArrayVector is not a constructor Getting this error after the new update HOT 3
- Support Sigv4 Auth
- A variable can't take another variable's value as a http request parameter if it starts with "1"
- Hope to support returning key value pairs as variables
- Show more details in console or query inspector
- TimeShift not working HOT 1
- JSON API: Bad Gateway HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grafana-json-datasource.