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

Float values causes agent to crash when sent via InfluxDbOutputWriter #91

Closed
GitImpulseIt opened this issue Dec 22, 2016 · 6 comments
Closed
Labels

Comments

@GitImpulseIt
Copy link

Hello Guys,

I encountered a problem with the InfluxDbOutputWriter. The floating point metrics, for example :
java.lang:type=OperatingSystem > ProcessCpuLoad
causes jmxtrans-agent to crash.

Try this :
<query objectName="java.lang:type=OperatingSystem" attribute="ProcessCpuLoad" resultAlias="ProcessCpuLoad"/>

You will obtain :
WARNING [jmxtrans-agent-1] org.jmxtrans.agent.JmxTransExporter - Ignore exception flushing metrics java.lang.RuntimeException: Failed to write metrics, response code: 400, response message: Bad Request ...

My environment :
jmxtrans-agent : 1.2.4
InfluxDB : 1.1
Tomcat : 7.0.73
JRE : Oracle 1.8.0_72-b15

Thank you for your help

@cyrille-leclerc
Copy link
Member

cyrille-leclerc commented Feb 14, 2017

Hello @BriacRONDI , I just discover your message, I had a notification issue.

Could you capture more details? I suspect that InfluxMetric.valueAsStr() could be more strict about float / decimal conversions. I see a risk with the locale of the JVM where valueAsStr() could emit a "," instead of a ".".

@cyrille-leclerc
Copy link
Member

I have identified a potential issue: big float values in java get formatted with an exponent

float value = 123_456_789.012_345;
System.out.println("value: " + value);

will return 1.23456789012345E8

See #95

@cyrille-leclerc
Copy link
Member

@kerlandsson can I get your feedback on this issue and on my PR #95 ? I suspect that we should be more strict than invoking Float.toString() to format floats.

I found in the official java client https://github.com/influxdata/influxdb-java/blob/influxdb-java-2.5/src/main/java/org/influxdb/dto/Point.java#L321

NumberFormat numberFormat = NumberFormat.getInstance(Locale.ENGLISH);
numberFormat.setMaximumFractionDigits(MAX_FRACTION_DIGITS);
numberFormat.setGroupingUsed(false);
numberFormat.setMinimumFractionDigits(1);

@GitImpulseIt
Copy link
Author

Thank you for working on this issue. I will test your PR as soon as possible and will give you a feedback.

@cyrille-leclerc
Copy link
Member

According to https://github.com/influxdata/influxdb-java/blob/influxdb-java-2.5/src/main/java/org/influxdb/dto/Point.java#L321

The expected string for 123_456_789.012_345 is 123456789.012345 and is NOT 1.23456789012345E8 as we generate today.

@cyrille-leclerc
Copy link
Member

Fix should be ready at #95

cyrille-leclerc pushed a commit that referenced this issue Feb 16, 2017
…formatting

[#91] InfluxDB - Decimal number formatting (float, double and BigDecimal)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants