micrometer-metrics / micrometer

An application observability facade for the most popular observability tools. Think SLF4J, but for observability.
https://micrometer.io
Apache License 2.0
4.45k stars 980 forks source link

min statistic for distribution summaries and timers #457

Open randysecrist opened 6 years ago

randysecrist commented 6 years ago

Quick question ...

Why doesn't https://github.com/micrometer-metrics/micrometer/blob/master/micrometer-core/src/main/java/io/micrometer/core/instrument/distribution/HistogramSnapshot.java have a min function?

jkschneider commented 6 years ago

Just wanted to be clear that there was a use for it before introducing. Seems like alerting on a min is a rare thing, but there is probably a real world case somewhere. What are you thinking of doing?

jkschneider commented 6 years ago

BTW, workaround is a P0 percentile:

@Test
void minimum() {
    DistributionSummary summary = DistributionSummary.builder("my.summary")
            .publishPercentiles(0)
            .register(new SimpleMeterRegistry());

    // dummy data
    for (int i = 1; i < 10; i++) {
        summary.record(i);
    }

    assertThat(summary.percentile(0)).isEqualTo(1);
}

Micrometer's client-side percentiles are designed to decay in the same way max does. P0 can be interpolated, but it's something.

randysecrist commented 6 years ago

Historical monitoring of snapshots (but not necessarily alert) a distribution summary for say ... minimum values for something like say ... request size. All the other relevant stats are there; just seems to be missing this one.

jkschneider commented 6 years ago

Reason I'm seeking concrete use cases is we should determine whether this is an always-on thing or an option to select. Leaning towards the latter unless there are an overwhelming number of use cases.

Request size has an interesting characteristic that it has a natural lower bound (request header size). Interestingly, it means request size essentially is never normally distributed and standard deviation is useless, but I digress...

Would you alert on min size?

randysecrist commented 6 years ago

My thought was to track request size only for something like POST or PUT; since as you say the natural lower bound for a GET or HEAD request would typically be just the header + query string.

In the case of using HTTP for incoming writes; I would only alert if the use case was below the expected minimum; if that is even knowable for a given use case ... and that really depends on the application imo.

jkschneider commented 6 years ago

Sounds like default off with an option to turn it on would be OK then?

randysecrist commented 6 years ago

Ya, I think that would work. Thanks!

jkschneider commented 6 years ago

This would be useful for the StackDriver Range aggregate as well.

jkschneider commented 6 years ago

When implemented, fix min statistic on Azure App Insights implementation as well. #441.

martel commented 5 years ago

This would also be useful while reporting to Cloudwatch where you could use StatisticSets: https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_StatisticSet.html

Instead of emitting each value separately in the reporter: https://github.com/micrometer-metrics/micrometer/blob/b604d1d89f125741437f84c934b68f2a429ff4e8/implementations/micrometer-registry-cloudwatch/src/main/java/io/micrometer/cloudwatch/CloudWatchMeterRegistry.java#L200-L207

thrxde commented 4 years ago

to enable the adjustments for Cloudwatch. i added min value to micrometer. on branch 1.3.x pullrequest