Unable to get Druid + grafana + quantify-grafana-plugins + nginx to work - MAC

This is a different error and question.

OS: MAC

Followed exact same steps: https://github.com/Quantiply/grafana-druid-wikipedia/ on MAC

http://localhost:9020/#/dashboard/file/wikipedia.json i see grafana dashboard with 3 empty widgets. Chrome JS console shows me below message three times (possibly for three widgets)

XMLHttpRequest cannot load http://localhost:8082/druid/v2. Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:9020’ is therefore not allowed access.

Options tried in nginx.cong

location ~* .(eot|ttf|woff|woff2)$ {

add_header Access-Control-Allow-Origin *;

}

location / {

root /Users/dvasthimal/GrafanaDruid/grafana-1.9.1;

index index.html index.htm;

if ($request_method = ‘OPTIONS’) {

add_header ‘Access-Control-Allow-Origin’ ‘*’;

Tried fresh and more but still not working.

FireFox Error: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1:8084/druid/v2. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

nginx.conf

Even Tried (With all permutations for location of add_header):
http://enable-cors.org/server_nginx.html

No luck.

Chrome: XMLHttpRequest cannot load http://127.0.0.1:8084/druid/v2. Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:9099’ is therefore not allowed access.

FF: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1:8084/druid/v2. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

In druid i see

Jan 29, 2016 1:15:33 AM com.sun.jersey.server.wadl.generators.AbstractWadlGeneratorGrammarGenerator attachTypes

INFO: Couldn’t find grammar element for class javax.ws.rs.core.Response

Jan 29, 2016 1:15:33 AM com.sun.jersey.server.wadl.generators.AbstractWadlGeneratorGrammarGenerator attachTypes

INFO: Couldn’t find grammar element for class java.io.InputStream

Jan 29, 2016 1:15:33 AM com.sun.jersey.server.wadl.generators.AbstractWadlGeneratorGrammarGenerator attachTypes

INFO: Couldn’t find grammar element for class javax.ws.rs.core.Response

Jan 29, 2016 1:15:33 AM com.sun.jersey.server.wadl.generators.AbstractWadlGeneratorGrammarGenerator attachTypes

INFO: Couldn’t find grammar element for class javax.ws.rs.core.Response

I created a DruidModule and see it working now. After several hours of beating the bush :slight_smile:
http://druid.io/docs/latest/development/modules.html

Glad you got it working. What was the issue?

  1. Grafana makes XMLHttpRequest to http://localhost:8082/druid/v2.

  2. Response from Druid does not have ‘Access-Control-Allow-Origin’ header set.

  3. Implement a Druid module (ServletFilter) to include Access-Control-Allow-Origin.

response.setHeader(“Access-Control-Allow-Origin”, “*”);

response.setHeader(“Access-Control-Allow-Credentials”, “true”);

response.setHeader(“Access-Control-Allow-Methods”, “POST, GET, HEAD, OPTIONS”);

response.setHeader(“Access-Control-Allow-Headers”, “Origin, Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers”);

Having Headers set through NGINX did not help.

nginx.conf

worker_processes 8;

pid nginx.pid;

events {

worker_connections 2000;

multi_accept on;

}

http {

sendfile on;

tcp_nopush on;

tcp_nodelay on;

keepalive_timeout 65;

types_hash_max_size 2048;

server_tokens off;

server_names_hash_bucket_size 32;

include mime.types;

default_type application/octet-stream;

error_log /usr/local/Cellar/nginx-full/1.8.1/logs/error.log;

access_log /usr/local/Cellar/nginx-full/1.8.1/logs/access.log;

server {

listen 9099;

location / {

root /Users/dvasthimal/druid_grafana/grafana-1.9.1;

index index.html index.htm;

}

location /druid/ {

proxy_pass http://127.0.0.1:8084/druid/v2;

}

}

}

CorsFilter.java (2.29 KB)

CORSFilterModule.java (1.69 KB)

CORSServletFilterHolder.java (1.99 KB)