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

[0.9.0-rc31] Unable to write point #2679

Closed
JauntyWard opened this issue May 28, 2015 · 7 comments
Closed

[0.9.0-rc31] Unable to write point #2679

JauntyWard opened this issue May 28, 2015 · 7 comments

Comments

@JauntyWard
Copy link

Using the Go Influx API and Influx 0.9 rc31 I am unable to write points to the database. When using code adapted from the API documentation, the following error occurs on the write:

json: cannot unmarshal number into Go value of type struct { Results []client.Result "json:\"results,omitempty\""; Err string "json:\"error,omitempty\"" }

What am I doing wrong?

@toddboom
Copy link
Contributor

@JauntyWard can you send us an example of the code you're using?

@JauntyWard
Copy link
Author

@toddboom Sure, below is an example of my code. Thanks.

type bucket struct {
    Name      string            
    Timestamp string            
    Tags      map[string]string 
    Fields map[string]interface{} 
}

func writeInfluxDB(buckets []bucket, influxConnection *client.Client, config influxDBConfig) {
    var (
        points      = make([]client.Point, len(buckets))
        pointsIndex = 0
    )

    for k := range buckets {
        bucket := buckets[k]

        points[pointsIndex] = client.Point{
            Measurement: bucket.Name,
            Tags:        bucket.Tags,
            Fields:      bucket.Fields,
            Time:        time.Now(),
        }
        pointsIndex++
    }

    pointsBatch := client.BatchPoints{
        Points:          points,
        Database:        config.influxDatabase,
        RetentionPolicy: "default",
    }

    _, err := influxConnection.Write(pointsBatch)
    if err != nil {
        fmt.Println(err)
    }
}

@aviau
Copy link
Contributor

aviau commented Jun 4, 2015

@toddboom

I don't know if this is related, but I cannot write points on 0.9.0-rc31 (switching from rc30):
I get the following error: InfluxDBClientError: 500: {"error":"bucket name required"}

Writing this does not work:

{
    "points": [
        {
            "fields": {
                "value": 0.64
            },
            "time": "2009-11-10T23:00:00Z",
            "measurment": "cpu_load_short",
            "tags": {
                "host": "server01",
                "region": "us-west"
            }
        }
    ],
    "database": "db"
}

But this works:

{
    "fields": {
        "value": 0.64
    },
    "tags": {
        "host": "server01",
        "region": "us-west"
    },
    "database": "db",
    "measurment": "cpu_load_short",
    "time": "2009-11-10T23:00:00Z"
}

@beckettsean
Copy link
Contributor

@aviau there's a syntax error in your examples, the correct spelling is measurement, not measurment. It's wrong in both snippets, but the lack of a measurement name should render a point invalid, as the database has no way of determining to which series the point belongs. I cannot explain why the second JSON block would be accepted as a valid point.

@JauntyWard
Copy link
Author

For me, both of the examples from @aviau with measurement spelled correctly (or indeed spelled incorrectly) yields a result of "400: {"error":"json: cannot unmarshal object into Go value of type []client.Point"}"

If, however, I am to use the following JSON:

 [
    {
        "measurement": "cpu_load_short",
        "tags": {
            "host": "server01",
            "region": "us-west"
        },
        "timestamp": "2009-11-10T23:00:00Z",
        "fields": {
            "value": 0.64
        }
    }
]

The result is "500: {"error":"bucket name required"}". However if I change measurement to name. It writes successfully.

@aviau
Copy link
Contributor

aviau commented Jun 4, 2015

@beckettsean

Wierd. Using ''name'' works.

@beckettsean beckettsean changed the title Unable to write point [0.9.0-RC31] Unable to write point Jun 9, 2015
@beckettsean beckettsean changed the title [0.9.0-RC31] Unable to write point [0.9.0-rc31] Unable to write point Jun 9, 2015
@beckettsean
Copy link
Contributor

Given the write path changes between RC31 and RC32 I think we can close this issue. Please re-test with the impending RC33.

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

No branches or pull requests

4 participants