Executing shell script from scripted dashboard

Hi all, as the title says, I’m trying to execute a shell script from grafana, I need to generate a button or at least when the dashboard load runs a specific shell script.

I’m trying with shelljs but I couldn’t make it, any idea that how I can achieve this? Is there any other option that I can use to run a shell script from grafana?

Thanks

1 Like

+1 for this tutorial or feature

Hi, @maximiliano,

You could create a link from the dashboard to a separate HTTP server you would create for handling these scripts. Those links would be available in the top-right corner of your Grafana dashboard, but they shall open in a new tab of the browser. This link would trigger an HTTP GET request to your server that handles these scripts. You may use virtually any HTTP server depending on what fits best with your scripts.

Anirudh

Hi @rameshanirudh95, thanks for your advice, but im looking for a solution without an external server, just using Grafana to do it, do you think that is possible ?

Regards
Max

Hi, @maximiliano, I don’t think it’s possible with the current version of the Grafana server and UI, unless someone writes a panel specifically to do this. For that, some potential security vulnerabilities have to be addressed since the user could potentially access low-level system settings via such a panel.

Thanks,

Anirudh

The short answer is that it isn’t possible because allowing execution of shell scripts from Grafana on the server would be a very big risk in terms of security vulnerabilities. My general recommendation would be to look into @rameshanirudh95’s proposed solution and pre-define which exact commands may be executed. Allowing shell scripts to be run from the web is in general quite scary since the risk of abuse is high and the result could be devastating.

Good luck,
Emil

1 Like

agree this is the right architecture and way to do it…