JamesOsgood / mongodb-grafana

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

No data #112

Closed Adhira-Deogade closed 3 years ago

Adhira-Deogade commented 3 years ago

I am facing same issues - my query is this - db.test_profile.aggregate ( [ { "$match" : { "job_name" : "metric_name", "start_time" : { "$gte" : "15" } } } ])

and response is - response:Array[0]

JamesOsgood commented 3 years ago

You need to project out the fields the plugin is expecting

{"$project": {"name" : "test", "value" : "$Value", "ts" : "$Timestamp", "_id" : 0 } } ])

The API is expecting back documents with the following fields

These documents are then converted into the Grafana API http://docs.grafana.org/plugins/developing/datasources/

James

On Tue, 16 Mar 2021 at 15:58, Adhira @.***> wrote:

I am facing same issues - my query is this - db.test_profile.aggregate ( [ { "$match" : { "job_name" : "metric_name", "start_time" : { "$gte" : "15" } } } ])

and response is - response:Array[0]

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/JamesOsgood/mongodb-grafana/issues/112, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABWPD6EAM457ZZOF5PCV4ALTD554DANCNFSM4ZI2SLXA .

Adhira-Deogade commented 3 years ago

It worked! Thank you so so much, @JamesOsgood

Adhira-Deogade commented 3 years ago

I kept the time key as epoch time, this was the issue. I am using pymongo and now I used datetime to get it working. In case anyone stumbles on similar issue.

oyearunpal commented 3 years ago

You can also use your query as below

db.test_profile.aggregate([
{"$match":{"job_name" : "metric_name"} }
])

But you have to change "timeseries" to "table"