Пример #1
0
 def get_counters(cls, format=None):
     if format == 'json':
         return db.get_metrics(type='counter')
     elif format == 'prometheus':
         counters = list()
         for c in Counter.get_counters():
             counters.append('# HELP alerta_{group}_{name} {description}\n'
                             '# TYPE alerta_{group}_{name} counter\n'
                             'alerta_{group}_{name}_total {count}\n'.format(
                                 group=c.group,
                                 name=c.name,
                                 description=c.description,
                                 count=c.count))
         return "".join(counters)
     else:
         return db.get_counters()
Пример #2
0
 def get_gauges(cls, format=None):
     if format == 'json':
         return db.get_metrics(type='gauge')
     elif format == 'prometheus':
         gauges = list()
         for g in Gauge.get_gauges():
             gauges.append('# HELP alerta_{group}_{name} {description}\n'
                           '# TYPE alerta_{group}_{name} gauge\n'
                           'alerta_{group}_{name} {value}\n'.format(
                               group=g.group,
                               name=g.name,
                               description=g.description,
                               value=g.value))
         return "".join(gauges)
     else:
         return db.get_gauges()
Пример #3
0
 def get_counters(cls, format=None):
     if format == 'json':
         return db.get_metrics(type='counter')
     elif format == 'prometheus':
         counters = list()
         for c in Counter.get_counters():
             counters.append(
                 '# HELP alerta_{group}_{name} {description}\n'
                 '# TYPE alerta_{group}_{name} counter\n'
                 'alerta_{group}_{name}_total {count}\n'.format(
                         group=c.group, name=c.name, description=c.description, count=c.count
                 )
             )
         return "".join(counters)
     else:
         return db.get_counters()
Пример #4
0
 def get_gauges(cls, format=None):
     if format == 'json':
         return db.get_metrics(type='gauge')
     elif format == 'prometheus':
         gauges = list()
         for g in Gauge.get_gauges():
             gauges.append(
                 '# HELP alerta_{group}_{name} {description}\n'
                 '# TYPE alerta_{group}_{name} gauge\n'
                 'alerta_{group}_{name} {value}\n'.format(
                         group=g.group, name=g.name, description=g.description, value=g.value
                 )
             )
         return "".join(gauges)
     else:
         return db.get_gauges()
Пример #5
0
 def get_timers(cls, format=None):
     if format == 'json':
         return db.get_metrics(type='timer')
     elif format == 'prometheus':
         timers = list()
         for t in Timer.get_timers():
             timers.append(
                 '# HELP alerta_{group}_{name} {description}\n'
                 '# TYPE alerta_{group}_{name} summary\n'
                 'alerta_{group}_{name}_count {count}\n'
                 'alerta_{group}_{name}_sum {total_time}\n'.format(
                         group=t.group, name=t.name, description=t.description, count=t.count, total_time=t.total_time
                 )
             )
         return "".join(timers)
     else:
         return db.get_timers()
Пример #6
0
 def get_timers(cls, format=None):
     if format == 'json':
         return db.get_metrics(type='timer')
     elif format == 'prometheus':
         timers = list()
         for t in Timer.get_timers():
             timers.append(
                 '# HELP alerta_{group}_{name} {description}\n'
                 '# TYPE alerta_{group}_{name} summary\n'
                 'alerta_{group}_{name}_count {count}\n'
                 'alerta_{group}_{name}_sum {total_time}\n'.format(
                     group=t.group,
                     name=t.name,
                     description=t.description,
                     count=t.count,
                     total_time=t.total_time))
         return "".join(timers)
     else:
         return db.get_timers()
Пример #7
0
 def find_all(cls):
     return [Gauge.from_db(gauge) for gauge in db.get_metrics(type='gauge')]
Пример #8
0
 def find_all(cls):
     return [Timer.from_db(timer) for timer in db.get_metrics(type='timer')]
Пример #9
0
 def find_all(cls):
     return [
         Counter.from_db(counter)
         for counter in db.get_metrics(type='counter')
     ]
Пример #10
0
 def find_all(cls):
     return [Gauge.from_db(gauge) for gauge in db.get_metrics(type='gauge')]
Пример #11
0
 def find_all(cls):
     return [Timer.from_db(timer) for timer in db.get_metrics(type='timer')]
Пример #12
0
 def find_all(cls):
     return [Counter.from_db(counter) for counter in db.get_metrics(type='counter')]