예제 #1
0
파일: views.py 프로젝트: willhope/alerta
def status():

    total_alert_gauge.set(db.get_count())

    metrics = Gauge.get_gauges(format='json')
    metrics.extend(Counter.get_counters(format='json'))
    metrics.extend(Timer.get_timers(format='json'))

    auto_refresh_allow = {
        "group": "switch",
        "name": "auto_refresh_allow",
        "type": "text",
        "title": "Alert console auto-refresh",
        "description":
        "Allows auto-refresh of alert consoles to be turned off remotely",
        "value": "ON" if Switch.get('auto-refresh-allow').is_on() else "OFF",
    }
    metrics.append(auto_refresh_allow)

    now = int(time.time() * 1000)

    return jsonify(application="alerta",
                   version=__version__,
                   time=now,
                   uptime=int(now - started),
                   metrics=metrics)
예제 #2
0
파일: views.py 프로젝트: Cashlix/alerta
def prometheus_metrics():

    total_alert_gauge.set(db.get_count())

    output = Gauge.get_gauges(format='prometheus')
    output += Counter.get_counters(format='prometheus')
    output += Timer.get_timers(format='prometheus')

    return Response(output, content_type='text/plain; version=0.0.4; charset=utf-8')
예제 #3
0
파일: views.py 프로젝트: willhope/alerta
def prometheus_metrics():

    total_alert_gauge.set(db.get_count())

    output = Gauge.get_gauges(format='prometheus')
    output += Counter.get_counters(format='prometheus')
    output += Timer.get_timers(format='prometheus')

    return Response(output,
                    content_type='text/plain; version=0.0.4; charset=utf-8')
예제 #4
0
파일: views.py 프로젝트: iapilgrim/alerta
def status():

    total_alert_gauge.set(db.get_count())

    metrics = Gauge.get_gauges()
    metrics.extend(Counter.get_counters())
    metrics.extend(Timer.get_timers())

    auto_refresh_allow = {
        "group": "switch",
        "name": "auto_refresh_allow",
        "type": "text",
        "title": "Alert console auto-refresh",
        "description": "Allows auto-refresh of alert consoles to be turned off remotely",
        "value": "ON" if Switch.get('auto-refresh-allow').is_on() else "OFF",
    }
    metrics.append(auto_refresh_allow)

    return jsonify(application="alerta", time=int(time.time() * 1000), metrics=metrics)
예제 #5
0
 def get_count(query: Query = None) -> Dict[str, Any]:
     return db.get_count(query)
예제 #6
0
파일: alert.py 프로젝트: Toniob/alerta
 def get_count(query=None):
     return db.get_count(query)
예제 #7
0
파일: views.py 프로젝트: yekeqiang/alerta
    gets_started = gets_timer.start_timer()
    try:
        query, sort, _, limit, query_time = parse_fields(request)
    except Exception, e:
        gets_timer.stop_timer(gets_started)
        return jsonify(status="error", message=str(e)), 400

    fields = dict()
    fields['history'] = {'$slice': app.config['HISTORY_LIMIT']}

    try:
        alerts = db.get_alerts(query=query, fields=fields, sort=sort, limit=limit)
    except Exception as e:
        return jsonify(status="error", message=str(e)), 500

    total = db.get_count(query=query)  # because total may be greater than limit

    found = 0
    severity_count = defaultdict(int)
    status_count = defaultdict(int)

    alert_response = list()
    if len(alerts) > 0:

        last_time = None

        for alert in alerts:
            body = alert.get_body()
            body['href'] = "%s/%s" % (request.base_url.replace('alerts', 'alert'), alert.id)
            found += 1
            severity_count[body['severity']] += 1
예제 #8
0
파일: alert.py 프로젝트: 3IWOH/alerta
 def get_count(query=None):
     return db.get_count(query)
예제 #9
0
파일: alert.py 프로젝트: guardian/alerta
 def get_count(query: Query=None) -> Dict[str, Any]:
     return db.get_count(query)
예제 #10
0
    except Exception, e:
        gets_timer.stop_timer(gets_started)
        return jsonify(status="error", message=str(e)), 400

    fields = dict()
    fields['history'] = {'$slice': app.config['HISTORY_LIMIT']}

    try:
        alerts = db.get_alerts(query=query,
                               fields=fields,
                               sort=sort,
                               limit=limit)
    except Exception as e:
        return jsonify(status="error", message=str(e)), 500

    total = db.get_count(
        query=query)  # because total may be greater than limit

    found = 0
    severity_count = defaultdict(int)
    status_count = defaultdict(int)

    alert_response = list()
    if len(alerts) > 0:

        last_time = None

        for alert in alerts:
            body = alert.get_body()
            body['href'] = "%s/%s" % (request.base_url.replace(
                'alerts', 'alert'), alert.id)
            found += 1