Metrics

⚠️
Clever Cloud Metrics is still in beta.

In addition to logs, you can have access to metrics to know how your application behaves. By default, system metrics like CPU and RAM use are available, as well as application-level metrics when available (apache or nginx status for instance).

Display metrics

For each application, there is a Metrics tab in the console.

Overview pane

To get a quick overview of the current state of your scalers, the overview pane displays the current CPU, RAM, Disk and Network activity. On supported platforms, you can also have access to requests / second, and GC statistics.

Overview pane on Grafana
Direct link from Overview pane to app dashboard in Grafana

Advanced pane

Advanced metrics allow you to access all gathered metrics, on a specified time range.

Custom queries

All metrics are stored in Warp 10, so you can explore data directly with the quantum interface, with WarpScript.

For instance, you can derive metrics over time, do custom aggregations or combine metrics.

Get alerts

You can set up alerts in Grafana to be notified on your apps and add-ons consumption. This can be useful to monitor databases capacity or latency.

Alert option
Alert option from the general menu in Grafana

For example, check this tutorial on how to create Slack alerts with Grafana.

Monitoring’ metrics

All applications and VMs instances behind are monitored. Data is sent to Warp 10, a Geotimes series database. All metrics can be processed directly in the console in the Metrics tab of your applications or by the Clever Cloud Warp 10 endpoint.

Monitoring data model

All metrics data follow the same schema in warp 10. Each class represents a specific metric. The context is provided by the Warp 10 labels.

Class values and Labels

Overview

A telegraf daemon supplies most metrics.

Each metric is recorded as a Warp 10 class. Labels provide additional information about the VMs like instances id, organisation id, reverse proxy used.

Labels

In metrics’ data, mains labels would be :

  • owner_id : A unique ID by organisation
  • app_id : A unique ID of application
  • host : HV id hosting the VM instance
  • adc : Reverse proxy ID for http connexion (ie: applications)
  • sdc : Reverse proxy ID for tcp connexion (ie: add-ons)
  • vm_type : volatile or persistent. Is it a stateless application or a stateful add-on
  • deployment_id : ID of the deployment
⚠️
For some specific metrics. Some labels could miss.
Classes

Telegraf provide lots of metrics described in their documentation.

Below, the list of all Warp 10 classes representing Telegraf metrics :

MetricMetric
conntrack.ip_conntrack_countmem.swap_free
conntrack.ip_conntrack_maxmem.swap_total
cpu.usage_guestmem.total
cpu.usage_guest_nicemem.used
cpu.usage_idlemem.used_percent
cpu.usage_iowaitmem.vmalloc_chunk
cpu.usage_irqmem.vmalloc_total
cpu.usage_nicemem.vmalloc_used
cpu.usage_softirqmem.wired
cpu.usage_stealmem.write_back
cpu.usage_systemmem.write_back_tmp
cpu.usage_usernet.bytes_recv
disk.freenet.bytes_sent
disk.inodes_freenet.drop_in
disk.inodes_totalnet.drop_out
disk.inodes_usednet.err_in
disk.totalnet.err_out
disk.usednet.packets_recv
disk.used_percentnet.packets_sent
http_response.http_response_codenet_response.response_time
http_response.response_timenet_response.result_code
http_response.result_codenet_response.result_type
http_response.result_typenetstat.tcp_close
kernel.boot_timenetstat.tcp_close_wait
kernel.context_switchesnetstat.tcp_closing
kernel.entropy_availnetstat.tcp_established
kernel.interruptsnetstat.tcp_fin_wait1
kernel.processes_forkednetstat.tcp_fin_wait2
mem.activenetstat.tcp_last_ack
mem.availablenetstat.tcp_listen
mem.available_percentnetstat.tcp_none
mem.bufferednetstat.tcp_syn_recv
mem.cachednetstat.tcp_syn_sent
mem.commit_limitnetstat.tcp_time_wait
mem.committed_asnetstat.udp_socket
mem.dirtyprocesses.blocked
mem.freeprocesses.dead
mem.high_freeprocesses.idle
mem.high_totalprocesses.paging
mem.huge_page_sizeprocesses.running
mem.huge_pages_freeprocesses.sleeping
mem.huge_pages_totalprocesses.stopped
mem.inactiveprocesses.total
mem.low_freeprocesses.total_threads
mem.low_totalprocesses.unknown
mem.mappedprocesses.zombies
mem.page_tablesprocstat_lookup.pid_count
mem.sharedsystem.load1
mem.slabsystem.load1_per_cpu
mem.swap_cachedjvm.statsd-jvm-profiler_heap_ps-old-gen_max.value
jvm.statsd-jvm-profiler_pending-finalization-count.valuejvm.statsd-jvm-profiler_nonheap_total_committed.value
jvm.statsd-jvm-profiler_loaded-class-count.valuejvm.metrics_jvm_heapMemoryUsage_used.value
jvm.statsd-jvm-profiler_gc_PS_Scavenge_count.valuejvm.metrics_jvm_nonHeapMemoryUsage_used.value
jvm.statsd-jvm-profiler_nonheap_metaspace_init.valuejvm.statsd-jvm-profiler_nonheap_total_used.value
jvm.statsd-jvm-profiler_heap_ps-survivor-space_used.valuejvm.statsd-jvm-profiler_heap_ps-eden-space_init.value
jvm.statsd-jvm-profiler_gc_PS_MarkSweep_time.valuejvm.statsd-jvm-profiler_nonheap_total_max.value
jvm.statsd-jvm-profiler_heap_ps-eden-space_max.valuejvm.statsd-jvm-profiler_nonheap_compressed-class-space_max.value
jvm.statsd-jvm-profiler_heap_total_init.valuejvm.statsd-jvm-profiler_nonheap_code-cache_used.value
jvm.statsd-jvm-profiler_nonheap_metaspace_used.valuejvm.statsd-jvm-profiler_nonheap_compressed-class-space_init.value
jvm.statsd-jvm-profiler_nonheap_metaspace_max.valuejvm.statsd-jvm-profiler_gc_PS_MarkSweep_count.value
jvm.statsd-jvm-profiler_heap_ps-eden-space_used.value

Examples and usages

From the metrics tab on the console. You can either open a Quantum console, an online WarpScript editor, or either send your WarpScript by your own way on the Warp 10 endpoint (provided by Quantum).

More information about Quantum and Warp 10 in our documentation.

For example, you could fetch the memory usage of an application for the last hour. Smoothed by a data average by minute.

⚠️
Computation can be time intensive.
// Fix the NOW timestamp to have the same on over the script
NOW 'NOW' STORE
// fetch data over 1 hour
[ <READ TOKEN> 'mem.available' { 'app_id' '<APPLICATION ID>' } $NOW 1 h ] FETCH
// Average the data by bucket of 1 min from the last point timestamped at NOW
[ SWAP bucketizer.mean $NOW 1 m 0 ] BUCKETIZE
// From the instance granularity to application granularity. Timestamps to timestamps merge
[ SWAP [ 'app_id' ] reducer.mean ] REDUCE

Consumption metric

Consumption can also be inferred by our metrics. We provide some helper macros in the Warp 10 documentation.

Consumption unit is in second.

The following script provides the whole consumption from between start and end timestamps for all applications under an organisation.

'<READ TOKEN>' '<ORGANISATION ID>' <START TIMESTAMP> <END TIMESTAMP> @clevercloud/app_consumption

Publish your own metrics

We currently support two ways to push / collect your metrics: the statsd protocol and prometheus.

The statsd server listens on port 8125. You can send metrics using regular statsd protocol or using an advanced one as described here.

We also support Prometheus metrics collection, by default our agent collects exposed metrics on localhost:9100/metrics.

If needed, you can override those settings with the two following environment variables:

  • CC_METRICS_PROMETHEUS_PORT: Define the port on which the Prometheus endpoint is available
  • CC_METRICS_PROMETHEUS_PATH: Define the path on which the Prometheus endpoint is available

As with Prometheus the exposed host can be the same as the application deployed, you can use a basic authentication to collect the metrics with the two following environment variables:

  • CC_METRICS_PROMETHEUS_USER: Define the user for the basic auth of the Prometheus endpoint
  • CC_METRICS_PROMETHEUS_PASSWORD: Define the password for the basic auth of the Prometheus endpoint

For large custom set of metrics to collect, the default response timeout of the /metrics query is 3 seconds. You can update it with the following environment variable:

  • CC_METRICS_PROMETHEUS_RESPONSE_TIMEOUT: Define the timeout in seconds to collect the application metrics. This value must be below 60 seconds as data are collected every minutes.

To access your metrics from Warp10 you need to use the prefix prometheus. or statsd. based on what you used to publish your metrics.

You can use this query to show all collected metrics:

[
  'TOKEN'
  '~prometheus.*'
  { 'app_id' 'app_xxxxxxxx' }
  NOW 5 m
]
FETCH

Node.js example

You can use node-statsd to publish metrics:

// npm install node-statsd

const StatsD = require("node-statsd"),
  client = new StatsD();

// Increment: Increments a stat by a value (default is 1)
client.increment("my_counter");

// Gauge: Gauge a stat by a specified amount
client.gauge("my_gauge", 123.45);

Haskell example

In Haskell, metrics are usually gathered with EKG. The package ekg-statsd allows to push EKG metrics over statsd.

If you’re using warp, you can use wai-middleware-metrics to report request distributions (request count, responses count aggregated by status code, responses latency distribution).

EKG allows you to have access to GC metrics, make sure you compile your application with "-with-rtsopts=-T -N" to enable profiling.

{-# LANGUAGE OverloadedStrings #-}

-- you need the following packages
-- ekg-core
-- ekg-statsd
-- scotty
-- wai-middleware-metrics

import           Control.Monad                   (when)
import           Network.Wai.Metrics             (WaiMetrics, metrics,
                                                  registerWaiMetrics)
import           System.Metrics                  (newStore, registerGcMetrics)
import           System.Remote.Monitoring.Statsd (defaultStatsdOptions,
                                                  forkStatsd)
import           Web.Scotty

handleMetrics :: IO WaiMetrics
handleMetrics = do
  store <- newStore
  registerGcMetrics store
  waiMetrics <- registerWaiMetrics store
  sendMetrics <- maybe False (== "true") <$> lookupEnv "ENABLE_METRICS"
  when sendMetrics $ do
    putStrLn "statsd reporting enabled"
    forkStatsd defaultStatsdOptions store
    return ()
  return waiMetrics

main = do
  waiMetrics <- handleMetrics
  scotty 8080 $ do
     middleware $ metrics waiMetrics
     get "/" $
       html $ "Hello world"
Last updated on