New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create config setting to control if graphite json render request is POST or GET #345
Comments
In your graphite apache/nginx config, can you add POST to Access-Control-Allow-Methods header? Grafana uses POST for the graphite json api. |
Can I change this call to GET instead of POST? |
No, there is no setting for this. It needs to be done in the code. Is this important for you? It should be pretty easy / quick to add POST to Access-Control-Allow-Methods |
I don't manage the graphite server, its a managed server. Not only it will take time but also I don't think I can argue to have a POST opened for GET request. |
Just pushed a config setting for this :) In config.js comment out graphiteUrl and replace with: datasources: {
prod: {
default: true,
type: 'graphite',
url: 'http://graphite.com',
render_method: 'GET' // new optional setting to change render request from POST to GET
}, This is in master. Not ready for new release yet. So if you want to make a new optimized build from master:
|
@torkelo thank you so much for quick turnaround time. |
We can't do this in Apache, because uWSGI hijacks request-processing. See <http://stackoverflow.com/a/25783474>. So: leverage the fact that graphite-web is a Django web app, and add a very thin Django middleware class that sets appropriate CORS headers for origins which match settings.CORS_ORIGINS, and add a parameter for specifying origins to graphite::web. Nice! Finally, tell Grafana to make GET requests to Graphite's render API and not POST. See <grafana/grafana#345>. Change-Id: Ieebc69411c61bf3b08990f8890c918260da1b432
Is it possible to do the same with the latest version of Graphana? I understand it does not use config.js anymore. |
@stefanoric not currently. But POST should be more reliable that is why we use it but some really old versions of Graphite seems to not like it. |
The server is am pointing to is 0.9.10 and apparently the POST is not enabled. |
I would recommend upgrading as grafana is barely usable with graphite 0.9.12 (with maxDataPoints patch) or graphite 0.9.13 , graphite before maxDataPoints feature makes grafana incredible slow for time rangs longer than a couple of days due to the graphite json api flooding grafana with millions of data points. so upgraded and experience grafana as it should be :) |
I am trying to use grafana with my existing graphite server. When i am importing existing dashboards grafana makes the POST call. I need to do that using the GET call. Can you
please help achieve this.
Traceback (most recent call last): File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 111, in get_response response = callback(request, _callback_args, *_callback_kwargs) File "/opt/graphite/webapp/graphite/render/views.py", line 104, in renderView seriesList = evaluateTarget(requestContext, target) File "/opt/graphite/webapp/graphite/render/evaluator.py", line 10, in evaluateTarget result = evaluateTokens(requestContext, tokens) File "/opt/graphite/webapp/graphite/render/evaluator.py", line 21, in evaluateTokens return evaluateTokens(requestContext, tokens.expression) File "/opt/graphite/webapp/graphite/render/evaluator.py", line 29, in evaluateTokens return func(requestContext, *args) File "/opt/graphite/webapp/graphite/render/functions.py", line 250, in averageSeries (seriesList,start,end,step) = normalize(seriesLists) File "/opt/graphite/webapp/graphite/render/functions.py", line 107, in normalize step = reduce(lcm,[s.step for s in seriesList])TypeError: reduce() of empty sequence with no initial value
Remote Address:ip:80
Request URL:http://ip/render
Request Method:POST
Status Code:500 INTERNAL SERVER ERROR
Request Headers
Accept:application/json, text/plain, /
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,ms;q=0.6
Cache-Control:no-cache
Connection:keep-alive
Content-Length:113
Content-Type:application/x-www-form-urlencoded
Host:ip
Origin:http://localhost
Pragma:no-cache
Referer:http://localhost/
User-Agent:Chrome 34.x
Form Data
from:-6h
until:now
target:averageSeries(metrics.cpu.*.Percent_CPU_Load)
format:json
maxDataPoints:358
Response Headers
Access-Control-Allow-Headers:origin, authorization, accept
Access-Control-Allow-Methods:GET, OPTIONS
Access-Control-Allow-Origin:*
Connection:close
Content-Type:text/html; charset=utf-8
Server:Apache/2.x
Transfer-Encoding:chunked
The text was updated successfully, but these errors were encountered: