Skip to content

Can't use 'to' function when param 'org' is passed #170

@lonelyleaf

Description

@lonelyleaf

Steps to reproduce:
List the minimal actions needed to reproduce the behavior.

1.code like this

        String funcStr = String.format("({r with\n" +
                "_measurement: \"%s\"," +
                "processorId: \"%s\"})", measurement, processorId);
        flux = flux.map(funcStr).to(config.getBucket());
        return client.getQueryApi().query(flux.toString(), config.getOrg());

will get

failed to initialize execute state: failed to look up organization "waterstrategy"

And I tried to use raw http request like below

POST {{myHost}}/api/v2/query?org=waterstrategy
#Accept: application/json
Content-Type: application/json
Authorization: Token {{myToken}}

{
  "query": "from(bucket:\"waterstrategy\")\n\t|> range(start:2020-11-08T08:41:16.358000000Z, stop:2020-11-08T09:15:28.087000000Z)\n\t|> filter(fn: (r) => r[\"_measurement\"] == \"c_00000005_C2_B1_UB\")\n\t|> aggregateWindow(every:60s, fn:mean)\n\t|> map(fn: (r) => ({r with\n_measurement: \"p_8a8d80b675a703110175a70445490038\",processorId: \"8a8d80b675a703110175a70445490038\"}))\n\t|> to(bucket:\"waterstrategy\", org:\"waterstrategy\")",
  "type": "flux",
  "dialect": {
    "header": true,
    "delimiter": ",",
    "annotations": [
      "datatype",
      "group",
      "default"
    ],
    "commentPrefix": "#",
    "dateTimeFormat": "RFC3339"
  }
}

and still get the error

{
  "code": "not found",
  "message": "failed to initialize execute state: failed to look up organization \"waterstrategy\""
}

But removing org param in to function like below will get 200 and my data.

{
  "query": "from(bucket:\"waterstrategy\")\n\t|> range(start:2020-11-08T08:41:16.358000000Z, stop:2020-11-08T09:15:28.087000000Z)\n\t|> filter(fn: (r) => r[\"_measurement\"] == \"c_00000005_C2_B1_UB\")\n\t|> aggregateWindow(every:60s, fn:mean)\n\t|> map(fn: (r) => ({r with\n_measurement: \"p_8a8d80b675a703110175a70445490038\",processorId: \"8a8d80b675a703110175a70445490038\"}))\n\t|> to(bucket:\"waterstrategy\")",
  "type": "flux",
  "dialect": {
    "header": true,
    "delimiter": ",",
    "annotations": [
      "datatype",
      "group",
      "default"
    ],
    "commentPrefix": "#",
    "dateTimeFormat": "RFC3339"
  }
}

Can you add a new to function without org?Is this influxdb's bug?

Specifications:

  • Client Version:1.12.0
  • InfluxDB Version: 2.0-rc
  • JDK Version: openjdk11
  • Platform: linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions