Skip to content

Feature: Any way to increment/decrement with a delay (after syntax) #762

@narcoticfresh

Description

@narcoticfresh

Hi!

First, thanks for mtail and your community support, it's great! ;-)

I'm using this version currently:

root@27ce4b2f72ca:/var/www# mtail -version
mtail version 3.0.0~rc43 git revision 3.0.0~rc43-3+b2 go version go1.15.9 go arch amd64 go os linux

I have a use case that does not seem possible currently - but would be of great use.

What do I want to archieve?

I want to render a gauge metric that expresses the number of active users of an application.

  • A user becomes "active" if he makes a request (= increment the metric). If the same user does not make a request for an hour, he comes inactive (= decrement the metric).

What i do

The application outputs this if a user makes a request (exemplary):

User is USERNAME,

So OK great - so i do this:

gauge active_users by user

/User is\: (?P<user>\w*),/ {
  active_users[tolower($user)]++
  del active_users[$user] after 1h
}

Which works to track them - but i actually do not want a metric that has a label per user - i just want to have a count..

What is missing

From what I see, there is no way to have a "count of active users in this scenario" - as Crucially, there is not log event that tells me when the hour has passed, so there is no log line that says "now he is inactive, the hour passed".

It would be great if I could write this:

active_user_acount++
active_user_acount-- after 1h

That way, if a new $user comes around (one which is not in active_users yet), i could increment it temporarly for an hour - mtail would automatically decrease it.

Another way to solve it

Another feature that would be amazing in this scenario is a function that could count the number of labels in a metric.

That way i could simply write:

hidden gauge active_users by user
gauge active_user_count

/User is\: (?P<user>\w*),/ {
  active_users[tolower($user)]++

  active_user_count = count(active_users)
}

That would be amazing! ;-) We have len() for strings, so some kind of function that allows me to do the same for the metric dimensions..

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionThis issue looks like a usage problem, not a bug or feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions