예제 #1
0
파일: metrics.py 프로젝트: willhope/alerta
 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
파일: metrics.py 프로젝트: willhope/alerta
 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
파일: metrics.py 프로젝트: willhope/alerta
 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
파일: metrics.py 프로젝트: ngohoa211/alerta
 def find_all(cls):
     return [Gauge.from_db(gauge) for gauge in db.get_metrics(type='gauge')]
예제 #8
0
파일: metrics.py 프로젝트: ngohoa211/alerta
 def find_all(cls):
     return [Timer.from_db(timer) for timer in db.get_metrics(type='timer')]
예제 #9
0
파일: metrics.py 프로젝트: ngohoa211/alerta
 def find_all(cls):
     return [
         Counter.from_db(counter)
         for counter in db.get_metrics(type='counter')
     ]
예제 #10
0
파일: metrics.py 프로젝트: 3IWOH/alerta
 def find_all(cls):
     return [Gauge.from_db(gauge) for gauge in db.get_metrics(type='gauge')]
예제 #11
0
파일: metrics.py 프로젝트: 3IWOH/alerta
 def find_all(cls):
     return [Timer.from_db(timer) for timer in db.get_metrics(type='timer')]
예제 #12
0
파일: metrics.py 프로젝트: 3IWOH/alerta
 def find_all(cls):
     return [Counter.from_db(counter) for counter in db.get_metrics(type='counter')]