JamesOsgood / mongodb-grafana

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

Can I plot non-timeseries data from Mongo? #108

Open rana13deb opened 3 years ago

rana13deb commented 3 years ago

This is my query. I want to plot a bar graph for se_elapsed_wall_time VS se_id

db.SessionStatus.aggregate([ {"$match": {"se_start_time": {"$gte": "$from", "$lte": "$to"}}}, {"$sort": {"se_start_time": 1}}, {"$project": { "metric": "$se_id", "value": "$se_elapsed_wall_time"}} ])

JamesOsgood commented 3 years ago

Grafana is designed to plot timeseries data and that's the only data the plugin supports. For producing static bar graphs as you mention, I'd use the inbuilt MongoDB Charts https://www.mongodb.com/products/charts which need no translation layer.

James

On Wed, 9 Dec 2020 at 18:05, rana13deb notifications@github.com wrote:

This is my query. I want to plot a bar graph for se_elapsed_wall_time VS se_id

db.SessionStatus.aggregate([ {"$match": {"se_start_time": {"$gte": "$from", "$lte": "$to"}}}, {"$sort": {"se_start_time": 1}}, {"$project": { "metric": "$se_id", "value": "$se_elapsed_wall_time"}} ])

— 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/108, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABWPD6EXTJZTBEREL2ZNQNTST634XANCNFSM4UT3KQHQ .

rana13deb commented 3 years ago

Hi James,

Thank you for responding to my questions, I know that grafana is designed to plot timeseries data and it natively does not support any non-timeseries plots.

But I have come across several demos online where people have used grafana and MySQL to plot non-timeseries graphs. I was hoping to use a similar approach to this tutorial : https://medium.com/grafana-tutorials/graphing-non-time-series-sql-data-in-grafana-8a0ea8c55ee3

I understand that MongoDB Charts will natively support what I am trying to do. But due to financial constraints I cannot use MongoDB's cloud or Enterprise version, also cannot subscribe to their MongoDB Charts.

-Ranadeep

ghost commented 3 years ago

@rana13deb I'm also trying to plot and table non-timeseries data. I've done some digging and found a possible solution. Is this scenario relevant your issue?

The reason was that of course, I needed to use a collection that existed in my database.

db.<MY_COLLECTION_NAME>.aggregate([{"$count": "name"}])

worked.

Originally posted by @Kadrian in https://github.com/JamesOsgood/mongodb-grafana/issues/89#issuecomment-611469082