Kevin
Kevin

Reputation: 11

How can i count the total number of sources my metric has with Librato?

I'm trying to build a composite metric which displays the count of sources reporting for a metric, and alert on it (for example if the number of source count is less than 3). Is this possible?

Upvotes: 1

Views: 185

Answers (1)

Nik
Nik

Reputation: 39

Yes, it's possible. It's a little convoluted right now and we will make it simpler in the future, but this will work:

sum(
    map({source:"*"},
        divide([
            series("my_metric","&"),
            series("my_metric","&")
        ])
    )
)

Here's a quick explanation:

The map() function breaks out all of the metric's sources (by using the * wildcard). I'm dividing the metric by itself to get a 1 for each instance and all that is wrapped in the sum() function to add it up.

Upvotes: 1

Related Questions