Hi All,

I am trying to calculate the derivative of a *counter* metric 
iface_send_bytes_total. More specifically:

   requests.get(
       "http://{}:{}/api/v1/query_range".format(
           os.environ["IXONE_PROMETHEUS_HOST"],
           os.environ["IXONE_PROMETHEUS_PORT"],
       ),
       params={
           "query": """ {}{{job="{}",asn="{}"}} """.format(
               metric, "ixone", asn
           ),
           "start": arrow.now().shift(minutes=-30).int_timestamp,
           "end": arrow.now().int_timestamp,
           "step": "300s",
       },
       timeout=10,
   ).json()

returns

{'status': 'success',

 'data': {'resultType': 'matrix',

  'result': [{'metric': {'__name__': 'iface_send_bytes_total',

     'asn': 'xxx',

     'asn_text': 'xxx',

     'host_name': 'de-fra05a-ri1',

     'iface_name': 'xe-18/1/3.0',

     'instance': 'x.x.x.x:19089',

     'job': 'ixone'},

    'values': [[1617036082, '71509706701310'],

     [1617036382, '71568383292303'],

     [1617036682, '71631728237264'],

     [1617036982, '71695503709290'],

     [1617037282, '71758877231912'],

     [1617037582, '71824964130577']]},

   {'metric': {'__name__': 'iface_send_bytes_total',

     'asn': 'xxx',

     'asn_text': 'xxx',

     'host_name': 'nl-ams04a-ri3',

     'iface_name': 'ae41.0',

     'instance': 'x.x.x.x:19089',

     'job': 'ixone'},

    'values': [[1617036082, '94056298009530'],

     [1617036382, '94169717330401'],

     [1617036682, '94286595275750'],

     [1617036982, '94407464686040'],

     [1617037282, '94530315906559'],

     [1617037582, '94656350955927']]},

   {'metric': {'__name__': 'iface_send_bytes_total',

     'asn': 'xxx',

     'asn_text': 'xxx',

     'host_name': 'nl-ams09c-ri1',

     'iface_name': 'ae41.0',

     'instance': 'x.x.x.x:19089',

     'job': 'ixone'},

    'values': [[1617036082, '2723097803324973'],

     [1617036382, '2723265785973945'],

     [1617036682, '2723436688981251'],

     [1617036982, '2723610306174213'],

     [1617037282, '2723782018282656'],

     [1617037582, '2723957898915806']]}]}}


*When* I try to calculate the derivative based on 5min interval to come up 
with the traffic in bits/sec using 


   requests.get(

       "http://{}:{}/api/v1/query_range".format(

           os.environ["IXONE_PROMETHEUS_HOST"],

           os.environ["IXONE_PROMETHEUS_PORT"],

       ),

       params={

           "query": """ (8 * irate({}{{job="{}",asn="{}"}}[5m])) """.format(

               metric, "ixone", asn

           ),

           "start": arrow.now().shift(minutes=-30).int_timestamp,

           "end": arrow.now().int_timestamp,

           "step": "300s",

       },

       timeout=10,

   ).json()

returns

{'status': 'success', 'data': {'resultType': 'matrix', 'result': []}}


Can you advise maybe what I am doing wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/2b7083dd-6b30-4d90-b358-3e89b3648323n%40googlegroups.com.

Reply via email to