You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Richard Deurwaarder (JIRA)" <ji...@apache.org> on 2019/04/24 18:19:00 UTC

[jira] [Updated] (FLINK-12325) Statsd reporter gives wrong metrics when using negative numbers

     [ https://issues.apache.org/jira/browse/FLINK-12325?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Richard Deurwaarder updated FLINK-12325:
----------------------------------------
    Description: 
The statsd reporter has a bug I believe when using negative numbers.

 

This is because when a metric is sent it is first converted to a string value. This means 100 becomes "100" and -100 becomes "-100". This value is then sent to statsd as a gauge value.

See this line for the conversion to string: [https://github.com/apache/flink/blob/master/flink-metrics/flink-metrics-statsd/src/main/java/org/apache/flink/metrics/statsd/StatsDReporter.java#L130]

And this line for sending it as a gauge:

[https://github.com/apache/flink/blob/master/flink-metrics/flink-metrics-statsd/src/main/java/org/apache/flink/metrics/statsd/StatsDReporter.java#L184]

 

This means a value of -100 will be sent like this:
{code:java}
<metric_name>:-100|g{code}
 

The statsd protocol how ever states the following ([https://github.com/statsd/statsd/blob/master/docs/metric_types.md#gauges]):
{noformat}
Adding a sign to the gauge value will change the value, rather than setting it.
{noformat}
 

 

So sending -100 multiple times means the gauge in statsd will be decremented multiple times, rather than set to -100.

 

I believe this isn't how flink expects it to work, isn't it?

  was:
The statsd reporter has a bug I believe when using negative numbers.

 

This is because when a metric is sent it is first converted to a string value. This means 100 becomes "100" and -100 becomes "-100". This value is then sent to statsd as a gauge value.

See this line for the conversion to string: [https://github.com/apache/flink/blob/master/flink-metrics/flink-metrics-statsd/src/main/java/org/apache/flink/metrics/statsd/StatsDReporter.java#L130]

And this line for sending it as a gauge:

[https://github.com/apache/flink/blob/master/flink-metrics/flink-metrics-statsd/src/main/java/org/apache/flink/metrics/statsd/StatsDReporter.java#L184]

 

So a value of -100 will be sent like this:
{code:java}
<metric_name>:-100|g{code}
 

The statsd protocol how ever states the following ([https://github.com/statsd/statsd/blob/master/docs/metric_types.md#gauges]):
{noformat}
Adding a sign to the gauge value will change the value, rather than setting it.
{noformat}
 

 

So sending -100 multiple times means the gauge in statsd will be decremented multiple times, rather than set to -100.

 

I believe this isn't how flink expects it to work, isn't it?


> Statsd reporter gives wrong metrics when using negative numbers
> ---------------------------------------------------------------
>
>                 Key: FLINK-12325
>                 URL: https://issues.apache.org/jira/browse/FLINK-12325
>             Project: Flink
>          Issue Type: Bug
>          Components: Runtime / Metrics
>    Affects Versions: 1.6.4, 1.7.2, 1.8.0
>            Reporter: Richard Deurwaarder
>            Priority: Minor
>
> The statsd reporter has a bug I believe when using negative numbers.
>  
> This is because when a metric is sent it is first converted to a string value. This means 100 becomes "100" and -100 becomes "-100". This value is then sent to statsd as a gauge value.
> See this line for the conversion to string: [https://github.com/apache/flink/blob/master/flink-metrics/flink-metrics-statsd/src/main/java/org/apache/flink/metrics/statsd/StatsDReporter.java#L130]
> And this line for sending it as a gauge:
> [https://github.com/apache/flink/blob/master/flink-metrics/flink-metrics-statsd/src/main/java/org/apache/flink/metrics/statsd/StatsDReporter.java#L184]
>  
> This means a value of -100 will be sent like this:
> {code:java}
> <metric_name>:-100|g{code}
>  
> The statsd protocol how ever states the following ([https://github.com/statsd/statsd/blob/master/docs/metric_types.md#gauges]):
> {noformat}
> Adding a sign to the gauge value will change the value, rather than setting it.
> {noformat}
>  
>  
> So sending -100 multiple times means the gauge in statsd will be decremented multiple times, rather than set to -100.
>  
> I believe this isn't how flink expects it to work, isn't it?



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)