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
string values parse as boolean #39
Comments
Hi, in your example you forgot to add the point to the batchPoints: Point point = builder.build();
batchPoints.point(point);
db.write(batchPoints); But even with that modification i cannot reproduce, nor understand your bug report. db.setLogLevel(LogLevel.FULL); before you write anything. thanks |
BTW, test for this ticket lives under: |
Hi, Thanks for the quick response. Here is the log and some clarification. The code I ran this time (modified from your test): public class Test39 {
public static void main(String[] args) {
String ip = "192.168.2.79";
InfluxDB influxDB = InfluxDBFactory.connect("http://" + ip + ":8086", "root", "root");;
influxDB.setLogLevel(InfluxDB.LogLevel.FULL);
String dbName = "ticket39_" + System.currentTimeMillis();
influxDB.createDatabase(dbName);
BatchPoints batchPoints = BatchPoints
.database(dbName)
.time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
.tag("async", "true")
.retentionPolicy("default")
.consistency(InfluxDB.ConsistencyLevel.ALL)
.build();
Point.Builder builder = Point.measurement("my_type");
builder.field("my_field", "string_value");
Point point = builder.build();
batchPoints.point(point);
influxDB.write(batchPoints);
// influxDB.deleteDatabase(dbName);
}
} The log
And console log from influxdb server showing the issue
As you can see, the server response is OK, but the value has been converted to boolean. The error I mentioned earlier is visible in the "influxd" server console log, referring to the shell where i start the "influxd" on the host running it. The database server version should be the latest (think I installed it yesterday from brew). It is running on OSX 10.10.3. When I run influx -version I get the info below.
|
Ok i see, but influxdb-java writes the right content in the lineprotocol, so this seems to be a problem with influxdb itself. I still does not know how exactly tags,fields and their values have to be escaped. Would you please raise a ticket with this example , in curl, to the influxdb directly ? |
OK, I will do that. If you look at my curl examples from above, you can also see that if the POST data was
and not
that might fix it. At least with curl it worked that way. But I have no idea what is the correct intended way to escape data types so I will post a question in their issue tracker.. |
fine, im also not sure if it is correct to surround string values with quotes, so i wait for their explanation. |
There was an issue already for the same behaviour in the db console. I put my comment there influxdata/influxdb#3063 |
String field values should be surrounded by double-quotes and any double-quotes in the string need to be escaped with See https://github.com/influxdb/influxdb/blob/master/tsdb/README.md |
I close this issue again, if this happens again please reopen. |
Hi mukatee, We are using the same version of influxdb 0.9, and I encountred the same issue. All strings values are converted to boolean. Can we have please the link for the ticket ? Thanks |
@hMechkouri is this the ticket you mean? influxdata/influxdb#3063 |
Hi, I think Andrew already linked the ticket if you were referring to the one on InfluxDB itself (also should be visible in above comments). Anyway, I think it is also handled better by the driver now.. T |
Hello,
There seems to be a problem with the Point.Builder class and using String values. Example:
This results in a field of type "boolean" typically set to false in the DB.
Influxd console shows errors such as
unable to parse bool value 'string_value': strconv.ParseBool: parsing "string_value": invalid syntax
I can repeat this with curl using
$ curl -i -XPOST 'http://localhost:8086/write?db=test1&precision=ms' -d 'cpu_load_short,host=server01,region=us-west value=string_value 1435148346112'
the above creates a field called "value" with boolean type and value of false, with the matching parse error.
$ curl -i -XPOST 'http://localhost:8086/write?db=test1&precision=ms' -d 'cpu_load_short,host=server01,region=us-west value2="string_value" 1435148346112'
the above with the double quotes creates a string field with the given string_value.
The problem seems to be in Point.java file in the method "public String lineProtocol()", where you do
I would suggest checking if the value is of type String and add the double quotes to fix.
This is using the 2.0 version built from the repository.
Cheers,
T
The text was updated successfully, but these errors were encountered: