Ad Widget

Collapse

Can't make work percentile function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aguirreif
    Junior Member
    • Jan 2018
    • 6

    #1

    Can't make work percentile function

    Hi, I'm using Zabbix with MySQL version 3.4.6-1+stretch in Debian 9.3, everything works fine except for the following:

    I want to get the 95th percentile of the output of an interface (ifHCOutOctets), and created a Calculated item in the host, but can't make it work (I know there is an option in the graphs, but I need an item to use it in grafana). The formula I'm using:
    Code:
    percentile(ifHCOutOctets[GigabitEthernet0/0/1/5.1250],60,95.0000)
    and also tried
    Code:
    percentile("ifHCOutOctets[GigabitEthernet0/0/1/5.1250]",60,95.0000)
    And I get the error:
    Code:
    8398:20180125:091153.277 item "router:perc95" became not supported: Cannot evaluate expression: "Cannot evaluate function "percentile(60,95.0000)": invalid number of parameters.".
    I read the documentation about Calculated items and the supported functions, but no luck.

    But I tried with other functions and it works just fine:

    Code:
    avg("ifHCOutOctets[GigabitEthernet0/0/1/5.1250]",60)
    last("ifHCOutOctets[GigabitEthernet0/0/1/5.1250]",60)
    max("ifHCOutOctets[GigabitEthernet0/0/1/5.1250]",60)
    min("ifHCOutOctets[GigabitEthernet0/0/1/5.1250]",60)
    prev("ifHCOutOctets[GigabitEthernet0/0/1/5.1250]",60)
    What is the right syntax for the percentile function, could someone give me some hints please?
  • kaspars.mednis
    Senior Member
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Oct 2017
    • 349

    #2
    Hi,

    percentile function uses 3 arguments
    Code:
    percentile (sec|#num,<time_shift>,percentage)
    You have only two arguments specified,if you want to ignore second parameter you must use ,, like here :

    Code:
    percentile("ifHCOutOctets[GigabitEthernet0/0/1/5.1250]"60,,95.0000)
    Regards,
    Kaspars

    Comment

    • aguirreif
      Junior Member
      • Jan 2018
      • 6

      #3
      You are so right! What a silly mistake, thank you very much, now its working great.

      Comment

      • arapacana
        Junior Member
        • Aug 2021
        • 11

        #4
        Hi, it looks like the formatting changed and now in version 5.4.4 the percentile() function is asking for:
        Code:
        percentile (/host/key,time period<:time shift>,percentage)
        I am trying to do a similar thing as Aguirreif: create a custom item so that I can get the 95th percentile to work in Grafana. But I want this item to be added to my normal templates so that it automatically applies to every tracked interface. I'm not able to get Zabbix to accept various versions of the formula:
        Code:
        percentile (//net.if.in[ifHCInOctets.{#SNMPINDEX}],300,95)
        Click image for larger version

Name:	Zabbix-FTC_ Configuration of item prototypes.png
Views:	2203
Size:	63.3 KB
ID:	431657

        What am I doing wrong?

        Any help appreciated, thanks.
        -Seth

        Comment

        • arapacana
          Junior Member
          • Aug 2021
          • 11

          #5
          I have already tried with and without the space.

          Comment

          • arapacana
            Junior Member
            • Aug 2021
            • 11

            #6
            So the following did actually work:

            percentile(//net.if.in[ifHCInOctets.{#SNMPINDEX}],300,95)

            Honestly I'm not entirely sure why it was not accepting the initial input... I ended up writing a different, simpler formula, in order to save the item, then I modified the formula to what I indicated in this post and it let me save. The item is also now available in Grafana as expected. However, I think that what I'm after is different. My goal is to have an item (so I can see it in Grafana) that shows the 95th percentile for total traffic across the graphed timeframe. The 300 seconds sampling above yields a value that changes, well, every 5 minutes, lol.

            I'm not sure what the right method is to achieve this. I was hoping to validate the built in Zabbix graph feature where you can include a percentile line for the left and/or right vertical axes of the graph, which does just put a single horizontal line across the graph for any graphing period.

            Grafana has a "threshold" line that can be set at 95% for example, but it's not a percentile function, but rather just an actual line at 95% of whatever the topmost value on the given graph timeframe is, so in my case totally useless, as I need 95th percentile function, not 95 percent.

            I have a Cacti system running simultaneously with Zabbix and their respective 95th percentile lines are close but not equivalent for the same time periods, and since I don't know how Zabbix's built-in percentile line is actually being calculated I am a little hesitant, as the 95th percentile is used for billing purposes, so it has to be correct.

            Comment

            Working...