JamesOsgood / mongodb-grafana

MongoDB plugin for Grafana
MIT License
464 stars 213 forks source link

Query not displaying data #61

Closed golanudelamare closed 5 years ago

golanudelamare commented 5 years ago

Hello,

first of all thank you for making possible to link MongoDB to Grafana.

I tried to display some data from my database, connected the database to Grafana correctly but I can't seem to be able to display the data from a collection. Here is my query:

db.endpoint_TEMP_TANK.aggregate( [ { "$match": {"Timestamp": { "$gte": "2019-06-19T09:54:31.680Z" }}}, { "$project" : {"name" : "test", "value" : "$Value", "Timestamp" : "$Timestamp", "_id" : 0 } } ] )

I receive no warnings whatsoever, only Grafana displays "No data points".

I've also tried to play a little and change the query "$gte": "ISODate(2019-06-19T09:54:31.680Z)" but then I receive an error.

Here a screenshot of one entry in my collection. They all have the same schema. Unbenannt

golanudelamare commented 5 years ago

If someone is bothered to stumble upon this post, here is my solution:

db.endpoint_TEMP_TANK.aggregate( [ {"$match": {"Timestamp": {"$gte": "$from" , "$lte": "$to" }}}, {"$sort": {"Timestamp": 1}}, {"$project": {"name" : "test", "value" : "$Value", "ts" : "$Timestamp", "_id" : 0 } } ])

The $sort is not mandatory.

Adhira-Deogade commented 3 years ago

I still can't fetch any data.