Comments (6)
I am getting these snippets even though grafana is able to render the dashboards. I only get the error when using hubot-grafana
Any ideas how I could debug this?
Everything seems to be ok, I get the correct URL and statusText from Grafana is OK but it returns an HTML instead of the PNG
I tried the same request with CURL and it worked fine
I think I found the problem.
The API key is not being passed to grafana in the header
/**
* Downloads the given URL.
* @param {string} url The URL.
* @returns {Promise<{ body: Buffer, contentType: string}>}
*/
async download(url) {
console.log(grafanaHeaders(null, null))
return await fetch(url, {
method: 'GET',
headers: grafanaHeaders(null, null, "PUT_YOR_TOKEN_HERE), // By default the token is not set in there
}).then(async (res) => {
const contentType = res.headers.get('content-type');
console.log(res.statusText)
const body = await res.arrayBuffer();
return {
body: Buffer.from(body),
contentType: contentType,
};
});
}
After adding the key there it worked, however by default it is not passed. Is this a bug on your end?
from hubot-grafana.
Hm, ok, so I copied out the HTML for one of those snippets and loaded it up in a browser. It looks like the problem is with Grafana and not this plugin. Those snippets are all 500 responses.
It'd be nice if there were a way to capture that response as a 500 and return an error message instead of the HTML snippet though.
from hubot-grafana.
What's likely happening is that the /render
endpoint is returning the HTML instead of the expected PNG, and our Hubot package is not catching that and displaying an error like it should. Can you verify that your Grafana server can render an image from a panel per usual? Sometimes it may be related to PhantomJS or something not working as expected.
from hubot-grafana.
It'd be nice if there were a way to capture that response as a 500 and return an error message instead of the HTML snippet though.
Yep, agree with that.
from hubot-grafana.
What will make that a bit of a challenge is that in the case of the Slack adapter, we're passing that URL along without checking to see if it's valid. This allows the bot to not wait around for the image to render (it can take a bit), but it puts us at the mercy of whatever Slack does in the event of a failure. Perhaps there's some type hinting we can do through the Slack API to say "No seriously, this should be an image. If it isn't, fail to render the image rather than returning the server output as text."
from hubot-grafana.
Splitting this off into a new issue. Definitely a bug, will update there.
from hubot-grafana.
Related Issues (20)
- graf db nginx-lua Why is the grafana homepage returned? HOT 8
- TimeZone support HOT 2
- Grafana 7: Full screen leads to localhost:3000 redirect HOT 4
- ERROR SyntaxError: Unexpected token < in JSON at position 0 HOT 3
- hubot-grafana does not work for Grafana 8 HOT 7
- Upgrade from 2.5.2 to 3.0.1: dashboards can't be accessed by slug anymore HOT 5
- Can only receive 1 image by each query which queries all panels in the dashboard HOT 2
- Allow the bot to respond in a thread HOT 2
- S3 Region breaks existing setup HOT 2
- Support for @hubot-friends/hubot-slack
- feat: clean the NPM package to make its footprint smaller
- Getting rid of the obsolete request dependency
- Tests are too slow or timing out HOT 2
- Refactor platform specific actions to adapters? HOT 3
- Download method needs API key in header HOT 3
- [Windows] Unable to run `npm test` HOT 4
- Let's do some big refactoring
- Typings
- Bot will respond multiple times when Grafana is a bit slow
- Slack upload fails with `TypeError: this.robot.adapter.client.web.files.uploadV2 is not a function`
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 hubot-grafana.