Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error 500 run query on SiteWise property value history for un-associated SiteWise data streams #228

Closed
janborch opened this issue Oct 10, 2023 · 5 comments · Fixed by #231
Assignees

Comments

@janborch
Copy link

What happened:

Query the SiteWise Datasource using Query Type: Get Property Value History
specifying a Property Alias of an associated SiteWise data stream.

This type of query worked in past version of the plugin.

Query returns error status code 500

{
  "request": {
    "url": "api/ds/query",
    "method": "POST",
    "data": {
      "queries": [
        {
          "timeOrdering": "ASCENDING",
          "datasource": {
            "type": "grafana-iot-sitewise-datasource",
            "uid": "6ECVm78nz"
          },
          "refId": "A",
          "maxPageAggregations": 1,
          "queryType": "PropertyValueHistory",
          "propertyAlias": "/Rand/RAND089",
          "region": "",
          "propertyId": "",
          "assetIds": [],
          "datasourceId": 34,
          "intervalMs": 10000,
          "maxDataPoints": 1730
        }
      ],
      "range": {
        "from": "2023-10-10T07:04:26.903Z",
        "to": "2023-10-10T13:04:26.903Z",
        "raw": {
          "from": "now-6h",
          "to": "now"
        }
      },
      "from": "1696921466903",
      "to": "1696943066903"
    },
    "hideFromInspector": false
  },
  "response": {
    "message": "An error occurred within the plugin",
    "messageId": "plugin.downstreamError",
    "statusCode": 500,
    "traceID": ""
  }
}

What you expected to happen:

Query should return the timeseries data for this SiteWise datastream, below a sample query with an associated data stream.:

{
  "request": {
    "url": "api/ds/query",
    "method": "POST",
    "data": {
      "queries": [
        {
          "timeOrdering": "ASCENDING",
          "datasource": {
            "type": "grafana-iot-sitewise-datasource",
            "uid": "6ECVm78nz"
          },
          "refId": "A",
          "maxPageAggregations": 1,
          "queryType": "PropertyValueHistory",
          "propertyAlias": "/Rand/RAND004",
          "region": "",
          "propertyId": "",
          "assetIds": [],
          "datasourceId": 34,
          "intervalMs": 10000,
          "maxDataPoints": 1730
        }
      ],
      "range": {
        "from": "2023-10-10T07:03:42.217Z",
        "to": "2023-10-10T13:03:42.217Z",
        "raw": {
          "from": "now-6h",
          "to": "now"
        }
      },
      "from": "1696921422217",
      "to": "1696943022217"
    },
    "hideFromInspector": false
  },
  "response": {
    "results": {
      "A": {
        "status": 200,
        "frames": [
          {
            "schema": {
              "name": "H1 Rand02",
              "refId": "A",
              "meta": {
                "custom": {
                  "resolution": "RAW"
                }
              },
              "fields": [
                {
                  "name": "time",
                  "type": "time",
                  "typeInfo": {
                    "frame": "time.Time"
                  }
                },
                {
                  "name": "rand02",
                  "type": "number",
                  "typeInfo": {
                    "frame": "float64"
                  },
                  "config": {}
                },
                {
                  "name": "quality",
                  "type": "string",
                  "typeInfo": {
                    "frame": "string"
                  }
                }
              ]
            },
            "data": {
              "values": [
                [
                  1696938591738,
                  1696938596738,
                  1696938601735,
                  ...

How to reproduce it (as minimally and precisely as possible):
Query a disassociated data stream

Anything else we need to know?:

Environment:

  • Grafana version: Amazon Manage Grafana 9.4
  • Plugin version: 1.10.1
  • OS Grafana is installed on: NA
  • User OS & Browser: NA
  • Others:
@jhoulihan
Copy link

jhoulihan commented Oct 10, 2023

I encountered this issue too, using AWS Managed Grafana. For an immediate workaround/fix, the datastreams can be associated with an asset in Sitewise and the data is able to be retrieved via AWS managed grafana.
However,
CAUTION**,
Should you want to re-assign/remove the datastreams from an asset in Sitewise, for allocation later (eg to mitigate this work around for this bug) , Sitewise assigns a new UUID to the datastream using the console(?????? really) therefore you lose access to historical data a.k.a lost data, of that (previously) disassociated datastream in both Sitewise and AWS Managed Grafana!

Expressing an opinion here... if I may use the analogy of a knife and fork representing datastream 1 and datastream 2. If I place the knife and fork into a kitchen drawer (where the kitchen drawer represents a Sitewise asset). I then take out of the kitchen drawer, expecting a knife and fork, but I get a spoon and a chopstick!!

@idastambuk
Copy link
Contributor

Hi @janborch, thanks for submitting this. I managed to reproduce this with a disassociated asset.

This type of query worked in past version of the plugin.

Do you know which version of the plugin this worked in? I'm unable to find a version where it worked.
Also, does this mean that the query for disassociated assets returned data, or just that it didn't return 500?
Thanks!

@idastambuk idastambuk moved this from Incoming to Waiting in AWS Datasources Oct 12, 2023
@janborch
Copy link
Author

janborch commented Oct 12, 2023

It worked in plugin 1.5.1 , AMG 8.4.
And yes it returned data

@idastambuk idastambuk moved this from Waiting to Incoming in AWS Datasources Oct 12, 2023
@idastambuk idastambuk self-assigned this Oct 13, 2023
@idastambuk idastambuk moved this from Incoming to In Progress in AWS Datasources Oct 13, 2023
@idastambuk
Copy link
Contributor

Hi @janborch I've managed to reproduce and we're working on a fix. You can follow updates in this ticket!

@idastambuk idastambuk linked a pull request Oct 24, 2023 that will close this issue
@idastambuk idastambuk moved this from In Progress to Done in AWS Datasources Oct 24, 2023
@fridgepoet
Copy link
Member

Fixed by #231

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants