-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Request header field Content-Type is not allowed by Access-Control-Allow-Headers. #187
Comments
this query copies and pasted from the dashboard returns the correct data, but nothing is displayed: curl -XGET http://myeshost:9200/logstash-2013.06.24/_search?pretty -d'
{
"query": {
"filtered": {
"query": {
"query_string": {
"query": "*"
}
},
"filter": {
"range": {
"@timestamp": {
"from": "2013-06-24T16:23:36.055Z",
"to": "2013-06-24T22:23:36.055Z"
}
}
}
}
},
"highlight": {
"fields": {},
"fragment_size": 2147483647,
"pre_tags": [
"@start-highlight@"
],
"post_tags": [
"@end-highlight@"
]
},
"size": 500,
"sort": [
{
"@timestamp": {
"order": "desc"
}
}
]
}' |
I think I've found the issue. I keep getting this in the javascript console: XMLHttpRequest cannot load http://myeshost:9200/logstash-2013.06.22/_search. Request header field Content-Type is not allowed by Access-Control-Allow-Headers. |
I have been able to reproduce this issue with Apache and Ngnix, and firefox and chrome as browsers I've added the following to the location / location / {
add_header 'Access-Control-Allow-Origin' 'http://<myeshost>:9200 http://<myeshost-cname>:9200';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Headers' 'Content-Type,Accept'; per http://adminsgoodies.com/cross-origin-resource-sharing-cors-with-nginx-chrome/ But didn't solve the issue, if interested this are all the javascript errors I get: TypeError: Property 'scrollTo' of object [object global] is not a function
at g (http://<myeshost>/common/lib/angular.min.js:29:217)
at Object.e.$eval (http://<myeshost>/common/lib/angular.min.js:87:39)
at Object.e.$digest (http://<myeshost>/common/lib/angular.min.js:84:474)
at Object.e.$apply (http://<myeshost>/common/lib/angular.min.js:87:198)
at http://<myeshost>/common/lib/angular.min.js:15:270
at Object.d [as invoke] (http://<myeshost>/common/lib/angular.min.js:26:272)
at Object.rb [as bootstrap] (http://<myeshost>/common/lib/angular.min.js:15:191)
at HTMLDocument.<anonymous> (http://<myeshost>/js/app.js:64:13)
at k (http://<myeshost>/common/lib/jquery-1.8.0.min.js:2:16961)
at Object.l.add [as done] (http://<myeshost>/common/lib/jquery-1.8.0.min.js:2:17246) angular.min.js:60
(anonymous function) angular.min.js:60
(anonymous function) angular.min.js:50
e.$digest angular.min.js:84
e.$apply angular.min.js:87
(anonymous function) angular.min.js:15
d angular.min.js:26
rb angular.min.js:15
(anonymous function) app.js:64
k jquery-1.8.0.min.js:2
l.add jquery-1.8.0.min.js:2
p.fn.p.ready jquery-1.8.0.min.js:2
(anonymous function) app.js:62
x LAB.min.js:5
U LAB.min.js:5
S.j LAB.min.js:5
I LAB.min.js:5
(anonymous function) LAB.min.js:5
a.onload.a.onreadystatechange OPTIONS http://<myeshost>:9200/logstash-2013.06.24/_search Request header field Content-Type is not allowed by Access-Control-Allow-Headers. angular.min.js:98
(anonymous function) angular.min.js:98
n angular.min.js:95
l angular.min.js:93
l.(anonymous function) angular.min.js:96
ejs.client.post elastic-angular-client.js:52
doSearch elastic.min.js:4
$scope.get_data module.js:156
$scope.set_time module.js:257
(anonymous function) module.js:75
(anonymous function) services.js:65
e.$broadcast angular.min.js:88
broadcast services.js:27
(anonymous function) module.js:220
i angular.min.js:76
(anonymous function) angular.min.js:76
e.$eval angular.min.js:87
e.$digest angular.min.js:84
e.$apply angular.min.js:87
e angular.min.js:94
p angular.min.js:97
v.onreadystatechange XMLHttpRequest cannot load http://<myeshost>:9200/logstash-2013.06.24/_search. Request header field Content-Type is not allowed by Access-Control-Allow-Headers. hope that helps to narrow down the issue |
debug info from firefox shows a different issue: Error: results.hits is undefined $scope.get_data/<@https://myeshost/panels/table/module.js:176
Nc/e/j.promise.then/i@https://myeshost/common/lib/angular.min.js:76
Nc/g/<.then/<@https://myeshost/common/lib/angular.min.js:76
e.prototype.$eval@https://myeshost/common/lib/angular.min.js:87
e.prototype.$digest@https://myeshost/common/lib/angular.min.js:84
e.prototype.$apply@https://myeshost/common/lib/angular.min.js:87
e@https://myeshost/common/lib/angular.min.js:94
p@https://myeshost/common/lib/angular.min.js:97
Xc/</v.onreadystatechange@https://myeshost/common/lib/angular.min.js:98 Here is my config.js /*
elasticsearch: URL to your elasticsearch server. You almost certainly don't
want 'http://localhost:9200' here. Even if Kibana and ES are on
the same host
kibana_index: The default ES index to use for storing Kibana specific object
such as stored dashboards
modules: Panel modules to load. In the future these will be inferred
from your initial dashboard, though if you share dashboards you
will probably need to list them all here
If you need to configure the default dashboard, please see dashboards/default
*/
var config = new Settings(
{
// By default this will attempt to reach ES at the same host you have
// elasticsearch installed on. You probably want to set it to the FQDN of your
// elasticsearch host
elasticsearch: "http://"+window.location.hostname+":9200",
// elasticsearch: "http://myeshost:9200",
// elasticsearch: 'http://localhost:9200',
kibana_index: "kibana-int",
modules: ['histogram','map','pie','table','stringquery','sort',
'timepicker','text','fields','hits','dashcontrol',
'column','derivequeries','trends','bettermap'],
}
); I can access elasticsearch from my browser and I can see the elasticsearch data. I can also see it with Kibana2 I have enable/disabled the other options for eleasticsearch with the same result. |
inspecting the header shows that its "correct"
I am really out of places to look |
I'm a bit puzzled why you're getting back Apache as the server with a curl request to http://myeshost:9200/logstash-2013.06.22/_search. Are you sure you're curling the right thing? You don't mention anything about using a proxy? |
that't the header for the Kibana instance running under apache The one for the elasticsearch query looks like:
a sample of the data returned: {
took: 5,
timed_out: false,
_shards: {
total: 5,
successful: 5,
failed: 0
},
hits: {
total: 11,
max_score: 1,
hits: [
{
_index: "logstash-2013.07.08",
_type: "fluentd",
_id: "Bf2nDdlpS9mZdKU8wJLDgg",
_score: 1,
_source: {
host: "edited",
ident: "ntpd",
pid: "1749",
message: "synchronized to edited, stratum 3",
tag: "system",
@timestamp: "2013-07-08T15:52:33+00:00"
}
}, |
I am running Kibana and elasticsearch both on CentOS 6.1 |
Ah, that would be why. Elasticsearch 0.19.5 does not supply the right CORS headers. I believe 0.19.12 does, but really you should upgrade to at least 0.20.6 which is the latest logstash supports. If you move to the elasticsearch_http output you can use 0.90.2 which comes with huge memory improvements |
that was the issue, you may want to specify some minimun requirements somewhere, this thing almost drove me mad ;) |
…rce5 A raw data field for refactoring
I have followed the installation instructions, I have updated config.js and used the fqdn of my ES system. I've updated the jquery.flot.time.js file since I was getting the error about it, but still I am getting no hits in the default dashboard.
going to http://myeshost:9200/logstash-2013.06.24/_search shows all the logs entries as expected.
Is there anything obvious that I am missing?
The text was updated successfully, but these errors were encountered: