Grafana Prometheus query for Flexml_exporter

Hello All,

I just try to build up graphics to see weekly average of license usages.

Average have to be collected weekly based only from business time.
Time: 7 - 17
Days: Monday to Friday

This is query to be used :
flexlm_feature_used{app=“app1”,name=“CAM5X”} → License usage
flexlm_feature_issued{app=“app1”,name=“CAM5X”} → Total amount of license

Can some one help me with this topic, thanks!

Hi, if I understand correctly, you want to calculate the average over the last week (7 days) limited to the business time, right?
What you could do is:

  1. Limit the result series to business time like:
    <base query> and hour(time()) > 7 and hour(time()) < 17 and day_of_week(time()) >= 1 and day_of_week(time()) <= 5
    (probably need to adjust the time for time zone)
  2. Calculate avg_over_time of the expression above, e.g.
    avg_over_time((<base query> and hour(time()) > 7 and hour(time()) < 17 and day_of_week(time()) >= 1 and day_of_week(time()) <= 5)[7d:1h])

And use it as instant query - the returned value will be the average over last 7 days. I think it should work but I don’t have any data to test it out.

Hi,

Thanks!
Still some problem, also some other fine tuning needed to get some results.

When I take license usage from one week, between 5-15. Average is 49,64%.

sum(flexlm_feature_used_users{app=“app1”, name=“CAM5X”}
and on() (hour(vector(time())) >= 5 and hour(vector(time())) <= 15)
and on() (day_of_week(vector(time())) >= 1 and day_of_week(vector(time())) <= 5))

Below query return 51,5 %.
I don’t know where differences comes.

avg_over_time(
(
flexlm_feature_used{app=“app1”,name=“CAM5X”}
and on() (hour(vector(time())) >= 5 and hour(vector(time())) <= 15)
and on() (day_of_week(vector(time())) >= 1 and day_of_week(vector(time())) <= 5)
)[1w:30m]
)

Well, for starters you’ve used two different metrics in each query, which might give different results. Also, sum and avg_over_time are two different entities - sum is an aggregation that summarizes each time series into one, one timestamp at a time. avg_over_time calculates mean over provided time period with given resolution.

Hello again,

Is there any way to get weekly avg of license usages?

You can see this screenshot below, for weekly it returns mid of week value, not whole week avg.
Upper picture shows correct value for last day (37,7%), and this should be also for lower picture too, but now it shows (49,6%).

I think the second query is the right one - you should use [1d:1h] in the top one - you want to have average over a day, not a week in the first (top) one.