meln5674 / grafana-mongodb-community-plugin

Open Source Grafana Plugin for querying MongoDB
GNU Affero General Public License v3.0
128 stars 17 forks source link

Time Series timestamp format #30

Open driedger opened 6 months ago

driedger commented 6 months ago

Hello, I have a large amount of legacy data in mongodb, where the original author chose to store some timestamps as a shortened integer value instead of a native Date datatype. All the values stored are a javascript timestamp, divided by 60,000 so it only represents minutes.

I for the life of me cannot figure out how to use the timestamp format field in the query editor to convert my custom timestamp into a BSON Date. I tried doing the conversion in my projection query, but that also does not return any results.

Could we provide an example of the timestamp formatting options? I attempted to refer to the Go time parse documentation in the tooltip, but cant seem to make it work.

Thanks

meln5674 commented 6 months ago

The timestamp format uses the Golang format specification, and is linked in the tooltip, but here is the same link for reference: https://pkg.go.dev/time#pkg-constants .

BbBaboo42 commented 2 months ago

have you tried {"$project": {"date": {"$toDate": "$your_date_field"}}}