Closed jchan-legendpower closed 2 months ago
journalctl logs when the query gets run:
Jun 14 00:29:08 nixosWsl grafana-start[46173]: logger=plugin.meln5674-mongodb-community t=2024-06-14T00:29:08.010628952Z level=info msg="QueryData called" request="map[Headers:map[http_X-Dashboard-Uid:ddolhvqf511q8d http_X-Datasource-Uid:edopd924ei3gga http_X-Grafana-Org-Id:1 http_X-Panel-Id:2 http_X-Panel-Plugin-Id:timeseries] PluginContext:map[AppInstanceSettings:<nil> DataSourceInstanceSettings:map[BasicAuthEnabled:false BasicAuthUser: Database: DecryptedSecureJSONData:<nil> ID:3 JSONData:map[url:mongodb://localhost:27017] Name:meln5674-mongodb-community Type:meln5674-mongodb-community UID:edopd924ei3gga URL: Updated:2024-06-14T00:09:28Z User:] OrgID:1 PluginID:meln5674-mongodb-community User:map[Email:admin@localhost Login:admin Name:admin Role:Admin]] Queries:[map[Interval:8.64e+13 JSON:map[aggregation:[{\"$project\":{\"timestamp\":1,\"sensorID\":\"$metadata.sensorID\",\"measurement\":1,\"_id\":0}}] autoTimeBound:false autoTimeSort:false collection:my_collection database:my_db datasource:map[type:meln5674-mongodb-community uid:edopd924ei3gga] datasourceId:3 intervalMs:8.64e+07 labelFields:[sensorID] maxDataPoints:926 queryType:Table refId:A timestampField:timestamp timestampFormat: valueFieldTypes:[double time] valueFields:[measurement timestamp]] MaxDataPoints:926 QueryType:Table RefID:A TimeRange:map[From:1999-04-30T06:59:59Z To:2010-04-30T06:59:59Z]]]]"
Jun 14 00:29:08 nixosWsl grafana-start[46173]: logger=plugin.meln5674-mongodb-community t=2024-06-14T00:29:08.010806452Z level=info msg="query called" context="map[AppInstanceSettings:<nil> DataSourceInstanceSettings:map[BasicAuthEnabled:false BasicAuthUser: Database: DecryptedSecureJSONData:<nil> ID:3 JSONData:map[url:mongodb://localhost:27017] Name:meln5674-mongodb-community Type:meln5674-mongodb-community UID:edopd924ei3gga URL: Updated:2024-06-14T00:09:28Z User:] OrgID:1 PluginID:meln5674-mongodb-community User:map[Email:admin@localhost Login:admin Name:admin Role:Admin]]" query="map[Interval:8.64e+13 JSON:map[aggregation:[{\"$project\":{\"timestamp\":1,\"sensorID\":\"$metadata.sensorID\",\"measurement\":1,\"_id\":0}}] autoTimeBound:false autoTimeSort:false collection:my_collection database:my_db datasource:map[type:meln5674-mongodb-community uid:edopd924ei3gga] datasourceId:3 intervalMs:8.64e+07 labelFields:[sensorID] maxDataPoints:926 queryType:Table refId:A timestampField:timestamp timestampFormat: valueFieldTypes:[double time] valueFields:[measurement timestamp]] MaxDataPoints:926 QueryType:Table RefID:A TimeRange:map[From:1999-04-30T06:59:59Z To:2010-04-30T06:59:59Z]]"
Jun 14 00:29:08 nixosWsl grafana-start[46173]: logger=plugin.meln5674-mongodb-community t=2024-06-14T00:29:08.010925052Z level=info msg="Querying MongoDB" pipeline="[[map[Key:$project Value:[map[Key:timestamp Value:1] map[Key:sensorID Value:$metadata.sensorID] map[Key:measurement Value:1] map[Key:_id Value:0]]]]]" query="map[Interval:8.64e+13 JSON:map[aggregation:[{\"$project\":{\"timestamp\":1,\"sensorID\":\"$metadata.sensorID\",\"measurement\":1,\"_id\":0}}] autoTimeBound:false autoTimeSort:false collection:my_collection database:my_db datasource:map[type:meln5674-mongodb-community uid:edopd924ei3gga] datasourceId:3 intervalMs:8.64e+07 labelFields:[sensorID] maxDataPoints:926 queryType:Table refId:A timestampField:timestamp timestampFormat: valueFieldTypes:[double time] valueFields:[measurement timestamp]] MaxDataPoints:926 QueryType:Table RefID:A TimeRange:map[From:1999-04-30T06:59:59Z To:2010-04-30T06:59:59Z]]" context="map[AppInstanceSettings:<nil> DataSourceInstanceSettings:map[BasicAuthEnabled:false BasicAuthUser: Database: DecryptedSecureJSONData:<nil> ID:3 JSONData:map[url:mongodb://localhost:27017] Name:meln5674-mongodb-community Type:meln5674-mongodb-community UID:edopd924ei3gga URL: Updated:2024-06-14T00:09:28Z User:] OrgID:1 PluginID:meln5674-mongodb-community User:map[Email:admin@localhost Login:admin Name:admin Role:Admin]]"
Jun 14 00:29:08 nixosWsl grafana-start[46173]: logger=plugin.meln5674-mongodb-community t=2024-06-14T00:29:08.012871552Z level=info msg="query finished" context="map[AppInstanceSettings:<nil> DataSourceInstanceSettings:map[BasicAuthEnabled:false BasicAuthUser: Database: DecryptedSecureJSONData:<nil> ID:3 JSONData:map[url:mongodb://localhost:27017] Name:meln5674-mongodb-community Type:meln5674-mongodb-community UID:edopd924ei3gga URL: Updated:2024-06-14T00:09:28Z User:] OrgID:1 PluginID:meln5674-mongodb-community User:map[Email:admin@localhost Login:admin Name:admin Role:Admin]]" query="map[Interval:8.64e+13 JSON:map[aggregation:[{\"$project\":{\"timestamp\":1,\"sensorID\":\"$metadata.sensorID\",\"measurement\":1,\"_id\":0}}] autoTimeBound:false autoTimeSort:false collection:my_collection database:my_db datasource:map[type:meln5674-mongodb-community uid:edopd924ei3gga] datasourceId:3 intervalMs:8.64e+07 labelFields:[sensorID] maxDataPoints:926 queryType:Table refId:A timestampField:timestamp timestampFormat: valueFieldTypes:[double time] valueFields:[measurement timestamp]] MaxDataPoints:926 QueryType:Table RefID:A TimeRange:map[From:1999-04-30T06:59:59Z To:2010-04-30T06:59:59Z]]" response="map[frames:[map[data:map[values:[[124.956 124.456] [9.467136e+11 9.468e+11]]] schema:map[fields:[map[name:measurement type:number typeInfo:map[frame:float64]] map[name:timestamp type:time typeInfo:map[frame:time.Time]]] name:sensorID=]]]]"
Seems like this is related to labelling of the data after the fact rather than the data itself? The actual points on the graph appear to be in the correct spot.
The correct value is also shown in the query inspector if i turn off Formatted data
Doh, turns out grafana just rounds off labels depending on what unit you set it to, setting Unit to Misc > String
or Misc > Locale Format
fixes it in the graph view, table view is still messed up but you can just get to the data from the query inspector or use a separate table panel I guess..
Floating point values seem to get rounded to the nearest integer:![image](https://github.com/meln5674/grafana-mongodb-community-plugin/assets/158101206/1ba478c2-3d3a-43d6-9d13-a9b9b2b40690)
For types I've tried
float
,float64
,double
, all behave the same way