Comments (25)
Right, it's ok after changing the type of time, thanks!
@yulidai How was this problem solved? I have the same problem, I changed the time type to isodate but it doesn't work.
from mongodb-grafana.
Right, it's ok after changing the type of time, thanks!
from mongodb-grafana.
from mongodb-grafana.
Query:
db.test.aggregate()
Error in Response
{ "message": "Cannot read property 'length' of undefined" }
from mongodb-grafana.
Thanks for your reply. I changed query to:
db.test.aggregate({"$group" : {"_id" : "$name", "num_tutorial" : {"$sum" : 1}}})
Then there's no wrong messge. But still not info showed in "Table Panel", but has result when running in mongo-cli
from mongodb-grafana.
you need to project the following fields in order for it to show on the panel:
db.test.aggregate([
{"$group" : {
"_id" : "$name",
"num_tutorial" : {"$sum" : 1},
"time" : {"$first" : "$your_time_column_name"}
}},
{"$project" : {
"name" : "$_id",
"value" : "$num_tutorial",
"ts" : "$time",
"_id" : 0
}}
])
You can check the README for more info on the required fields that the api expects
from mongodb-grafana.
@minh0722 Thank you for your patience
Here is my data in mongo with command in mongo:
db.myCollection.find()
{ "_id" : ObjectId("5b6c2f134202c48ce09a6a13"), "time" : 1533816595792, "value" : 1, "metric" : "first" }
{ "_id" : ObjectId("5b6c2f1b4202c48ce09a6a14"), "time" : 1533816603521, "value" : 3, "metric" : "second" }
{ "_id" : ObjectId("5b6c34a74202c48ce09a6a15"), "time" : 1533818023968, "value" : 5, "metric" : "second" }
Then the query in panel is:
db.myCollection.aggregate([
{"$group" : {
"_id" : "$name",
"num_tutorial" : {"$sum" : 1},
"time" : {"$first" : "$time"}
}},
{"$project" : {
"name" : "$_id",
"value" : "$num_tutorial",
"ts" : "$time",
"_id" : 0
}}
])
But still nothing showed in either Graph or Table. Any help will be appreciated, thank you!
from mongodb-grafana.
You don't have a column name
anywhere in your db. Try changing "_id" : "$name"
to "_id" : "$metric"
from mongodb-grafana.
Sorry I edited my prev comment
from mongodb-grafana.
@minh0722 Thank you, Still nothing after changing, any other problem?
from mongodb-grafana.
what's the response from the query?
from mongodb-grafana.
target is
target:"db.myCollection.aggregate([ {"$group" : { "_id" : "$metric", "num_tutorial" : {"$sum" : 1}, "time" : {"$first" : "$time"} }}, {"$project" : { "name" : "$_id", "value" : "$num_tutorial", "ts" : "$time", "_id" : 0 }} ])"
response is
response:Array[1]
0:Object
columns:Array[0]
rows:Array[0]
type:"table"
from mongodb-grafana.
change the type to timeserie. Table type is not supported
from mongodb-grafana.
Result after changing type to timeserie
response:Array[0]
from mongodb-grafana.
Maybe the reason is caused by time zone(here is china), but when i change time range from "last 6h" to "last 24h". But still nothing to show, i don't know why... T.T
from mongodb-grafana.
I dont think that's the problem cause you dont have a "$match" pipeline in your aggregate. But just to try it out add this before "$group":
{ "$match" : { "time" : { "$gte" : "$from", "$lte" : "$to" } } },
from mongodb-grafana.
No data too.
when run in mongo-cli with:
db.myCollection.aggregate([ {
"$group" : {
"_id" : "$metric",
"num_tutorial" : {"$sum" : 1},
"time" : {"$first" : "$time"} }
}, {
"$project" : {
"name" : "$_id",
"value" : "$num_tutorial",
"ts" : "$time", "_id" : 0 }
} ])
Will get data below:
{ "name" : "second", "value" : 2, "ts" : 1533816603521 }
{ "name" : "first", "value" : 1, "ts" : 1533816595792 }
But with nothing in grafana. Maybe caused by my grafana setting? But datasource test is success. And i rechecked config is same to the document
from mongodb-grafana.
did you select the datasource that is above the query box?
from mongodb-grafana.
Here is the db config:
db:Object
url:"mongodb://rpiread:[email protected]:27017,rpi-sensor-data-shard-00-01-ifxxs.mongodb.net:27017,rpi-sensor-data-shard-00-02-ifxxs.mongodb.net:27017/test?ssl=true&replicaSet=rpi-sensor-data-shard-0&authSource=admin"
db:"test"
And the mongodb is running in local, Datasource testing info is:
Data source is working
from mongodb-grafana.
Yes i did select the mongodb as the datasouce
from mongodb-grafana.
Oh my god, the Datasource testing always success even though closing the database. I think is the proxy hide the error, i'll check it...
from mongodb-grafana.
check if data source is correctly configured. I had problem with some proxy settings and I had to write the full proxy domain name in mongodb url so you can check that too
from mongodb-grafana.
@minh0722 When i change "MongoDB URL" to localhost, the response is different:
target:
db.myCollection.aggregate([ {
"$group" : {
"_id" : "$metric",
"num_tutorial" : {"$sum" : 1},
"time" : {"$first" : "$time"} }
}, {
"$project" : {
"name" : "$_id",
"value" : "$num_tutorial",
"ts" : "$time", "_id" : 0 }
} ])
response:
response:Object
message:"doc.ts.getTime is not a function"
from mongodb-grafana.
I think the field time has to be of type Date
from mongodb-grafana.
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]
from mongodb-grafana.
Related Issues (20)
- No data HOT 4
- Filtering values shows [Object object] HOT 2
- Comparison problems with Grafana variables
- Cannot read property getTime of undefined error HOT 3
- {"message":"Cannot read property 'url' of undefined"} on localhost:3333
- Cannot get plugin to show up in grafana after installation HOT 4
- Does this plugin support a containerized setup? HOT 8
- Plugin disabled due to missing plugin signature HOT 1
- Is this project abandoned? HOT 16
- Multi-value variable HOT 1
- Has anyone managed to set the connection string to read only from a secondary node ?
- Why is there no .find()? HOT 1
- Error while installing Mongo Proxy npm install HOT 1
- Unsupported OP_QUERY command: aggregate. The client driver may require an upgrade. MongoDB 6.0.1 HOT 5
- Is $unwind supported?
- Request: Sign the plugin HOT 2
- Cannot add a datasource HOT 3
- Grafana Helm HOT 2
- Times out for mongodb://localhost:27017 HOT 1
- Regarding Bar Graph
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongodb-grafana.