Grafana won't talk to Elasticsearch instance

Hi Grafaners,
Thanks a lot for reading my issue,
I did install and configure Grafana & Elasticsearch to start display my data,
i succeeded adding Elasticsearch as a Datasource and then i tried to add an index , mapping the fields , adding some documents then i tried parsing queries but no success.
Let me share my scripts and state :blush:
After creating the index i launched this script to add mapping :

`var elasticsearch = require('elasticsearch');

var time = Date.now || function() {
  return +new Date;
};
var client = new elasticsearch.Client({
  host: 'localhost:9200'
});
client.indices.putMapping({
  index: 'monitor',
  type: 'data',
  body: {
	  properties: {
		  
	'name': {
		'type' : 'text',
		'index': 'analyzed'
	},
    'temp' : {
		'type' : 'integer',
		'index': 'analyzed'
	},
    'hum' : {
		'type' : 'integer',
		'index': 'analyzed'
	},
    'currentValue': {
		'type' : 'float',
		'index': 'analyzed'
	},
	'timestamp': {
		'type' : 'date',
		'index': 'analyzed',
		'format': 'epoch_millis'
	}
  }
}
}, function(err,resp,status){
    if (err) {
      console.log(err);
    }
    else {
      console.log(resp);
    }
});`

Then i did the same for populating the elasticsearch with data :
var elasticsearch = require('elasticsearch'); var time = Date.now || function() { return +new Date; }; var client = new elasticsearch.Client({ host: 'localhost:9200' }); client.create({ index: 'monitor', type: 'data', id: '2', body: { name: "node", temp: 42, hum : 86, currentValue: 195.991, timestamp : time() } }, function (error) { if (error) { console.error('elasticsearch cluster is down!'); } else { console.log('All is well'); } });
I did this 10 times to have different values for testing,
I tried Query Variable too but no suceess too :persevere:


Could you please tell me what iโ€™m missing here,

Thanks for any helpful answer,
Cheers
Mohammed

checkout this guide:

1 Like

Thanks a lot @torkel
It seems like no data correspond to the query :
{"search_type":"query_then_fetch","ignore_unavailable":true,"index":"monitor"} {"size":0,"query":{"bool":{"filter":[{"range":{"timestamp":{"gte":"1505169396936","lte":"1505170799999","format":"epoch_millis"}}},{"query_string":{"analyze_wildcard":true,"query":"*"}}]}},"aggs":{"2":{"date_histogram":{"interval":"60s","field":"timestamp","min_doc_count":0,"extended_bounds":{"min":"1505169396936","max":"1505170799999"},"format":"epoch_millis"},"aggs":{"1":{"avg":{"field":"temp"}}}}}}
I think it was due to the timestamp field iโ€™m using in NodeJS
Any suggestion with that field ? maybe the Date.now function isnโ€™t giving the same time format as gravana expect,

Try modifying
var time = Date.now || function() { return +new Date; };

var time = Date.now().getTime();

Here we go !!! thanks @torkel,
Working well now