Skip to content
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

Closed
ersubodhgupta opened this issue Apr 24, 2014 · 10 comments

Comments

@ersubodhgupta
Copy link

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

@torkelo
Copy link
Member

torkelo commented Apr 24, 2014

In your graphite apache/nginx config, can you add POST to Access-Control-Allow-Methods header? Grafana uses POST for the graphite json api.

@ersubodhgupta
Copy link
Author

Can I change this call to GET instead of POST?

@torkelo
Copy link
Member

torkelo commented Apr 24, 2014

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

@ersubodhgupta
Copy link
Author

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.

@torkelo torkelo changed the title Grafana is making the POST call while importing the existing dashboard how can I do that using the GET call? Create config setting to control if graphite json render call request is POST or GET Apr 24, 2014
@torkelo torkelo changed the title Create config setting to control if graphite json render call request is POST or GET Create config setting to control if graphite json render request is POST or GET Apr 24, 2014
@torkelo
Copy link
Member

torkelo commented Apr 24, 2014

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:

  • clone repository
  • download nodejs
  • npm install -g grunt-cli
  • grunt release

@ersubodhgupta
Copy link
Author

@torkelo thank you so much for quick turnaround time.

atdt added a commit to wikimedia/operations-puppet that referenced this issue Sep 25, 2014
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
@stefanoric
Copy link

Is it possible to do the same with the latest version of Graphana? I understand it does not use config.js anymore.

@torkelo
Copy link
Member

torkelo commented May 1, 2015

@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.

@stefanoric
Copy link

The server is am pointing to is 0.9.10 and apparently the POST is not enabled.

@torkelo
Copy link
Member

torkelo commented May 1, 2015

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants