One feature I really wanted for a project I'm working on was png exports. My project was regualrlry hitting the render API and I noticed that after about an hour I couldn't render any charts until I restarted the plugin. I assume this is the issue you refer to in one of your sticky topics?
Reading through the Grafana forums I noticed they were moving away from PhantomJS (as you also make mention of) to a Chrome solution. I researched headless Chrome and discovered that I could render the charts using the standard Mac Chrome install and an Indigo schedule. The schedule runs a bash script which runs a Chrome command that renders the chart as a png and saves it to the Indigo Web Server's public folder. From there I can access the png from my project. I've been running it for 4 days without issue.
Using the same process the image could be used in an Indigo Control Page.
The bash script I'm using is below.
- Code: Select all
#!/usr/bin/env bash
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --headless --disable-gpu --screenshot='/Library/Application Support/Perceptive Automation/Indigo 7/IndigoWebServer/public/my_image_name.png' --window-size=450,180 --hide-scrollbars 'http://localhost:3006/d-solo/NWEfJlNik/home?refresh=1m&orgId=1&panelId=2" frameborder="0"'
You need to change the screenshot , window-size and the Grafana URL settings as desired.
The image is then accessible from http://localhost:8176/public/my_image_name.png
I got the Grafana URL from the Share Panel menu on the Embed tab. Uncheck "Current time range" and strip out the <iframe> tags. The Grafana URL width and height entires aren't required and can be removed. Chrome ignores them and renders to its window-size setting regardless.
My Indigo schedule runs every 5 minutes and uses about 15% CPU for about 5 seconds each time on my 2011 MacMini. Just a consideration.... trying to run 10 charts every minute may cause some resource issues.
I'm going to investigate if the Chrome --headless command can send authentication as I'd like to lock Grafana back down.
Pete