Giter Site home page Giter Site logo

Comments (15)

marcusolsson avatar marcusolsson commented on July 29, 2024 2

Judging by the votes on the original post, this is important to many users. I'll get started working on this!

@smarkm I think what you're asking for is a bit different from what the original poster meant. To answer your question though: No, generic query parameter as variables is not supported. If you'd like to accomplish something like this you'd have to use dashboard variables, which is supported in both the path and query string fields.

from grafana-json-datasource.

marcusolsson avatar marcusolsson commented on July 29, 2024 1

Been experimenting with how to add this to the query editor. Here's a few thoughts I've been having so far:

  • The body text area is using the Monaco editor so you'd get access to syntax highlight and other features
  • I think I'd like to be able to hide it in case of large payloads
  • Debating whether selecting JSON in the query editor should add a custom header, or whether that should be configuring in the data source config
  • Possible to extend with a key value editor for form values, but thinking a Raw mode would work for now

Screen Shot 2021-01-29 at 12 22 48

Thoughts?

from grafana-json-datasource.

marcusolsson avatar marcusolsson commented on July 29, 2024 1

Ok, so here's an update on this. I've discussed this thread with the Grafana team, and I've decided to add support for POST requests. The reasoning is that the difference between GET and POST in this case is only semantic. There's nothing stopping you from building a REST API that uses GET to create resources. Similarly, there are APIs that only uses POST for all operations, including reading data.

With that, I also decided to add the support for settings a request body back in there. Unfortunately, due to the browser limitation I mentioned earlier, GET requests don't support a request body. You'll get a warning that tells you the body is being ignored.

I've released v0.9.0, which introduces a brand new query editor. Since this is a pretty big change, I'll hold off on publishing this for a bit to let people try it out first.

You can install it by running:

grafana-cli --pluginUrl=https://github.com/marcusolsson/grafana-json-datasource/releases/download/v0.9.0/marcusolsson-json-datasource-0.9.0.zip plugins install marcusolsson-json-datasource

Please read the CHANGELOG.md before installing it.

from grafana-json-datasource.

 avatar commented on July 29, 2024 1

@marcusolsson brilliant, with Cache Time 0s works, thank you!

from grafana-json-datasource.

casieo avatar casieo commented on July 29, 2024 1

Ok, so here's an update on this. I've discussed this thread with the Grafana team, and I've decided to add support for POST requests. The reasoning is that the difference between GET and POST in this case is only semantic. There's nothing stopping you from building a REST API that uses GET to create resources. Similarly, there are APIs that only uses POST for all operations, including reading data.

With that, I also decided to add the support for settings a request body back in there. Unfortunately, due to the browser limitation I mentioned earlier, GET requests don't support a request body. You'll get a warning that tells you the body is being ignored.

I've released v0.9.0, which introduces a brand new query editor. Since this is a pretty big change, I'll hold off on publishing this for a bit to let people try it out first.

You can install it by running:

grafana-cli --pluginUrl=https://github.com/marcusolsson/grafana-json-datasource/releases/download/v0.9.0/marcusolsson-json-datasource-0.9.0.zip plugins install marcusolsson-json-datasource

Please read the CHANGELOG.md before installing it.

This is working beautifully! Thank you! Will also play with word cloud panel, etc.
sprinklr

from grafana-json-datasource.

marcusolsson avatar marcusolsson commented on July 29, 2024

Thank you! I think this should be ok to add. I probably need to experiment with how to add it to the query editor without taking up too much space. Don't know when I'll be able to get around to this, but the more people who vote for this, the sooner it will get done :)

from grafana-json-datasource.

smarkm avatar smarkm commented on July 29, 2024

@marcusolsson Does this plugin support source URL query parameter as variable value for Path and Query string? I think this may be the same kind of issue and follow is what I mean:
image
I am trying to use this way to implement the drill-down function or any other ways to do it?

from grafana-json-datasource.

smarkm avatar smarkm commented on July 29, 2024

Got it, Thanks for your answer @marcusolsson

from grafana-json-datasource.

 avatar commented on July 29, 2024

Hi Marcus, thanks a lot for your plugin. I use the Postman application to test my Icinga queries and the raw body query is a POST request. Per Icinga documentation I add X-HTTP-Method-Override: "GET" in the headers, but this also works in the Grafana datasource. Will this request be executed as POST or GET, or can there be an option to choose?
Thanks a lot!
Regards Ferenc

from grafana-json-datasource.

marcusolsson avatar marcusolsson commented on July 29, 2024

@ferencmatyas All requests are executed as GET. I've been a bit reluctant to add the option to change the HTTP method, since I worry it will extend the scope of the plugin.

The intended purpose of this data source is to read and visualize JSON resources, not to create them. By supporting other methods, I feel like it would encourage people to use it as a Postman alternative. If you need a control panel, there are other plugins that can send JSON request using a button, for example.

For now, I'd like to keep this plugin read-only. If you can convince me that there are well-used APIs that use POST to read data (I'd like to learn more about the Icinga API), I will consider it. I hope I'm making sense here :)

Edit: You could argue that why would you add support for adding a body, since you typically don't use a body when using GET. I know from experience though that this is fairly common.

from grafana-json-datasource.

marcusolsson avatar marcusolsson commented on July 29, 2024

Tried something different altogether. Would love to hear what you think. My reasoning behind this one is that I mostly work on the JSON Paths most of the time, so the path, params, and body would take up unnecessary space.

tabs

from grafana-json-datasource.

marcusolsson avatar marcusolsson commented on July 29, 2024

Unfortunately, since technically a GET request with a request body isn't HTTP, browsers don't allow sending bodies with GET requests.

As I wrote in my earlier comment, I'm familiar with the fact that there are APIs that require it, but based what I've read so far, this simply isn't possible.

I'm going to (reluctantly) close this issue. If anyone knows how to make non-HTTP requests with the Fetch API, I'll reopen this.

from grafana-json-datasource.

 avatar commented on July 29, 2024

@marcusolsson thanks a lot for this update, I noticed the drop-down menu on the Path tab, it works with 2 Panels in Grafana. The addition is that as much GET part of the query needs to be added to the Path field as possible. In Icinga example, Path POST /objects/services?filter=service.state==ServiceWarning and body like { "filter": "service.downtime_depth == 0.0 && service.acknowledgement == 0.0 && service.display_name != "service1" && service.display_name != "service2" && service.handled == 0 " } and do not try to include the ServiceWarning in the body query. This seems to fix the issue where two panels with different queries in the Critical and Warning state get the same results with auto refresh.

from grafana-json-datasource.

 avatar commented on July 29, 2024

@marcusolsson I write a new reply. the Path query above does not solve the issue with auto refresh, I need for Icinga the body part to send the query for Critical or Warning for it to consider the other filters. Now when I reload with F5 the Grafana Dashboard the initial data is fine and I see 2 http requests in the icinga log. But when Grafana does the Auto Refresh, no new http request is seen in the icinga log and Grafana somehow loads the same cached reply. I googled maybe this is a Grafana setting, this comes up https://community.grafana.com/t/refresh-every-5s/3897/8 . Can you reproduce this issue? Thank you.

from grafana-json-datasource.

marcusolsson avatar marcusolsson commented on July 29, 2024

By default, the plugin caches the response for 5 minutes. This is to avoid making requests while working on your JSON Paths, once you're happy with your query, I suggest that you change the Cache Time to 0s. Let me know if that helps!

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.