     raw_server.use '/metrics', (req, res) ->
         res.setHeader("Content-Type", "text/plain; version=0.0.4")
         res.setHeader('Cache-Control', 'private, no-cache, must-revalidate')
-        {get_bugs_total} = require('./local_hub')
-        labels = "project_id=\"#{project_id}\",session_id=\"#{session_id}\""
-        res.send("""
-        # HELP kucalc_project_bugs_total The total number of caught bugs.
-        # TYPE kucalc_project_bugs_total counter
-        kucalc_project_bugs_total{#{labels}} #{get_bugs_total()}
-        # HELP kucalc_project_start_time when the project/session started
-        # TYPE kucalc_project_start_time counter
-        kucalc_project_start_time{#{labels}} #{start_ts}
-        """)
+        res.send(exports.prometheus_metrics())

    )

exports.compute_status = compute_status = (cb) ->
    status = {memory:{rss:0}, disk_MB:0}
    async.parallel([
        (cb) ->
            compute_status_disk(status, cb)
        (cb) ->
            #compute_status_memory(status, cb)
            cgroup_memstats(status, cb)
        (cb) ->
            compute_status_tmp(status, cb)
    ], (err) ->

    setInterval(test_firewall, interval_ms)
    return

exports.prometheus_metrics = () ->
    {get_bugs_total} = require('./local_hub')
    labels = "project_id=\"#{project_id}\",session_id=\"#{session_id}\""
    """
    # HELP kucalc_project_bugs_total The total number of caught bugs.
    # TYPE kucalc_project_bugs_total counter
    kucalc_project_bugs_total{#{labels}} #{get_bugs_total()}
    # HELP kucalc_project_start_time when the project/session started
    # TYPE kucalc_project_start_time counter
    kucalc_project_start_time{#{labels}} #{start_ts}
    # HELP kucalc_project_cpu_usage_seconds
    # TYPE kucalc_project_cpu_usage_seconds counter
    kucalc_project_start_time{#{labels}} #{current_status.cpu?.usage ? 0.0}
    # HELP kucalc_project_memory_usage_ki
    # TYPE kucalc_project_memory_usage_ki gauge
    kucalc_project_memory_usage_ki #{current_status.memory?.rss ? 0.0}
    # HELP kucalc_project_memory_limit_ki
    # TYPE kucalc_project_memory_limit_ki gauge
    kucalc_project_memory_limit_ki #{current_status.memory?.limit ? 0.0}
    """

# called inside raw_server
exports.init_health_metrics = (raw_server, project_id) ->
    return if not exports.IN_KUCALC

    # Setup health and metrics (no url base prefix needed)
    raw_server.use '/health', (req, res) ->
