flexlm_exporter
flexlm_exporter copied to clipboard
Feature Request: simple/sum user licence usage per feature
As you can see below, flexlm_feature_used_users is differentiating users based on the server, display, and tool they are using for one specific feature:
I was wondering if there is the possibility to maybe create a flexlm_feature_used_users_simple view that can trim the extra stuff and sum each user's usage for a total amount. For example, user1 in the above example would be 4+2+2 and list as 8 tokens, Or can I already do that in Prometheus?
I am sorry if it's a beginner question.
Hi @D4R4, I am actually wondering why the user string has so much information. I would expect a simple username there. Can you share some information on that?
Besides of that, you have to ways of "grouping" or sum up the usage over a label, in this case user.
- On the Prometheus server side, see recording_rules. You will have the information on the TSDB, and could also discard the original metrics.
- On the Grafana side, putting a similar Prometheus query on your dashboard, not touching the prometheus TSDB.
Both have pros and cons as always, depending on what you prefer.
I added a function like this:
lmstatFeatureUsedUsersSimple: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "feature", "used_users_simple"),
"License feature used by user labeled by app, feature name and "+
"username of the license.", []string{"app", "name", "user"}, nil,),
if licenses.MonitorUsers && (licUsersByFeature[name] != nil) {
var licUsers = licUsersByFeature[name]
var licUsersTrimmed = map[string]float64{}
for username, licused := range licUsers {
var re = regexp.MustCompile(`^([^\s]*)\s.*$`)
usernameSimple := re.ReplaceAllString(username, `$1`)
if licUsersTrimmed[usernameSimple] != 0 {
licUsersTrimmed[usernameSimple] += licused
} else {
licUsersTrimmed[usernameSimple] = licused
}
}
for usernameSimple, licused := range licUsersTrimmed {
ch <- prometheus.MustNewConstMetric(
c.lmstatFeatureUsedUsersSimple, prometheus.GaugeValue,
licused, licenses.Name, name, usernameSimple)
}
}
To get the job done
Hi @D4R4, I am also interested in summing and reporting tokens per user. Where did you add this function and "if" statement?